funbinod Posted April 26, 2014 Share Posted April 26, 2014 (edited) i dunno what happened to these fetching lines. it escapes first row and returns rest of the rows... $query = "SELECT * FROM tempsales";$result = mysqli_query($connect, $query) or die(mysqli_error($connect));echo "<table border='1' cellpadding='4px'> <tr bgcolor='#009933' align='center'> <td>S.N.: </td> <td>SID: </td> <td>Quantity: </td> <td>Rate: </td> <td>Discount.: </td> <td>Totel Amount: </td> <td>Edit:</td> </tr>";while($row = mysqli_fetch_array($result)) { echo "<tr bgcolor='#009966'>"; echo "<td>" . $row['sn'] . "</td>"; echo "<td>" . $row['sid'] . "</td>"; echo "<td>" . $row['qty'] . "</td>"; echo "<td>" . $row['rate'] . "</td>"; echo "<td>" . $row['less'] . "</td>"; echo "<td>" . $row['amt'] . "</td>"; echo "<td><a href="cedit.php?cid=$row[cid]&m=edit" class=slink>Edit</a></td>"; echo "</tr>";} echo "</table>"; Edited April 26, 2014 by funbinod Link to comment Share on other sites More sharing options...
davej Posted April 26, 2014 Share Posted April 26, 2014 What is "escapes" ? Link to comment Share on other sites More sharing options...
funbinod Posted April 27, 2014 Author Share Posted April 27, 2014 (edited) "escapes" means it doesn't display first row but shows all other rows.... Edited April 27, 2014 by funbinod Link to comment Share on other sites More sharing options...
funbinod Posted April 28, 2014 Author Share Posted April 28, 2014 (edited) its fine. i solved it myself. but there arouse a question.. can anyone please define it? i used $query = "SELECT * FROM tempsales";$result = mysqli_query($connect, $query) or die(mysqli_error($connect)); for while loop. and i used the same query to grab 'cid' column from the same table 'tempsales' like this.. $rowcid = mysqli_fetch_array($result); $query1 = "SELECT * FROM customer WHERE cid = '$rowcid[cid]'"; $result1 = mysqli_query($connect, $query1) or die(mysqli_error($connect)); $rowcname = mysqli_fetch_array($result1); there is a column 'cid' in table 'tempsales' and same column on 'customer' table and i want to grab 'cname' from 'customer' using 'cid'. doing this didn't show row 1 from table 'tempsales'. but when i made same query again to grab 'cid' field like this --- $cnamequery = "SELECT * FROM tempsales";$cnameresult = mysqli_query($connect, $cnamequery) or die(mysqli_error($connect));$rowcid = mysqli_fetch_array($cnameresult);$query1 = "SELECT * FROM customer WHERE cid = '$rowcid[cid]'";$result1 = mysqli_query($connect, $query1) or die(mysqli_error($connect));$rowcname = mysqli_fetch_array($result1); the problem is solved. i want to know what is this issue. can't i use same query to different places and querys? Edited April 28, 2014 by funbinod Link to comment Share on other sites More sharing options...
Ingolme Posted April 28, 2014 Share Posted April 28, 2014 When you call fetch_array() you're moving the pointer ahead. If you use fetch_array() again the pointer will not be in the first position. You can fix that by setting the pointer to 0 using mysqli_data_seek() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now