Hey all!

I've been working on a website but have been having a bit of trouble with dynamic linking using php. I've tried (and failed) with different methods to get it working but i need the help of some very talented coders :)

I currently have a webpage which extracts info from a database using mysql, and i would like to link the outputted info to another page which dynamically changes content based on the link. (Each link has different information associated with it)

To simplify, lets say i have 2 pages - stuff.php and info.php

In the stuff.php file, i have managed to get the connection and output from the database all working. I have attempted to send the output name to info.php via this code.

echo "<td><a href=\"info.php?{$row['Name']}\">$f1</a></td>";

**$f1 is the variable i have used to output from the database.

On the info.php page - (This code is just to grab the name from stuff.php, and output the name)

    $query="SELECT * FROM tblStuff WHERE Name='$stuffname'";
    $row = mysql_fetch_assoc($result);
    echo $row['Name'];

The idea is straightforward,

  • User clicks link,
  • Link sends user to info.php,
  • stuff.php sends link name to info.php,
  • info.php grabs name from stuff.php
  • Outputs name

Now upon testing, the links on stuff.php appears to have the name added onto the end of each hyperlink (which is what i wanted), except that info.php isn't outputting the name of the link. Anyone able to provide any solutions?

Thanks in advance

Recommended Answers

All 5 Replies

here is how i do it

<a href="info.php?Name=<? echo $row['Name']; ?>"><? echo $f1;?></a>

and in info.php write it this way


and then continue with your code in stuff.php

Thanks for the reply dragonlee,

Ive modified the code so its similar to yours, however, the info.php still refuses to output anything, it remains a blank page :/

Any suggestions or ideas?

Member Avatar for rajarajan2017

Check whether you get the value of Name="echo value", Just check your address bar it comes with the value after click the link.

echo $stuffname;

Well after 4 hours of fiddling around with the code, i managed to make it work!

Heres the solution to my problem -

On the first page, stuff.php, the output links from the database became

<a href="#" onclick="document.myform.formVar.value='<? echo $row['Name']; ?>'; document.myform.submit(); return false"><? echo $f1;?></a>

Take note of

value='<? echo $row['Name']; ?>

this is how i managed to get the value outputted on the info page exactly the same as the link i clicked.

Then at the bottom of stuff.php, i made the hyperlink an "invisible" form -

<form method=post name="myform" action="anime.php">
	<input type="hidden" name="formVar" value="">

And finally, on the info.php page -

// Retrieve the hidden form variable (using PHP).
$myvar = $_POST['formVar']; echo $myvar; 

Thanks for the help, gl and if anyone runs into the same problem, hopefully this is also the solution :)

On a related note. I'm trying to upload buddypress visitor maps to my website. Unfortunately, this requires uploading geolitecity.dat which is a 30mb file. I am on byethost which has a file upload size limit of 10mb. Therefore I have uploaded the file to an external website here.


Is there anyway to link the file to the site so that the plugin can run correctly.

Thanks for your time,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.