Jump to content

[SOLVED] Mulriple Mysql Queries


leest

Recommended Posts

Hi,

 

Just a little question really, I have a query which draws information from a table, i want to take two of the results from the table and run two more queries.  Now i can do this simply enough if i just wanted display one set of results, however i wanted to paginate the script and get multiple results but really not sure how to go about it, as i can not seem to run more than one query within the pagination.  Any advce or a good kick in the right direction would be much appreciated.

 

Thanks

Link to comment
Share on other sites

HI,

 

Thanks ok below is a basic layout of what i am trying to do, this isn't my actual script but i can get the results that i want from this.  What i want to do now is to find away to paginate the results or two run the queries differntly.

 


include '../folder/folder/db1.php';

$result_1 = $row['result_1'];
// Make a MySQL Connection
$query = "SELECT * FROM Table WHERE Result_1 ='$result_1'  "; 

$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());

$answer_1 = $row['answer_1'];
$answer_2 = $row['answer_2'];
$answer_3 = $row['answer_3'];
}

$query = "SELECT * FROM Table2 WHERE answer_2 ='$answer_2'  "; 

$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());

$answer_4 = $row['answer_4'];
}

$query = "SELECT * FROM Table3 WHERE answer_3 ='$answer_3'  "; 

$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());

$answer_5 = $row['answer_5'];

echo $row['answer_1'];
echo $row['answer_4'];
echo $row['answer_5'];
}

Link to comment
Share on other sites

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.