Jump to content


Photo

problem displaying data...


  • Please log in to reply
1 reply to this topic

#1 damianharvey

damianharvey
  • New Members
  • Pip
  • Newbie
  • 1 posts
  • LocationSydney, Australia

Posted 07 May 2003 - 06:18 AM

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.big...rvey/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

#2 barbatruc

barbatruc
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationMontreal, Quebec, Canada

Posted 07 May 2003 - 05:36 PM

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.
Unfortunately, PHP \'empowered every moron with a copy of Windows notepad to be \"web programmers\". (...) Give PHP a real INFRASTRUCTURE. Use PEAR!!!\'




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users