Jump to content

help passing along a VARIABLE from page to page


gigido

Recommended Posts

Hi,

i have an html page that is displaying the results of my query from a .php file. the results are displayed on the html page as

 

while ($row = mysql_fetch_array($result)) {

echo $row['title'].";

}

 

 

 

My question is if i were to pass along that data to another php page thats linked from this current html page, how would i pass the variable on? I tried doing a

$titleresults = $row['title']  but that doesnt seem to work.

 

 

any direction on how to do this would be appreciated.

 

thanks.

What about having the results on a separate page and then just including it on whatever page you want.

 

table_data.php

<?php
// connect to database
$sql = "SELECT * FROM `table`";
$result = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($result)
if ($num_rows > 0)
{
$count = 0;
while ($row = mysql_fetch_array($result)
{
	$count++;
	echo ($count != $num_rows) ? "{$row['title']}, " : "{$row['title']}";
}
}
// close database connection
?>

 

index.php

<html>
<body>
<h1>Hello World!</h1>
<p><?php include('table_data.php'); ?></p>
</body>
</html>

 

another_page.php

<html>
<body>
<h1>Goodbye World!</h1>
<p><?php include('table_data.php'); ?></p>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.