I’m trying to echo a value in a form based on number of rows returned from database query. Keep getting error Parse error: syntax error, unexpected T_ECHO, expecting ‘,’ or ‘;’
As you can probably tell I’m pretty new to this. Can anyone help me echo the variable? I know that $num_rows is returning a value as using var_dump shows. Thanks
<?
if($num_rows <= 10) {
echo '</br></br><form id="h1" class="rounded" action="4.php" target=""
method="post"/>
<input type="submit" name="submit" class="button" value="10" /><br>
<input type="text" name="number_of_tests" value="'echo $num_rows;'"/>
</form>';
}
if($num_rows >10) {
echo '</br></br><form id="h2" class="rounded" action="4.php"
target="_blank" method="post"/>
<input type="submit" name="submit" class="button" value="11"/><BR>
<input type="text" name="number_of_tests" value="'echo $num_rows;'"/>
</form>';
}?>
In both of your code blocks, you repeat the command echo instead of either concatenating the output or using two statements. You have done this:
which is a syntax error. Instead, you can do this:
or this: