Jump to content

Show Records by Group


rscott7706

Recommended Posts

Hey all, hope all is well....

I have a non-profit site that has business categories for their members (Accommodations, Advertising
Agriculture & Livestock, Antiques, Crafts &Collectibles , etc.).


I want to display records by category - but only that category.  For instance I want to display all records for Accommodations alone then after some html coding (links to the category and "top of page") start a new section that does the next category - Advertising.

Here is my coding that groups by Directory_Catagory, but lists all the records.  Can we list only records by a certian category?

$db = mysql_connect("localhost", "", "");
mysql_select_db("lakeside_chamber");
$query = "SELECT * FROM members GROUP by Directory_Catagory";

$result = mysql_query($query) or die(mysql_error());
echo "<font face=\"arial\">";
while($row = mysql_fetch_array($result)){
    echo $row['Company_Name'];
    echo "<br />";
    echo $row['Directory_Catagory'];
    echo "<br />";
    echo $row['First_Name']. " " . $row['Last_Name'];
    echo "<br />";
    echo $row['Address']. " " . $row[''];
    echo $row['City']. ", " . $row['State']. " " . $row['Zip_Code'];
    echo "<br />";
    echo $row['Phone_Number'];
    echo "<br />";
    echo "<a href=mailto:'$row[Web_Email]'>".$row['Web_Email']."</a>";
    echo "<br />";
    echo "<a href='$row[Web_Site_Address]'>".$row[Web_Site_Address]."</a>";
    echo "<br />";
    echo "<br />";

Thanks in advance!!

Link to comment
https://forums.phpfreaks.com/topic/27891-show-records-by-group/
Share on other sites

I got it - sorry to jump for help too soon.  it is simple - here is the statement (gives you "Advertising"):

$query = "SELECT * FROM members WHERE Directory_Catagory = 'Advertising' ORDER by Directory_Catagory";

I am not sure the ORDER by stament is still necessary, but left it in.
Link to comment
https://forums.phpfreaks.com/topic/27891-show-records-by-group/#findComment-127546
Share on other sites

Archived

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

×
×
  • 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.