fontener Posted February 20, 2010 Share Posted February 20, 2010 Hi all, I need some help as I am new to PHP ... I am trying to display a table of data from a query of multiple tables. Anyway, let's say I have a table called "radiostations".. and within that table is a "formatID" ... this "formatID" is also shared with a table called "formats" which corresponds to a given "format" .. I dont want to limit my query to only that format... but when i display the results, instead of showing the "formatID" I want to show the corresponding "format". You're probably going ... but any help would be appreciated. I have attached a picture for visual help. In other words, right now I am querying table "radiostations" to display all 'radiostations' and corresponding info and setting variables for "call_letters, formatID"... etc. but i dont want to display the formatID, rather it's relational value... [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/192752-multiple-table-queries/ Share on other sites More sharing options...
jl5501 Posted February 20, 2010 Share Posted February 20, 2010 select r.stationID,r.call_letters,f.format from radiostation r,format f where r.formatID = f.formatID Link to comment https://forums.phpfreaks.com/topic/192752-multiple-table-queries/#findComment-1015377 Share on other sites More sharing options...
fontener Posted February 20, 2010 Author Share Posted February 20, 2010 select r.stationID,r.call_letters,f.format from radiostation r,format f where r.formatID = f.formatID Thank you very much, friend! Muchos Gracias Amigo Спасибо, друг Link to comment https://forums.phpfreaks.com/topic/192752-multiple-table-queries/#findComment-1015387 Share on other sites More sharing options...
fontener Posted February 20, 2010 Author Share Posted February 20, 2010 Ok, I'm only getting one row to show with said method... any ideas? here's the full code <?php $color1 = "#CCFFCC"; $color2 = "#CEC5A6"; $result =mysql_query( "select r.*,f.format,m.md_name, p.city, p.state_province from station r,format f,md m, postal p where r.format_id = f.format_id and r.md_id = m.md_id and r.postal_id = p.postal_id"); if (!$result) { echo("<p>Error performing query: " . mysql_error() . "</p>"); exit(); } while ($row = mysql_fetch_array($result)) { $callabcs = $row["call_letters"]; $station = $row["station_name"]; $link = $row["station_website"]; $phone = $row["station_phone"]; $md = $row["md_name"]; $pd = $row["pd_name"]; $format = $row["format"]; $level = $row["level"]; $city = $row["city"]; $local = $row["state_province"]; $notes = $row["additional_notes"]; } ?> <table cellpadding="0" cellspacing="0" cellpadding="0" border="0" class="megatable"><tr><th>Call Letters</th><th>Station ID</th><th>Phone</th><th>MD</th><th>PD</th><th>Format</th><th>Level</th><th>City</th><th>Province</th><th>Notes</th></tr> <?php $row_count = 0; $row_color = ($row_count % 2) ? $color1 : $color2; echo "<tr><td bgcolor=\"$row_color\" id=\"hundo\">$callabcs</td><td bgcolor=\"$row_color\" id=\"hundo\"><a href=\"$link\">$station</a></td><td bgcolor=\"$row_color\" id=\"hundo\">$phone</td><td bgcolor=\"$row_color\" id=\"hundo\">$md</td><td bgcolor=\"$row_color\" id=\"hundo\">$pd</td><td bgcolor=\"$row_color\" id=\"hundo\">$format</td><td bgcolor=\"$row_color\" id=\"level\">$level</td><td bgcolor=\"$row_color\" id=\"hundo\">$city</td><td bgcolor=\"$row_color\" id=\"hundo\">$local</td><td bgcolor=\"$row_color\" id=\"hundofity\">$notes</td></tr>"; $row_count++; ?> </table> Link to comment https://forums.phpfreaks.com/topic/192752-multiple-table-queries/#findComment-1015421 Share on other sites More sharing options...
jl5501 Posted February 20, 2010 Share Posted February 20, 2010 that would imply that you only have one record that meets all the where conditions Link to comment https://forums.phpfreaks.com/topic/192752-multiple-table-queries/#findComment-1015424 Share on other sites More sharing options...
fontener Posted February 20, 2010 Author Share Posted February 20, 2010 Oh, well I want to display all of the stations... i only wanted the information rather than the id displayed for each.. if you can still help, that'd be great! Link to comment https://forums.phpfreaks.com/topic/192752-multiple-table-queries/#findComment-1015428 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.