cs1h Posted September 19, 2007 Share Posted September 19, 2007 Hi, I am using the get method on my form to send information to my proccesing script, but i don't know how to take the information from the url and so that i can search for it in the database using a piece of code like this, $sql = "SELECT * FROM items WHERE id=$art"; Can any one tell me how to do this, Cheers Colin Quote Link to comment https://forums.phpfreaks.com/topic/69911-solved-how-to-get-information-from-url/ Share on other sites More sharing options...
Fadion Posted September 19, 2007 Share Posted September 19, 2007 <?php $art = $_GET['id']; $sql = "SELECT * FROM items WHERE id=$art"; $results = @mysql_query($sql) or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/69911-solved-how-to-get-information-from-url/#findComment-351144 Share on other sites More sharing options...
chocopi Posted September 19, 2007 Share Posted September 19, 2007 to get a info from the url you use $_GET http://www.somesite.com/index.php?art=hello <?php $art = $_GET['art']; $sql = "SELECT * FROM items WHERE id=$art"; ?> ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/69911-solved-how-to-get-information-from-url/#findComment-351147 Share on other sites More sharing options...
redarrow Posted September 19, 2007 Share Posted September 19, 2007 @ <<<<< take that away what the point in the die then. Quote Link to comment https://forums.phpfreaks.com/topic/69911-solved-how-to-get-information-from-url/#findComment-351149 Share on other sites More sharing options...
redarrow Posted September 19, 2007 Share Posted September 19, 2007 url example <?php example.php?id=$art ?> <?php if($_GET['id']=="$art"){ $x = $_GET['art']; $sql = "SELECT * FROM `items` WHERE id='$x'"; $results = mysql_query($sql) or die(mysql_error()); // echo required info. }else{ header("location: index.php"); exit; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/69911-solved-how-to-get-information-from-url/#findComment-351153 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.