【发布时间】:2018-06-05 21:01:21
【问题描述】:
我正在尝试在表中显示 mysql 数据库中的行,但我无法让 PHP 在 html 中显示。这是我的代码:
<?php
$connection = mysql_connect("localhost","root","")
or die("no connection");
$db_select=mysql_select_db("smqr",$connection)
or die("no connection to db");
$query= ("SELECT * FROM seafood");
$result=mysql_query($query)or die(mysql_error());
while
($row =mysql_fetch_array($result)):
$recipe=$row['recipe'];
$usrtext=$row['usrtext'];
$usrtxt=$row['usrtxt'];
endwhile;
?>
<body bgcolor="#ffccff">
<table align="center" width="780" height="100%" bgcolor="lightgrey" border="1">
<thead>
</thead>
<tbody>
<tr>
<th height="220">
<img src="seafoods.jpg" width="100%" height="220" /></th></tr>
<tr>
<th>Recipe Name <p>
<? echo "$recipe" ?></p></th></tr>
<tr>
<th>Ingrediants and Measurements
<p><? echo $usrtext ?></p></th></tr>
<tr>
<th>Instructions
<p> <? echo $usrtxt ?></p></th>
</tr>
我认为我必须在 while 循环中回显表,我尝试回显表,但它不起作用,所以我尝试在我发布的 html 中添加 PHP。当我在结束前回显$recipe 时,它会显示信息,但我需要它在表格中。
【问题讨论】:
标签: php mysql html-table