Jump to content

Archived

This topic is now archived and is closed to further replies.

damianharvey

problem displaying data...

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.