cturner Posted November 5, 2006 Share Posted November 5, 2006 I am trying to display database items from two different tables. When I test the following code nothing displays. Can someone please tell me how I can fix this problem? Thanks in advance.[code=php:0]require "config.php"; $query2 = "SELECT * FROM tbl_product INNER JOIN tbl_cart ON tbl_product.productname = tbl_cart.username"; $r2 = mysql_query($query2) or die('Could not query because3: ' .mysql_error()); while($row2 = mysql_fetch_array($r2)){ // display the product name echo "<td valign=top>".$row2['productname']."<br />"; // display the options echo $row2['packsize']."<br />"; echo $row2['colour']."<br />"; echo $row2['icon']."<br />"; echo $row2['name']."<br />"; echo $row2['address1']."<br />"; echo $row2['address2']."<br />"; echo $row2['address3']."<br />"; echo $row2['address4']."<br />"; echo $row2['address5']."<br />"; echo "</td>"; }mysql_close();[/code] Quote Link to comment Share on other sites More sharing options...
cturner Posted November 5, 2006 Author Share Posted November 5, 2006 Can someone please move this thread to the MySQL help forum? I have just realised that I should have posted it there. Quote Link to comment Share on other sites More sharing options...
toplay Posted November 5, 2006 Share Posted November 5, 2006 It looks ok off hand. Are you sure you have data that match in BOTH tables? If you expect data back even if one table doesn't match, then you should be using a LEFT/RIGHT JOIN instead.Try running the query at the MySQL command prompt or GUI, etc. Experiment with a WHERE clause and see.Post some sample data you have in both tables if you're still having problems. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 5, 2006 Share Posted November 5, 2006 I assume the query is not throwing any errors... you should see if you're getting back any rows from mysql_count_rows() -- or whatever that function is called. Quote Link to comment 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.