Php 当我从另一页获取数据时,仅获取一条记录
我已经创建了一个php页面,用于从mysql获取所有数据,我还有另一个页面用于显示网页上的数据。。。。 我有一个php页面,它类似于page_1.phpPhp 当我从另一页获取数据时,仅获取一条记录,php,mysql,Php,Mysql,我已经创建了一个php页面,用于从mysql获取所有数据,我还有另一个页面用于显示网页上的数据。。。。 我有一个php页面,它类似于page_1.php <?php include_once'db_localconnection.php'; $query="SELECT * FROM `table 5` where base='Home Plans'"; $get_allplans=mysql_query($query) or die(mysql_error());
<?php include_once'db_localconnection.php';
$query="SELECT * FROM `table 5` where base='Home Plans'";
$get_allplans=mysql_query($query) or die(mysql_error());
while($fetch=mysql_fetch_array($get_allplans))
{
$plans_code=$fetch['plan_code'];
$speed=$fetch['speed'];
$data=$fetch['data'];
$duration=$fetch['duration'];
$gb_pm=$fetch['gb_pm'];
$up_speed=$fetch['up_speed'];
$price=$fetch['price'];
$base=$fetch['base'];
}
?>
我有另一个显示数据的页面,我还包括了所有需要的页面
<td><?php echo $plans_code; ?></td>
<td><?php echo $speed; ?></td>
<td><?php echo $data; ?></td>
<td class="center"><?php echo $duration; ?></td>
<td class="center"><?php echo $gb_pm; ?></td>
<td><?php echo $up_speed; ?></td>
<td><?php echo $price; ?></td>
<td><a href="#">get reacharge</a></td>
因此,我只得到第一条记录,请帮助。您将db中的值存储到变量,例如$plans\U code等。在WHILE语句中,每次循环时,您只需覆盖这些值。相反,将它们存储到数组中并发送到第二页并显示它们 例如:
$completeData = array();
while($row=mysql_fetch_array($get_allplans))
{
array_push($completeData, $row);
}
现在将数组$completeData提取到第二页,然后显示它,
比如:
<?php foreach($completeData as $row) { ?>
<tr>
<td><?php echo $row['plans_code']; ?></td>
<td><?php echo $row['speed']; ?></td>
.
.
.
</tr>
<?php } ?>