gigido Posted March 14, 2008 Share Posted March 14, 2008 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. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted March 14, 2008 Share Posted March 14, 2008 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> Quote Link to comment Share on other sites More sharing options...
gigido Posted March 14, 2008 Author Share Posted March 14, 2008 um, not sure if that work for what im doing.. i just gave it a shoot and doesnt seem to fit my situation. Any other ways of doing this that you can suggest? thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.