back2black
Junior Member
- Dec 20, 2008
- 118
- 29
Hi All,
I have a mysql table with three fields:
1) Category
2) Title
3) Sub Category
4) Price
Basically, I have a php page called categories.php with a table on it, and a URL field called cat
So to get there, for example you would go via:
categories.php?cat=Mixers
categories.php?cat=Headphone
categories.php?cat=Racks etc. etc....
On this page I want to display all the records in the category URL cat. So if for example someone came to the page from ?cat=Mixers I want to display all the records in the table where Category is Mixers.
So how would I actually do this?
So far I have this code:
But this displays all the fields in each cell, but doesnt add rows.
Anyone know how to add rows for each record?
Thanks very much for all your help
I have a mysql table with three fields:
1) Category
2) Title
3) Sub Category
4) Price
Basically, I have a php page called categories.php with a table on it, and a URL field called cat
So to get there, for example you would go via:
categories.php?cat=Mixers
categories.php?cat=Headphone
categories.php?cat=Racks etc. etc....
On this page I want to display all the records in the category URL cat. So if for example someone came to the page from ?cat=Mixers I want to display all the records in the table where Category is Mixers.
So how would I actually do this?
So far I have this code:
Code:
<table width="700" border="1">
<tr>
<td width="193">Title</td>
<td width="397">Sub Category</td>
<td width="88">Price</td>
</tr>
<tr>
<td>
<?php
$catresult=$_GET['cat'];
$result = mysql_query("SELECT * FROM tbprofo WHERE category='$catresult'");
while($row = mysql_fetch_array($result))
{
echo $row['title'];
}
?>
</td>
<td>
<?php
$catresult=$_GET['cat'];
$result = mysql_query("SELECT * FROM tbprofo WHERE category='$catresult'");
while($row = mysql_fetch_array($result))
{
echo $row['sub'];
}
?>
</td>
<td>
<?php
$catresult=$_GET['cat'];
$result = mysql_query("SELECT * FROM tbprofo WHERE category='$catresult'");
while($row = mysql_fetch_array($result))
{
echo $row['price'];
}
?>
</td>
</tr>
</table>
But this displays all the fields in each cell, but doesnt add rows.
Anyone know how to add rows for each record?
Thanks very much for all your help