Clinton Posted April 17, 2008 Share Posted April 17, 2008 If I use the extract(row) function how do I change the following to recognize that? <? if ($row{'dob'}=='0000-00-00') echo " "; else echo date('n/j/Y',strtotime($row{'dob'})); ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted April 17, 2008 Share Posted April 17, 2008 Use $dob in place of $row['dob'] Quote Link to comment Share on other sites More sharing options...
Clinton Posted April 17, 2008 Author Share Posted April 17, 2008 That makes sense. I gave it a shot, however, and I"m getting an error: Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in /trainingreport.php on line 31 <?php while ($row=mysql_fetch_assoc($result)){ extract($row); echo"<tr> <td>$lname $fname $mname</td> <td>" if ($dob=='0000-00-00') echo " "; else echo date('n/j/Y',strtotime({$dob})); "</td> <td>$cdl</td> </tr>"; } ?> Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 forgot a semicolon. <?php while ($row=mysql_fetch_assoc($result)){ extract($row); echo"<tr> <td>$lname $fname $mname</td> <td>"; if ($dob=='0000-00-00') echo " "; else echo date('n/j/Y',strtotime({$dob})); "</td> <td>$cdl</td> </tr>"; } ?> Quote Link to comment Share on other sites More sharing options...
Clinton Posted April 17, 2008 Author Share Posted April 17, 2008 Oh the power of a semicolon. Your English teacher would be proud. :-) What about this one? Parse error: syntax error, unexpected '{', expecting ')' in trainingreport.php on line 31 Quote Link to comment Share on other sites More sharing options...
Clinton Posted April 17, 2008 Author Share Posted April 17, 2008 Never mind. Got it. :-) Thanks a million folks. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 didn't need the brackets in strtotime <?php while ($row=mysql_fetch_assoc($result)){ extract($row); echo"<tr> <td>$lname $fname $mname</td> <td>"; if ($dob=='0000-00-00') echo " "; else echo date('n/j/Y',strtotime($dob)); "</td> <td>$cdl</td> </tr>"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.