Putting data from a mysql database on the next page

Codes here !

Moderators: macek, egami, gesf

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Thu Nov 21, 2002 5:06 am

First off you have to collect the passed http variables with this, (it doesn't matter if the vars come from a mysql query, from a form or whatever):

Code: Select all

$i=0;
while(list($key, $value) = each($HTTP_GET_VARS)){
   $var[$i]=$value; //save the value of the variable in an array
   $i++;   
}

Now you can access the array with $var[0], $var[1], $var[2]....... up to as many vars as you declared on the previous page.

:)

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Fri Nov 22, 2002 12:28 pm

Ok, regarding your mail I think I can tell you what was wrong :)
the var $result contains the data to connect to you mysql server.

Code: Select all

$result = mysql_query($sql,$db);


If you want to send a piece (or as much as you want) of data to the other page you have to keep the information in variables.
An example -->
This would output a list of links with the different data.

Code: Select all

<?php
$sql="SELECT * FROM ".$table." ORDER BY id";
$result=mysql_query($sql,$db);
while ($row=mysql_fetch_array($result)){
   echo "<a href='my_page.php?the_id=".$row["id"]."&the_name=".$row["name"]."'>send this data: <b>".$row["id"]."</b> and <b>".$row["name"]."</b> to the next page</a><br>";
}
?>


Then, in the other page my_page.php, you can use the passed vars.
An example -->

Code: Select all

while(list($key, $value) = each($HTTP_GET_VARS)){
echo $key." = ".$value."<br>";
}


If you need more help just post back
I hope It's been useful
;)


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest