# 2 separate $results from mySQL query in 1 file

**URL:** <https://forum.kirupa.com/t/2-separate-results-from-mysql-query-in-1-file/207189>\
**Category:** programming\
**Created:** [November 15, 2006, 1:31pm UTC](https://forum.kirupa.com/t/2-separate-results-from-mysql-query-in-1-file/207189 "2006-11-15T13:31:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@jacob](https://forum.kirupa.com/u/jacob)\
**Post date:** [November 15, 2006, 1:31pm UTC](https://forum.kirupa.com/t/2-separate-results-from-mysql-query-in-1-file/207189/1 "2006-11-15T13:31:06Z")

</div>

I am making a php page, which will have content that changes based on the selected menu item.

so far, i have the menu itself loading correctly:

\<?  
$i=0;  
while ($i \< $num) {

$menuname=mysql\_result($result,$i,“menuname”);  
echo “\<a href=‘redir.php?menuname=$menuname’\>$menuname\</a\>” ?\>\</p\>\</b\>\</td\>

\<?  
++$i;  
}

the file called redir.php does not yet exist. I was thinking it would be a separate php file which determines the content that should be echoed into THIS php doc.

OR

I could have the hyperlink in the menu simply return the selection to this same index file.  
and have the content pulled from the relevant row in the table.

As in:

$selection=$\_GET[‘menuname’];  
include(‘inc.config.php’);  
mysql\_connect($dbhost, $dbuser, $dbpasswd);  
@mysql\_select\_db($dbname) or die( “Unable to select database”);  
$query=“SELECT \* FROM `Gallery` WHERE menuname=’$selection’”;

$result=mysql\_query($query);  
$num=mysql\_numrows($result);

$i=0;  
while ($i \< $num) {  
$menuname=mysql\_result($result,$i,“menuname”);  
$name=mysql\_result($result,$i,“name”);  
$description=mysql\_result($result,$i,“description”);  
$urlcopy=mysql\_result($result,$i,“urlcopy”);  
$url=mysql\_result($result,$i,“url”);  
$location=mysql\_result($result,$i,“location”);

This second method seems to be a lot simpler, but also more complicated.  
My question is this: how can i have these 2 separate $results in the same file?  
How can i have 2 different queries to the mySQL db without causing total insanity?

thanks for whatever help you can give!
