-3

I'm trying to have the value of a PHP variable there's my code: ...

while($row = mysqli_fetch_array($response)){
$var = $row['num'];
echo $var;
echo '<tr><td align="left">' . 
$row['id'] . '</td><td align="left">' . 
$row['num'] . '</td><td align="left">' .
$row['used'] . '</td><td align="left">' . 
$row['temps'] . '</td><td align="left">' . 
$row['prix'] . '</td><td align="left">' . 
$row['date'] . '</td><td align="left"> .
<p>
<form action="delete.php" method="post">
<input type="text" name="name" value=$var />
</p>

<p>
<input type="submit" name="submit" value="Delete" />
</p>
</form>';

echo '</tr>';
}

i'm trying to put the value of $var but when i do this code there's an error

( ! ) Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ',' or ';' in C:\wamp64\www\Site test\php\mysql_getInfo.php on line 39

For information my code is getting the database and putting on a website, I'm trying to add button to delete from the database.

chris85
  • 23,846
  • 7
  • 34
  • 51
Noonana73
  • 3
  • 1

1 Answers1

-2

i recommend you to echo every line and also extracting ur $var:

while($row = mysqli_fetch_array($response)){
$var = $row['num'];
echo $var;
echo '<tr><td align="left">';
echo $row['id'] . '</td><td align="left">';
echo $row['num'] . '</td><td align="left">';
echo $row['used'] . '</td><td align="left">'; 
echo $row['temps'] . '</td><td align="left">';
echo $row['prix'] . '</td><td align="left">'; 
echo $row['date'] . '</td><td align="left">';
echo '<p>';
echo '<form action="delete.php" method="post">';
echo '<input type="text" name="name" value='.$var.' />';
echo '</p>';

echo '<p>';
echo '<input type="submit" name="submit" value="Delete" />';
echo '</p>';
echo '</form>';

echo '</tr>';
}
thomasxd24
  • 55
  • 7