damianharvey Posted May 7, 2003 Share Posted May 7, 2003 Hi all, I have a problem where I am trying to display the contents of a table joined with a description field joined from another table. The resulting HTML table generates completely randomly. Sometimes it\'s fine. Other times it is stuffed (see screen dump - http://www.users.bigpond.com/damianharvey/table1.jpg ) It\'s not always the same rows that are stuffed either. Sometimes it also gives me the \"The page cannot be displayed\" error. My SQL Statement is: select * from inventory left join shirt_type on shirt_type.type = inventory.shirt_type ORDER BY inventory.design_name, inventory.design_colour and I have no problem with this in my ODBC SQL Query program. My PHP code is (roughly) : <?php require_once(\'Connections.php\'); ?> <?php mysql_select_db($database_Test, $Test); $query_inventory = \"select * from inventory left join shirt_type on shirt_type.type = inventory.shirt_type ORDER BY inventory.design_name, inventory.design_colour\"; $inventory = mysql_query($query_inventory, $Test) or die(mysql_error()); $row_inventory = mysql_fetch_assoc($inventory); $totalRows_inventory = mysql_num_rows($inventory); ?> //then some other stuff <table> <?php do { ?> <tr> <td><?php echo $row_inventory[\'design_name\']; ?></td> <td><?php echo $row_inventory[\'design_colour\']; ?></td> <td><?php echo $row_inventory[\'shirt_colour\']; ?></td> <td><?php echo $row_inventory[\'shirt_size\']; ?></td> <td><?php echo $row_inventory[\'description\']; ?></td> <td><?php echo $row_inventory[\'quantity\']; ?></td> <td><?php echo \"<a href=\"Cart.php?action=ADD&design_name=\".$row_inventory[\'design_name\'].\"&design_colour=\".$row_inventory[\'design_colour\'].\"&shirt_colour=\".$row_inventory[\'shirt_colour\'].\"&shirt_size=\".$row_inventory[\'shirt_size\'].\"\" target=\"_self\">Buy One</a>\" ?></td> </tr> <?php } while ($row_inventory = mysql_fetch_assoc($inventory)); ?> Has anyone seen something like this before? I am running Apache 1.3.23 and PHP4. Thanks in advance. Damo Quote Link to comment Share on other sites More sharing options...
barbatruc Posted May 7, 2003 Share Posted May 7, 2003 What is the browser you\'re using ? In which OS ? Sometimes, you may have troubles with empty <td></td> and this might be why you get strange result like this. To avoid this you may try to do, for each <td> statement: <td><?php echo (!empty($row[\'indextodisplay\']) ? $row[\'indextodisplay\'] : "& nbsp;"); ?></td> Note: there is no \" \" between the \"&\" and \"nbsp;\", PHPbb sucks at displaying it when there is no \" \" between them. JP. 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.