Jump to content

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

Link to comment
https://forums.phpfreaks.com/topic/440-problem-displaying-data/
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.

Link to comment
https://forums.phpfreaks.com/topic/440-problem-displaying-data/#findComment-1491
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.