Putting data from a mysql database on the next page

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
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:
$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.

:)
 
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:
$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:
<?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:
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
;)
 
Back
Top