I am trying to select all the values from a row in a table using sql and php in
ID: 3859881 • Letter: I
Question
I am trying to select all the values from a row in a table using sql and php in order to display it into an html table. Below is my code:
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "Cherries7";
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$sql = 'SELECT question, a1, a2, a3, a4, a5, a6, a7, a8 FROM ffq';
mysql_select_db('FamilyFeud');
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_assoc($retval)) {
echo " <section><table align='center'>
<tr><td colspan='4', align='center'> {$row['question']} </td></tr>
<tr>
<td align='center'> {$row['a1']} </td>
<td class='click'><button type='button'><script>document.write(a1p)</script></button></td>
<td align='center'> {row['a5']} </td>
<td class='click'><button type='button'><script>document.write(a5p)</script></button></td>
</tr>
<tr>
<td align='center'> {$row['a2']} </td>
<td class='click'><button type='button'><script>document.write(a2p)</script></button></td>
<td align='center'> {row['a6']} </td>
<td class='click'><button type='button'><script>document.write(a6p)</script></button></td>
</tr>
<tr>
<td align='center'> {$row['a3']} </td>
<td class='click'><button type='button'><script>document.write(a3p)</script></button></td>
<td align='center'> {row['a7']} </td>
<td class='click'><button type='button'><script>document.write(a7p)</script></button></td>
</tr>
<tr>
<td align='center'> {$row['a4']} </td>
<td class='click'><button type='button'><script>document.write(a4p)</script></button></td>
<td align='center'> {row['a8']} </td>
<td class='click'><button type='button'><script>document.write(a8p)</script></button></td>
</tr>
</table></section> ";
}
Half of my code works, but the other half doesn't. Can someone tell me what I am doing wrong? Thanks so much!
Iteration #3 2/23-3/14 x D CTemp pattern examp x D Assignment2.pdf x Presenter view x 27.0.0.1 localhost/ C 127.00. Feud/Family Feud PresenterView.php Apps Blackboard Maste ng Physics NeHe D Modern operating sy S Ncsu arraylist Linked List How do you say hello in a different language Current Score Bonjour frowTa5T) Team 1 Salam Hola. Ask me anything C Chegg Current Score Team 2Explanation / Answer
Since you're using " " and the echo statement. Simply writing $variableName will do.
You dont need to put {} before and after. That should do.
<td align='center'> $row['a1'] </td>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.