Dysan Posted November 9, 2007 Share Posted November 9, 2007 Why doesn't this work? - I'm trying to display just the letter M if record contains Male, and F id the record contains Female. $record = 1; while($row = mysql_fetch_array($result)) { $sex = substr($row['Sex'], 0, 1; echo "<tr>"; echo "<td>" . $record++ . ") " . $row['Firstname'] . "<br>" . $row['Lastname'] . "</td>"; echo "<td>" . $sex . "</td>"; echo "</tr>"; } echo "</table>"; Link to comment https://forums.phpfreaks.com/topic/76690-why-doesnt-this-work/ Share on other sites More sharing options...
pocobueno1388 Posted November 9, 2007 Share Posted November 9, 2007 You didn't close the substr() function. $sex = substr($row['Sex'], 0, 1); Link to comment https://forums.phpfreaks.com/topic/76690-why-doesnt-this-work/#findComment-388255 Share on other sites More sharing options...
Barand Posted November 10, 2007 Share Posted November 10, 2007 That should have given you "Parse error: syntax error, unexpected ';' in C:\Inetpub\wwwroot\test\xxxxxx.php on line 4" which tells you immediately there is a problem there - perhaps something missing before the ';' ? If it didn't I recommend you turn your error reporting on. Link to comment https://forums.phpfreaks.com/topic/76690-why-doesnt-this-work/#findComment-388274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.