这是我的PHP/MySQL脚本:
<?php
mysql_connect('localhost', 'root', 'test') or die (mysql_error());
mysql_select_db('info1') or die (mysql_error());
$result = mysql_query("SELECT * from automobiles");
//Table starting tag and header cells
while($row = mysql_fetch_array($result)){
//Display the results in different cells
echo "<dd><dl><img src=' " . $row['image'] . " '>" . $row['manufacturer'] ." " . $row['model'] . "</dd></dl>";
echo "<dd><dl>" . $row['carinfo'] . "</dd></dl>";
}
//Table closing tag
echo "</table>";
?>
Run Code Online (Sandbox Code Playgroud)
但是,如果我这样做,它会工作:
{$myvariable}
Run Code Online (Sandbox Code Playgroud)
使用大括号对变量进行编码是一个好主意,或者:
echo " . $row['variable']. "
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏,谢谢!