Jump to content

Dynamic Links


joelhazel

Recommended Posts

I've researched into creating pages with dynamic links (aka domain.com/properties.php?id=10) to show details of that particular property and have come up empty.  My code for the actual link on the index.php page is:

 

<a href="properties.php?id=$row[0]">View</a> - Where $row[0] pulls the property ID

 

 

I've read of a couple ways to pass that information onto the properties.php page, such as

 

$ref = intval($_GET['ref']);

$query = ("SELECT * FROM properties WHERE id=$ref");

echo '$query';

 

and also

 

$ref = $_REQUEST["id"];

$query = ("SELECT * FROM properties WHERE id=$ref");

echo '$query';

 

Neither of which have worked.  I am sure I'm missing something but everything I've read hasn't seemed to help or at least I don't have enough knowledge to know what exactly I should have done.  Also, my register_globals = Off which I include because one page referenced that but everything I've read suggests NOT to turn it On. 

 

Ideas?

Link to comment
https://forums.phpfreaks.com/topic/189941-dynamic-links/
Share on other sites

You do the database magic THEN you build the link once you have pulled the data from the database. You then do something in the link page with the ID.

 

You should start by making a form.php for practice and a process_form.php to display the data. Once you have that you should make a connect.php to get some data from a database and a process_connect.php to display the data from the database. By that time you should understand enough of whats going to make something usable.

 

 

HTH

Teamatomic 

Link to comment
https://forums.phpfreaks.com/topic/189941-dynamic-links/#findComment-1002205
Share on other sites

teamatomic,

 

As far as creating files for practice, that's really what I've already got.  My index.php file connects to and selects * from the properties table, listing all the data in a table format.

 

I can create files all day long but not knowing what should go in them is kinda what I'm after.

Link to comment
https://forums.phpfreaks.com/topic/189941-dynamic-links/#findComment-1002210
Share on other sites

Well, thats kinda the reason you build an app, cause you have some data and an idea of how you want to use it. If you grab everything then you use only what you need and ignore the rest. If you dont have what you need give it a good think and you can probably use something you have already retrieved(like ID's) to get data you can use. I guess you should sit down with a legal pad and a six-pack and figure out what you want to do.

 

 

HTH

Teamatomic

Link to comment
https://forums.phpfreaks.com/topic/189941-dynamic-links/#findComment-1002235
Share on other sites

For any out there who may have had the same issues as me .. the answer to my question is:

 

$ref = $_GET["foo"];    <----- THIS

$query = "SELECT * FROM table WHERE foo='$ref'";    <----- AND THIS

 

$result = mysql_query($query);....etc etc

 

 

Where foo is the name of the table column you want to show. 

 

Link to comment
https://forums.phpfreaks.com/topic/189941-dynamic-links/#findComment-1003801
Share on other sites

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.