开发者

problem during data fetch

开发者 https://www.devze.com 2023-01-01 03:30 出处:网络
here is my code $sql=\"SELECT * FROM $tbl_name WHERE ownerId=\'$UserId\'\"; $result=mysql_query($sql,$link)or die(mysql_error());

here is my code

$sql="SELECT * FROM $tbl_name WHERE ownerId='$UserId'"; $result=mysql_query($sql,$link)or die(mysql_error());

$row = mysql_fetch_array($result, MYSQL_ASSOC);

<?php
                                    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
                                        {
                                            echo "<tr>";
                                            echo "<td>".$row['pinId']."</td>";
                                            echo "<td>".$row['usedby']."</td>";
                                            echo "<td>".$row['status']."</td>";
                                            echo "</tr>";
                                        }
                                    ?>

it is ignoring the first record means if 4 rows are in $row its igno开发者_Python百科ring the 1st one rest three are coming on page. ownerId is not primary key.


This problem is arising because you already called $row = mysql_fetch_array($result, MYSQL_ASSOC); once before looping..

try this code...

$sql="SELECT * FROM $tbl_name WHERE ownerId='$UserId'"; 
$result=mysql_query($sql,$link)or die(mysql_error());

<?php
 while($row = mysql_fetch_array($result, MYSQL_ASSOC))
  {
   echo "<tr>";
   echo "<td>".$row['pinId']."</td>";
   echo "<td>".$row['usedby']."</td>";
   echo "<td>".$row['status']."</td>";
   echo "</tr>";
   }
 ?>

all i have done is removed the 3rd line from your code....

0

精彩评论

暂无评论...
验证码 换一张
取 消