Jump to content

error on fetching rows


funbinod

Recommended Posts

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 by funbinod
Link to comment
Share on other sites

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 by funbinod
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...