[PHP] Multiple MySQL Tables -- HTML Tables
Hi all, I have a newbie question, I hope somebody can help me out. I have an HTML form (query.html) that has a drop down menu of all 50 states and 3 checkboxes of 3 years (1999, 2000 and 2001), I want users to be able to select one state and any year(s) they want (they can choose one or more years). I have a MySQL DB that has 3 tables, each table has data for one year (i.e. states99, states00 and states01). I want to be able to have the results.php script connect to the database, make a query from multiple tables and display it to an HTML table, for example: State | 1999 | 2000 |orState | 1999 | 2001 -- AL|23,010|12,567| . . . Thank you for your time. Mouncef -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Multiple MySQL Tables -- HTML Tables
?php $res = mysql_query(SELECT sd.state_name,s99.count,s00.count,s01.count FROM states_data sd LEFT JOIN states99 s99 USING(state_id) LEFT JOIN states00 s00 USING(state_id) LEFT JOIN states01 s01 USING(state_id) ); while($ar=mysql_fetch_assoc($res)){//look at PHP docs to see if mysql_fetch_assoc is there in your PHP foreach ($ar as $k = $v){ $str.=sprintf('|%20s',$v).; } echo $str.br\n } ? Hope this make a little help. Andrey Hristov IcyGEN Corporation http://www.icygen.com 99% - Original Message - From: Mouncef Belcaid [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, August 27, 2001 7:08 PM Subject: [PHP] Multiple MySQL Tables -- HTML Tables Hi all, I have a newbie question, I hope somebody can help me out. I have an HTML form (query.html) that has a drop down menu of all 50 states and 3 checkboxes of 3 years (1999, 2000 and 2001), I want users to be able to select one state and any year(s) they want (they can choose one or more years). I have a MySQL DB that has 3 tables, each table has data for one year (i.e. states99, states00 and states01). I want to be able to have the results.php script connect to the database, make a query from multiple tables and display it to an HTML table, for example: State | 1999 | 2000 |orState | 1999 | 2001 -- AL|23,010|12,567| . . . Thank you for your time. Mouncef -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Multiple MySQL Tables -- HTML Tables
Don't forget to mysql_free_result($res) after the while, if you have other PHP statements before the end of the script. Andrey Hristov IcyGEN Corporation http://www.icygen.com 99% - Original Message - From: Mouncef Belcaid [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, August 27, 2001 7:08 PM Subject: [PHP] Multiple MySQL Tables -- HTML Tables Hi all, I have a newbie question, I hope somebody can help me out. I have an HTML form (query.html) that has a drop down menu of all 50 states and 3 checkboxes of 3 years (1999, 2000 and 2001), I want users to be able to select one state and any year(s) they want (they can choose one or more years). I have a MySQL DB that has 3 tables, each table has data for one year (i.e. states99, states00 and states01). I want to be able to have the results.php script connect to the database, make a query from multiple tables and display it to an HTML table, for example: State | 1999 | 2000 |orState | 1999 | 2001 -- AL|23,010|12,567| . . . Thank you for your time. Mouncef -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]