mysql data submenu

Hi, i would like to use the result from a mysql query as input for further information but don’t know how.

[php]

<? $username="root"; $password="11"; $database="res"; mysql_connect('127.0.0.1',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM restest"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <? $i=0; while ($i < $num) { $resa=mysql_result($result,$i,"resa"); $resb=mysql_result($result,$i,"resb"); $resc=mysql_result($result,$i,"resc"); ?>
resa is:
<? echo $resa; ?>
resb is:
<? echo $resb; ?>
<? $i++; } echo "
resc is:
<? echo $resc; ?>
"; [/php] the results are links, and when i click such a link, i would like information about only that row from the database. so somehow the next page should do something like [php] $query="SELECT * FROM test WHERE id='17'"; [/php] where id is a variable based on what i clicked the previous page. i hope someone can help me with this.

The function here:

[php]$num=mysql_numrows($result);[/php]

Should be mysql_num_rows. You also close the connection with mysql_close before you get some of the results from the query. I would try moving mysql_close to after:

[php]<?
$i++;
}

echo “”;[/php]

the part of the code i pasted in the first post works fine.

what i need though, is that when for example i click the second link, ‘resb’, it will open a new page, ‘showdetails1.php’, and in that page it should give the options

resb-1
resb-2
resb-3

and not

resa-1
resa-2
resa-3
resb-1
resb-2
resb-3
resc-1
resc-2
resc-3

as it is currently doing.

so i somehow need the showdetails1.php page to start with

$query="SELECT * FROM test WHERE id='2'";

instead of just

$query="SELECT * FROM test ";

where the id=part is generated by what is clicked in the previous page, resa, resb or resc.

lets say
resa
resb
resc

person1
person2
person3

and when i click
person2,
i want only the adress, postalcode and phonenumber from person2, and not from person 1,2 and 3.

Sponsor our Newsletter | Privacy Policy | Terms of Service