Forum Moderators: coopster

Message Too Old, No Replies

Using a hyperlink to retrieve data? is it possible without?

         

steven420

3:05 am on May 10, 2007 (gmt 0)

10+ Year Member



Hi, I was wondering if it is possible to get data from a database using a hyperlink instead of a form? My situation is I have a page with a list of products (data from a mysql table) and I want to keep the info on the page small so I have limited the description and left out some info. what I want is a link at the bottom of each product that says "more details" and when clicked it creates a new page on the fly to show more info. is it possible to do this without javascript? If so How. Any tips?

Thanks,
Steven.

dreamcatcher

7:18 am on May 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Steven,

Sure, you can do this with query strings.

index.php?id=ID_NUMBER_HERE

SELECT * FROM table WHERE id = '".$_GET['id']."' LIMIT 1;

And then display your data. Assuming you have a unique identifier for each row. This is ideally an auto increment id field.

Its worth noting that query strings are open to abuse if not used correctly. So, try and check any data that comes in from a query string to make sure that no-one has attempted to change anything. This can be a common cause of SQL Injection Vulnerabilities [webmasterworld.com].

Some of the PHP functions like strip_tags [uk3.php.net] & the ctype [uk3.php.net] functions should prove useful, along with some of the regex [uk3.php.net] commands.

dc

henry0

12:25 pm on May 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When familiarized with passing your query using $_GET
You will need to be very much concerned (As per dreamcatcher) with security.
As an advanced security move you may consider using a random token to be passed along the query.
Then pass that token as a session and verify that the result of $_GET==$_SESSION[‘token’];
If yes then let the script carry on; if not then its an intrusion tentative and exit();

A similar tech was discussed

HERE
[webmasterworld.com]

steven420

7:05 pm on May 11, 2007 (gmt 0)

10+ Year Member



Hi, Thanks for all the help but I am still confused. I am using a pagination class to display the products and I don't understand how to remove the pagination(displays 15 products) and only display 1 product. If I was using a form I would understand how to do this but i don't understand how to do this using a hyperlink. I haven't been able to find any good tutorials on this stuff. Can anyone explain exactly how this works. How would I use conditional statements with a hyperlink?

steven420

12:55 am on May 12, 2007 (gmt 0)

10+ Year Member



Thanks for all the help I think I've got it figured out now.