<?php
$link = mysql_connect ( "localhost", "root", "vertrigo" );if (mysql_select_db ( "unite2", $link )) {
//echo "数据库连接成功";
}//查询
$sql = "select * from unite_voucher";
$result = mysql_query ( $sql, $link );$row = mysql_fetch_array ( $result );print_r ($row);
?>
<table width="500" border="1">
<tr>
<th scope="col">1</th>
<th scope="col">2</th>
<th scope="col">3</th>
<th scope="col">4</th>
</tr>
<?php
while ( $row ) {
?>
<tr>
<td><?php echo $row [0]?></td>
<td><?php echo $row [1]?></td>
<td><?php echo $row [2]?></td>
<td><?php echo $row [3]?></td>
</tr>
<?php
//echo $row[0]." ".$row[1]."<br>";
$row = mysql_fetch_array ( $result );
}
mysql_close ( $link );
?>
</table>
$link = mysql_connect ( "localhost", "root", "vertrigo" );if (mysql_select_db ( "unite2", $link )) {
//echo "数据库连接成功";
}//查询
$sql = "select * from unite_voucher";
$result = mysql_query ( $sql, $link );$row = mysql_fetch_array ( $result );print_r ($row);
?>
<table width="500" border="1">
<tr>
<th scope="col">1</th>
<th scope="col">2</th>
<th scope="col">3</th>
<th scope="col">4</th>
</tr>
<?php
while ( $row ) {
?>
<tr>
<td><?php echo $row [0]?></td>
<td><?php echo $row [1]?></td>
<td><?php echo $row [2]?></td>
<td><?php echo $row [3]?></td>
</tr>
<?php
//echo $row[0]." ".$row[1]."<br>";
$row = mysql_fetch_array ( $result );
}
mysql_close ( $link );
?>
</table>
$link = mysql_connect ( "localhost", "root", "vertrigo" );
if (mysql_select_db ( "unite2", $link )) {
//echo "数据库连接成功";
}
//查询
$sql = "select * from unite_voucher";
$result = mysql_query ( $sql, $link );
?>
<table width="500" border="1">
<tr>
<th scope="col">1</th>
<th scope="col">2</th>
<th scope="col">3</th>
<th scope="col">4</th>
</tr>
<?php
while ( $row = mysql_fetch_array ( $result ) ) {
?>
<tr>
<td><?php echo $row [0]?></td>
<td><?php echo $row [1]?></td>
<td><?php echo $row [2]?></td>
<td><?php echo $row [3]?></td>
</tr>
<?php
}
mysql_close ( $link );
?>
</table>
还有,你这个SQL语句确定在数据库中有返回结果吗?
用 $row[fieldname]另外还有权限与编码问题
SET character_set_connection= utf8; //gb2312
一把sql语句要先在sql中写好,然后执行下,看有没有错误,能不能查出数据。
这样效率高点,要不然在程序中写出错了很难找
或者显示的时候直接改为:
$row['字段名']而不是你以前的$row[2]数字形式!