Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

db return results problem

Status
Not open for further replies.

dessie1981

Programmer
May 9, 2006
116
GB
Hi Everyone,

I am having a problem formating results from my mysql db,
I have a db of products, this includes a manufacturer column.

I would like to list the products under a manufacturer heading
. I can return the manufacturer headings but am having problem inputting the results under each manufacturer heading.

below is the code that prints the start of each table, which includes the manufacturer header.


/////this is creating an anchor of the manu's

while ($manu_row = mysql_fetch_array($manu_result))
{

echo '<a href="#' . $manu_row[0] . '"> ' . $manu_row[0] . '</a>';
}

echo '<table width="95%" border="0" align="center" cellpadding="5" cellspacing="5" summary="">
<tr>';


$manu_result2 = @mysql_query($manu_sql);

///enter loop and create manu header

while ($manu_row = mysql_fetch_array($manu_result2))
{
?>

<td colspan="6" class="product-header"><?echo $manu_row[0];?></td>
</tr>
<tr>
<td class="column-header">Part No.</td>
<td class="column-header">Description</td>
<td class="column-header">Manufacturer</td>
<td width="80" class="column-header"><div align="right">Price (&#8364;)</div></td>
<td width="80" class="column-header"><div align="right">Stock Qty</div></td>
<td width="90" class="column-header"><div align="right">Add To Cart</div></td>
</tr>
<?

}

Here is the sql that i need to include within the above loop somehow

$sql = "select * from products where part_no like '$partno%'";

I prob need to add some kind of array onto the end of this statement in order for it to step through the manufacturers.

If anyone can make sense of this, fair play to you.

Regards
Dessie
 
I prob said the worong word there "formating" i mean the format of the output of my results.

Regards
Dessie
 
You want to filter the resuts from the DB by part_no. That means every result you get will have the same part number.

You have to find the place where you call
mysql_query(...) and place the sql before it.
like:

Code:
$sql = "select * from products where part_no like '$partno%'";
[blue]$manu_result[/blue]=mysql_query([red]$sql[/red]);

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top