PDA

View Full Version : A MySQL doubt



AndreVR
March 6th, 2002, 21:18
Sorry, I'm a newbie programming in PHP/MySQL....

I have a table, with two columns called "id" and "nick"
i'd like to make my PHP page to get all "nick" values and show them, and I'd like each one linking with <a href="www.hostingservice.com/phpscript?id=x>, where 'X' is the id correspondent stored in the MySQL table.

I have two questions:
1 - What SQL query should I do? (SELECT nick, id FROM $table)?:confused:

2 - After the query, what code, should I write for the PHP page showing this correctly? :confused:

Thanks.... ;)

megapuzik
March 7th, 2002, 04:32
Well...
the query for selecting the NICK is this :


$query = "SELECT nick FROM table_name";
$result = mysql_query($query, $connection_link);

To show your results try this :


$show_query = "SELECT * FROM table_name";
$handler = mysql_query($show_query, $connection_link);
while(mysql_fetch_array($handler))
{
print " <a href=\"www.hostingservice.com/phpscript?id=$handler[id]\">$handler[nick]</a>";
}


good luck.