Skip to content Skip to sidebar Skip to footer

How Do I Make A New Row In A Table Which Retrieves Database Fields From An Array?

I have an array which will fetch rows from the database. But what I want to do is to create a new empty row in the table where if $row['StudentAnswer'] equals $row['AnswerContent']

Solution 1:

How about this:

...
<td>{$row['Weight%']}</td>
<td>{" . $row['StudentAnswer'] == $row['AnswerContent'] ? $row['Weight%'] : "0" . "}</td>
<td>{$row['StudentId']}</td>
...

Think that's what you're trying to do, although I'm still a bit confused. Does that work?

Or perhaps it would be easier if you tried a more drawn out approach. It takes more syntax but makes the logic a little bit easier to decifer...

...
<td>{$row['Weight%']}</td>
<td>{"; 
if ($row['StudentAnswer'] == $row['AnswerContent'])
  echo "$row['Weight%']";
else
  echo "0";
echo "}</td>
<td>{$row['StudentId']}</td>
...

Post a Comment for "How Do I Make A New Row In A Table Which Retrieves Database Fields From An Array?"