affordit Posted February 2, 2008 Share Posted February 2, 2008 I have a query that accesses a products table and I have more than one products table. What I need to know is can I run a query and store the results in an array and run the query and stor those results in a different array and extract them at will and place them in there proper places on the page? Thanks in advance for any suggestions. This is what I am using now <?php $mynumber=rand(1, 5); include("sharons_dbinfo.inc.php"); mysql_connect(mysql,$username,$password); mysql_select_db(mydatabase) or die( "Unable to select database"); $query_content= "SELECT `heading`, `picture`, `description` FROM `content` WHERE `item` = '$mynumber'"; $result=mysql_query($query_content) or die(mysql_error()); $arr = mysql_fetch_assoc($result); extract($arr); print "<table width='200' align='right'><tr><td>$heading"; echo "<br />"; echo $picture; echo "<br />"; echo $description; print "</TD></tr></table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/89114-solved-is-it-possible-to-run-multiple-queries-on-one-page/ Share on other sites More sharing options...
Stooney Posted February 2, 2008 Share Posted February 2, 2008 You can run all the queries you want on a single page. Quote Link to comment https://forums.phpfreaks.com/topic/89114-solved-is-it-possible-to-run-multiple-queries-on-one-page/#findComment-456395 Share on other sites More sharing options...
pocobueno1388 Posted February 2, 2008 Share Posted February 2, 2008 Yes, you would just do another query. You MAY be able to combine everything you want into one query and get the same results. How are the tables in your database setup? So give a detailed description of your tables, then tell us exactly what your wanting to select. Quote Link to comment https://forums.phpfreaks.com/topic/89114-solved-is-it-possible-to-run-multiple-queries-on-one-page/#findComment-456396 Share on other sites More sharing options...
affordit Posted February 2, 2008 Author Share Posted February 2, 2008 OK what I have is 1 table to start with and it currently cotains 4 fields item set to auto inc, heading=full text, picture=full text, description=full text. What I want to do is add more tables and eventually be able to query all the tables i need to based on the link clicked and assemble a page of ads. In short I would like to be able to query all the tables that pertain to what they are interested in. Quote Link to comment https://forums.phpfreaks.com/topic/89114-solved-is-it-possible-to-run-multiple-queries-on-one-page/#findComment-456403 Share on other sites More sharing options...
pocobueno1388 Posted February 2, 2008 Share Posted February 2, 2008 Your going to have to give us details from a second table for us to help you link them. If you do that, make sure you tell us exactly what your wanting to select and do. Quote Link to comment https://forums.phpfreaks.com/topic/89114-solved-is-it-possible-to-run-multiple-queries-on-one-page/#findComment-456404 Share on other sites More sharing options...
affordit Posted February 3, 2008 Author Share Posted February 3, 2008 All the tables will be basiccally the same except that the will contain different types of product like automotive and shoes toys and the like. They will all contain the same fields just different type of products. I think I might have to assign them all a "product code" to relate them but im not sure how to do that. Quote Link to comment https://forums.phpfreaks.com/topic/89114-solved-is-it-possible-to-run-multiple-queries-on-one-page/#findComment-456410 Share on other sites More sharing options...
pocobueno1388 Posted February 3, 2008 Share Posted February 3, 2008 Maybe instead of making a separate table for EVERY category, you can just add a field called "category" to your table and put ALL the items in it. So your fields would be auto heading picture description category And for category you can put "Toy", "Tool", "Garden", or whatever. That way it will be easy to sort out and grab exactly what you want. Quote Link to comment https://forums.phpfreaks.com/topic/89114-solved-is-it-possible-to-run-multiple-queries-on-one-page/#findComment-456412 Share on other sites More sharing options...
affordit Posted February 3, 2008 Author Share Posted February 3, 2008 Sorry had to ahovel alot of snow. Yes that makes more sense thanks then the queries could be set where categories = X Now how would I set up the multiple queries to sort into diff. arrays? Quote Link to comment https://forums.phpfreaks.com/topic/89114-solved-is-it-possible-to-run-multiple-queries-on-one-page/#findComment-456483 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.