I am working to build a list of store locations for a given city & state. I'm able to list out all of the locations separately, and I'm able to create a "box" for each location, but I'd like to group all of the store locations together, so you can easily see all of the locations in the same line and "box". In the database each store location is listed in a separate row. Can I do what I want to do using this current database configuration?
I'm new to SQL & PHP - so please explain your solution. 🙂
Thank you so much!
Example:
List of Stores In Washington
Store Name: Big Box Store ABC
Store Locations: Seattle, Olympia, Northgate, Spokane
Store Website: www.mystore.com
(in future versions i'd like to have the store location name be a link to that locations' website)
Here is another live example (only for colleges) that matches what I am trying to do. You'll see that the campus locations for a given school are listed in the same "box" for each school. If a school has more than one location in a given state, all locations will be listed.
http://www.allculinaryschools.com/culinary-degree/all-degrees/culinary-arts/california?search=ca
Here's what I have so far.
<?php
mysql_select_db("$db_name", $con);
$sql = 'SELECT * FROM allstores
WHERE state_long = "'.$pickstate.'"
ORDER BY storename ';
$result1 = mysql_query($sql);
// Flag variable to track success:
$okay = TRUE;
while($row = mysql_fetch_array($result))
print "<div class ='store-box'>
<p><img class='storelogo' src='img/logos/".$row['logoid'] .".jpg' alt='". $row['storename'] ."' />
<span class='storename'>" . $row['storename'] . "</span>
<br />
<strong>Store Locations: </strong>" . $row['store-location'] . "
<br />
<strong>Store Website: </strong>" . $row['store_url'] . "
</p>
</div>";
mysql_close($con);
?>