PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dwsddas
Forum Newbie
Posts: 8 Joined: Tue Dec 22, 2009 4:44 am
Post
by dwsddas » Tue Dec 22, 2009 5:02 am
Hi,
I have many php variables on my web page as links to another page, they display data from MySQL. I want one of this variable to be displayed on another page when I click on it. Please help how to do it.
Code: Select all
<?php
error_reporting(E_ALL ^ E_NOTICE);
mysql_connect("localhost","root") or die(mysql_error());
mysql_select_db("tttt") or die(mysql_error());
$query=mysql_query("SELECT * FROM textt");
while($row = mysql_fetch_array($query))
{
$textname = $row['textname'];
$textbody = $row['textbody'];
echo "<a href=\"tet.php\"> $textname </a>";
}
?>
MichaelR
Forum Contributor
Posts: 148 Joined: Sat Jan 03, 2009 3:27 pm
Post
by MichaelR » Tue Dec 22, 2009 5:42 am
Could you be a bit more clear about what you mean? My first impression is that something like this is what you need:
Code: Select all
echo '<a href="tet.php?textname=' . $textname . '">' . $textname . '</a>';
So that the variable is available on the target page by accessing the $_GET super-global:
dwsddas
Forum Newbie
Posts: 8 Joined: Tue Dec 22, 2009 4:44 am
Post
by dwsddas » Tue Dec 22, 2009 6:55 am
I want $textname to be displayed on target page. I entered your code and it displays blank page.
MichaelR
Forum Contributor
Posts: 148 Joined: Sat Jan 03, 2009 3:27 pm
Post
by MichaelR » Tue Dec 22, 2009 8:11 am
That's because my code simply defined the $textname variable. You'll need to ouput it using echo, for example, on the target page.
dwsddas
Forum Newbie
Posts: 8 Joined: Tue Dec 22, 2009 4:44 am
Post
by dwsddas » Wed Dec 23, 2009 4:56 am
Thanks. It works.