Jump to content

[SOLVED] Is it possible to run multiple queries on one page


Recommended Posts

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>";

?>

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.

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.

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.