Jump to content

Why Doesn't This Work?


Dysan

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.