Lamez Posted October 1, 2008 Share Posted October 1, 2008 Ok, so I have a DB filled with tables named after the football conference's, and I want to take all 12 conference's I have, and take the teams in the table and make one giant list, alphabetized. Well, the code I posted below does not work, I get something like this: "Resource id #26Resource id #27Resource id #28Resource id #29Resource id #30Resource id #31Resource id #32Resource id #33Resource id #34Resource id #35Resource id #36" and here is my code, <?php $path = ""; $title = "Test"; $rank = "yes"; //$login = "yes"; $admin = "yes"; include ($path."main/include/cons/head.php"); $a = mysql_query("SELECT * FROM `Atlantic Coast Conference`"); $b = mysql_query("SELECT * FROM `Big 12`"); $c = mysql_query("SELECT * FROM `Big East`"); $d = mysql_query("SELECT * FROM `Big 10`"); $e = mysql_query("SELECT * FROM `Conference USA`"); $f = mysql_query("SELECT * FROM `Independents`"); $g = mysql_query("SELECT * FROM `Mid-American`"); $h = mysql_query("SELECT * FROM `Mountain West`"); $i = mysql_query("SELECT * FROM `Pac 10`"); $j = mysql_query("SELECT * FROM `SEC`"); $k = mysql_query("SELECT * FROM `Sun Belt`"); $l = mysql_query("SELECT * FROM `WAC`"); $all = $a.$b.$c.$d.$e.$f.$g.$h.$i.$j.$k.$l; echo $all; include ($path."main/include/cons/foot.php"); ?> Thanks guys! Quote Link to comment Share on other sites More sharing options...
hawkenterprises Posted October 1, 2008 Share Posted October 1, 2008 it's because after using mysql_query you need to use something else to fetch the data from the result. $line = mysql_fetch_array($result) will achieve this as well as many other ways Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 1, 2008 Author Share Posted October 1, 2008 oh gosh, brain fart. I knew that Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 1, 2008 Share Posted October 1, 2008 All I can say is WTF?! First, there should NOT be separate tables for each conference. There should be a table which lists the conferences then one table for all "teams" which holds specific, one-to-one data for the teams and each team would have a foreign key to the conferences table. However, if you decide not to do it the right way, you should be able to get the results you want using UNION. Althugh I'm not 100% sure you can use a sort on a UNION. <?php $path = ""; $title = "Test"; $rank = "yes"; //$login = "yes"; $admin = "yes"; include ($path."main/include/cons/head.php"); $query = "SELECT * FROM `Atlantic Coast Conference` UNION SELECT * FROM `Big 12` UNION SELECT * FROM `Big East` UNION SELECT * FROM `Big 10` UNION SELECT * FROM `Conference USA` UNION SELECT * FROM `Independents` UNION SELECT * FROM `Mid-American` UNION SELECT * FROM `Mountain West` UNION SELECT * FROM `Pac 10` UNION SELECT * FROM `SEC` UNION SELECT * FROM `Sun Belt` UNION SELECT * FROM `WAC` ORDER BY team_name"; $result = mysql_query($query) or die (mysql_error()); while ($record=mysql_fetch_assoc($result)) { echo implode(' - ', $record) . "<br>\n"; } include ($path."main/include/cons/foot.php"); ?> Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 1, 2008 Author Share Posted October 1, 2008 Thank you for that bit of code, and there is not a right way, just a more efficient way. Just because you prefer it that way, does not mean it is the so called, right way. Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 1, 2008 Share Posted October 1, 2008 ... there is not a right way, just a more efficient way. Hmm... wouldn't a more efficient way be the right way? Do some research on Database Normalization (thousands of references out there) and learn what is meant be a relational database. Without using the "related" functionality within a database you are left with nothing more than glorified spreadsheets. Quote Link to comment Share on other sites More sharing options...
hawkenterprises Posted October 1, 2008 Share Posted October 1, 2008 mjdamato, you must be one of the freaks here.... I don't know about you but I didn't come into this world knowing everything and doing everything perfect. Perhaps your birth was virginal as well? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.