Mobile app version of vmapp.org
Login or Join
Becky754

: Capturing a variable from a clicked link or url using php I've build a php page called pageById.php that pulls in and displays data from a MySQL database, but the query is 'static'. $sql

@Becky754

Posted in: #CustomVariables #Mysql #Php #Url

I've build a php page called pageById.php that pulls in and displays data from a MySQL database, but the query is 'static'.

$sql = "SELECT * FROM table WHERE id = 879";


I want to change this so it uses a variable in-place of 879.

$sql = "SELECT * FROM table WHERE id = $var";


I'd like to be able to pull the $var from a link on the previous page or from the URL, but I'm not sure how.

Can someone please help or point me in the direction of a decent tutorial for beginners?

Thanks!

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Becky754

1 Comments

Sorted by latest first Latest Oldest Best

 

@Gretchen104

You need to learn about GET and POST variables.

This is really basic PHP stuff :P

Have a look at php.net/manual/en/reserved.variables.post.php
This question is likely to be migrated to Stack Overflow where I am almost certain it will be a duplicate question

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme