livewirerules Posted June 9, 2010 Share Posted June 9, 2010 Im am trying to retrieve all the transaction information that is done by user. Below is my code $sql="select * from trans where tfid='987456'"; $result=mysql_query($sql) or die(mysql_error()); while ($row=mysql_fetch_array($result)) { $date=$row['h_date']; $ref=$row['ref']; price=$row['price']; echo"<tr> <td>$date</td> <td>$ref</td> <td>$price</td> </tr>"; I have around 6 transactions with the same tfid. but in the above code it shows only the first result.. how do i show all the 6 transactions? thanks Quote Link to comment https://forums.phpfreaks.com/topic/204252-display-all-results-with-the-same-id/ Share on other sites More sharing options...
dabaR Posted June 9, 2010 Share Posted June 9, 2010 Well, that code would not compile (missing } for while loop), but it looks like it would display all results, and the SQL seems to get all the transactions with that tfid. Can you double check by running the same query right inside mysql? Quote Link to comment https://forums.phpfreaks.com/topic/204252-display-all-results-with-the-same-id/#findComment-1069766 Share on other sites More sharing options...
livewirerules Posted June 9, 2010 Author Share Posted June 9, 2010 sorry... actually its a partial code.The complete code within the loop was about 200 lines,i just edited for a few lines. there are no syntax errors Quote Link to comment https://forums.phpfreaks.com/topic/204252-display-all-results-with-the-same-id/#findComment-1069770 Share on other sites More sharing options...
dabaR Posted June 9, 2010 Share Posted June 9, 2010 And what about running the same query directly in mysql? If that works, you might want to post some of the code you cut out, cause there don't seem to be many errors in that code shown. Quote Link to comment https://forums.phpfreaks.com/topic/204252-display-all-results-with-the-same-id/#findComment-1069772 Share on other sites More sharing options...
PFMaBiSmAd Posted June 9, 2010 Share Posted June 9, 2010 It's highly likely that you are reusing $result inside of the loop, so when the while() is evaluated after the first time through the loop, there is no longer anything to fetch. Quote Link to comment https://forums.phpfreaks.com/topic/204252-display-all-results-with-the-same-id/#findComment-1069773 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.