And here's my code that I adjusted from tutorial examples:
Code: Select all
$db = mysql_connect("localhost", "pstvalu_director", "XXXXXXX");
$result = mysql_query("SELECT * FROM alumni ORDER BY lastname",$db);
if ($myrow = mysql_fetch_array($result))
echo "<table border=1>\n";
<td>%s (%s), %s</td>
while ($myrow = mysql_fetch_array($result));
echo "Sorry, no records were found!";
In general it works. I want to put people's maiden name in parenthesis following their last name, then followed by a comma, then their first name. This works perfectly for the first item. But the other 98% of the rows do not have maiden names in the mySQL database (they're blank). Is there a way I can alter this code so that it will only print the "(" and ")" on each side of the "%s" ONLY if there is data associated with that column?
The same situation effects those people who don't have cities and states associated with them, in which case they still get a comma in that section.
Please help! Thanks.