Hey,
I was wondering how to use php to show mysql data on a webpage, but use the same webpage to show different results.Kind of like webpage.php?id=something so I can just change the id in the url to view different mysql content if thats possible??
If not how would I go about doing something else similar to this?
Thanks alot.
PHP and MySQL one page to show all
Moderator: General Moderators
- andyhoneycutt
- Forum Contributor
- Posts: 468
- Joined: Wed Aug 27, 2008 10:02 am
- Location: Idaho Falls
Re: PHP and MySQL one page to show all
Well, the id will be present in the $_GET global, so assuming it's url.php?id=1234, you could use the $_GET['id'] variable to modify your sql statement. Be sure to sanitize any data you use in this way before passing it on to mysql. Functions such as mysql_real_escape_string are recommended, as well as variable typecasting where you can. I like to use an sprintf() statement to build my sql statement anymore, or rely on a package like PDO.
-Andy
-Andy
Re: PHP and MySQL one page to show all
Hey,
Thanks alot for the help, I am having trouble finding any pages on the web to help me do this, it sounds like you do this kind of stuff alot so just wondering if you knew any websites with good demos and tutorials on this?
Its my first time doing anything at all like this so all sounds a bit confusing lol
Thanks alot for the help, I am having trouble finding any pages on the web to help me do this, it sounds like you do this kind of stuff alot so just wondering if you knew any websites with good demos and tutorials on this?
Its my first time doing anything at all like this so all sounds a bit confusing lol