I'm trying to pull information in from three or four seperate tables into one query. I have a table called store which holds id, store_name_id, store_address_id and groups. the store_location table holds the id, address, city, store_state_id, zip and phone. the store_name table hold th id and store_name. the store_state table holds id and state. groups is something else it points to a table that references product groups offered at the various retail locations.
anyway my problem is doing a select statement that will get me the information and do it like that
Store Name
address - city - state - zip - phone - group name
x the number of entries for that store name.
here is my fourth attempt at this query
$sql = "SELECT store_name.name as name, store_location.address as address, store_location.city as city, store_state.state as state, store_location.zip as zip, store_location.phone as phone, store.id FROM store, store_name, store_location, store_state WHERE (store.store_name_id=store_name.id) AND (store.store_address_id==store_location.id) AND (store_location.store_state=store_state.id)";
$result = mysql_query($sql);
$counter = 0;
while ($retail_store = mysql_fetch_array($result) ) {
if ($counter % 2 == 0) {
$retail_store_output .= "<TR><TD BGCOLOR=\"#F7F7F7\" WIDTH=\"60%\"><FONT FACE=\"Verdana, Arial, Tahoma\" SIZE=\"2\" COLOR=\"#000000\">".$retail_store["name"]." - ".$retail_store["address"]." - ".$retail_store["city"]." - ".$retail_store["state"]." - ".$retail_store["zip"]." - ".$retail_store["phone"]."</FONT></TD>";
$retail_store_output .= "<TD BGCOLOR=\"#F7F7F7\" WIDTH=\"40%\"><FONT FACE=\"Verdana, Arial, Tahoma\" SIZE=\"1\" COLOR=\"#000000\">Would you like to <a href=\"index.php?area=retail&type=rsnedit&id=".$retail_store_name["id"]."\">Edit</a> or <a href=\"index.php?area=retail&type=rsndelete&id=".$retail_store_name["id"]."\">Delete</a></FONT></TD></tr>";
} else {
$retail_store_output .= "<TR><TD BGCOLOR=\"#F7F7F7\" WIDTH=\"60%\"><FONT FACE=\"Verdana, Arial, Tahoma\" SIZE=\"2\" COLOR=\"#000000\">".$retail_store["name"]." - ".$retail_store["address"]." - ".$retail_store["city"]." - ".$retail_store["state"]." - ".$retail_store["zip"]." - ".$retail_store["phone"]."</FONT></TD>";
$retail_store_output .= "<TD BGCOLOR=\"#DDDDDD\" WIDTH=\"40%\"><FONT FACE=\"Verdana, Arial, Tahoma\" SIZE=\"1\" COLOR=\"#000000\">Would you like to <a href=\"index.php?area=retail&type=rsnedit&id=".$retail_store_name["id"]."\">Edit</a> or <a href=\"index.php?area=retail&type=rsndelete&id=".$retail_store_name["id"]."\">Delete</a></FONT></TD></tr>";
}
$counter++;
}
$retail_store_output .= "<TR><TD BGCOLOR=\"#F7F7F7\" WIDTH=\"20%\"></TD><TD BGCOLOR=\"#F7F7F7\" WIDTH=\"80%\"><FONT FACE=\"Verdana, Arial, Tahoma\" SIZE=\"2\" COLOR=\"#000000\"><a href=".$PHP_SELF."?area=retail&type=rsnadd>Add</a> New Retail Store?</FONT></TD></tr>";
mysql_close();
I know I am missing something and I have looked at it several times my mind is starting to gloss over, can someone help ..thanks
dan