OriginalSunny Posted April 16, 2006 Share Posted April 16, 2006 Hi,I have used the following code for my queries: $connect = connect_to_db("con.inc"); $query = "SELECT * FROM purc WHERE ID='{$_SESSION['ID']}'"; $result = mysql_query($query,$connect) or die("sql_del: ".mysql_error($connect)); $connect1 = connect_to_db("con.inc"); $query1 = "SELECT * FROM [b]purc_item[/b] WHERE ID='{$_SESSION['ID']}'"; $result1 = mysql_query($query,$connect1) or die("sql_del: ".mysql_error($connect1));The only difference is the table which is highlighted in bold and i have changed the variable names. Now the following code is used to extract the data: echo "The ID for the product is: <br>";while($row = mysql_fetch_array($result)) { echo ''.$row['ID'].'';} echo "The quantity for the product is: <br>";while($row = mysql_fetch_array([b]$result1[/b])) { echo "<td><b>"; echo ''.$row['quantity'].''; echo "</b></td>";}echo "<br><br>";The first piece of data is extracted perfectly but the second piece doesnt seem to work?? I have changed the variable name. It seems i can keep extracting data from the first query but not the second? I had this problem before and wanst able to see what i was doing wrong? Link to comment https://forums.phpfreaks.com/topic/7536-one-query-works-but-the-other-doesnt/ Share on other sites More sharing options...
AndyB Posted April 16, 2006 Share Posted April 16, 2006 The value of $row used in the first loop is being reset in the second loop. Try this:while([b]$row1[/b] = mysql_fetch_array($result1)){echo "<td><b>";echo ''.$[b]row1[/b]['quantity'].''; Link to comment https://forums.phpfreaks.com/topic/7536-one-query-works-but-the-other-doesnt/#findComment-27459 Share on other sites More sharing options...
OriginalSunny Posted April 16, 2006 Author Share Posted April 16, 2006 Thanks but there is still no output for the second loop. Link to comment https://forums.phpfreaks.com/topic/7536-one-query-works-but-the-other-doesnt/#findComment-27460 Share on other sites More sharing options...
AndyB Posted April 16, 2006 Share Posted April 16, 2006 [code] $result1 = mysql_query($query,$connect1)[/code]That should be:[code] $result1 = mysql_query($query1,$connect1)[/code] Link to comment https://forums.phpfreaks.com/topic/7536-one-query-works-but-the-other-doesnt/#findComment-27461 Share on other sites More sharing options...
OriginalSunny Posted April 16, 2006 Author Share Posted April 16, 2006 Thanks Link to comment https://forums.phpfreaks.com/topic/7536-one-query-works-but-the-other-doesnt/#findComment-27466 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.