HighDots Forums  

PHP MySQL Data Display Question

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss PHP MySQL Data Display Question in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David B
 
Posts: n/a

Default PHP MySQL Data Display Question - 07-17-2004 , 10:46 PM






I want to display just the first three letters of every word in one
field from a table, and I also want the first letters changed to lower
case. I believe either of the following two codes will do the trick, but
I can't figure out how to plug them into my query:

1) function makeshortcode($name) {
return strtolower(substr($name, 0, 3)) . substr(microtime(), 3, 7);
}

2) $first_three_letters = strtolower(substr("$string", 1));

Below is a copy of my query. Can anyone show where to insert either of
the above scripts or suggest an alternate method of printing out the
first three letters only, all lower case?

Thanks.

<?php
$result = mysql_query('select count(*) from fammammals');
if (($result) && (mysql_result ($result , 0) > 0)) {
} else {
die('Invalid query: ' . mysql_error());
}
{
$res = mysql_query ("SELECT * FROM fammammals") or die (mysql_error());
echo "<table class='sortable' id='tabedit'>";
//<!-- BeginDynamicTable -->
while ($row = mysql_fetch_array ($res))
{
echo '<tr><td class="text"><'. $_SERVER['PHP_SELF'] .'?id='.
$row['IDMam'] .'>'. $row['FamMamName'] .'</td></tr>'."\n"; }

/*
echo '<tr><td class="text"><'. $_SERVER['PHP_SELF'] .'?id='.
$row['IDArea'] .'>'. $row['NamePA'] .'</td><td class="right">'.
$row['LinkPA'] .'</td></tr>'."\n"; }
*/

}
echo '</table>';
?>


Reply With Quote
  #2  
Old   
Michael Fesser
 
Posts: n/a

Default Re: PHP MySQL Data Display Question - 07-19-2004 , 10:28 AM






.oO(David B)

Quote:
I want to display just the first three letters of every word in one
field from a table, and I also want the first letters changed to lower
case. I believe either of the following two codes will do the trick, but
I can't figure out how to plug them into my query:
Do you want to do these modifications when fetching the data (i.e. in
your SQL-query) or after fetching it (i.e. in the PHP-code)?

1) SQL: SELECT ... LOWER(LEFT(yourField, 3)) AS yourField, ...
2) PHP: $value = strtolower(substr($value, 0, 3));

HTH
Micha


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.