leest Posted December 18, 2007 Share Posted December 18, 2007 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 https://forums.phpfreaks.com/topic/82230-solved-mulriple-mysql-queries/ Share on other sites More sharing options...
roopurt18 Posted December 18, 2007 Share Posted December 18, 2007 Your description is not very clear. Could you perhaps provide an example? The example doesn't have to match your program exactly, but it should be analogous. Link to comment https://forums.phpfreaks.com/topic/82230-solved-mulriple-mysql-queries/#findComment-417897 Share on other sites More sharing options...
leest Posted December 18, 2007 Author Share Posted December 18, 2007 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 https://forums.phpfreaks.com/topic/82230-solved-mulriple-mysql-queries/#findComment-417908 Share on other sites More sharing options...
roopurt18 Posted December 18, 2007 Share Posted December 18, 2007 How about a query like: SELECT * FROM `table1` t1 INNER JOIN `table2` t2 ON t1.`answer_2`=t2.`answer_2` INNER JOIN `table3` t3 ON t1.`answer_3`=t3.`answer_3` And then you can add the appropriate LIMIT clause for your pagination? Link to comment https://forums.phpfreaks.com/topic/82230-solved-mulriple-mysql-queries/#findComment-417918 Share on other sites More sharing options...
leest Posted December 18, 2007 Author Share Posted December 18, 2007 Cool Thanks, i'll give it ago, I didn't think about joining tables just guess thats my in experience, thank you Link to comment https://forums.phpfreaks.com/topic/82230-solved-mulriple-mysql-queries/#findComment-417924 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.