当我从另一个页面获取数据时,只有单个记录

时间:2015-10-10 11:41:48

标签: php mysql

我创建了一个用于从mysql获取所有数据的php页面,我有另一个页面在网页上显示数据.... 我有php页面,如page_1.php

> OMP_NUM_THREADS=1 numactl -N 0 -m 0 ./recursive 500
Time for recursive method is 9.32888s
> OMP_NUM_THREADS=2 numactl -N 0 -m 0 ./recursive 500
Time for recursive method is 9.48718s
> OMP_NUM_THREADS=4 numactl -N 0 -m 0 ./recursive 500
Time for recursive method is 10.962s
> OMP_NUM_THREADS=8 numactl -N 0 -m 0 ./recursive 500
Time for recursive method is 13.2786

我有另一个节目数据页面我还包括所有需要的页面

<?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'];
    }    
?>

所以我只获得第一张唱片请帮助..

1 个答案:

答案 0 :(得分:0)

您可以在WHILE语句中将db中的值存储到变量,即$ plans_code等,每次循环时都会覆盖值。而是将它们存储到数组中并发送到第二页并显示它们。

示例:

$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 } ?>