idgeit Posted February 23, 2007 Share Posted February 23, 2007 Hey all, I've been trying to figure out how exactly to do this. At the moment I've got a php page that pulls up info from a database and displays it, But I would like to make a single page and let the ID of the product change and then the page will change to suit the ID. sort of like this page i.e /index.php?=actionpost.......... ect I have no idea where i should be looking under, or what even this is called. Any help would be great, Thanks! ~ Idgeitman Quote Link to comment https://forums.phpfreaks.com/topic/39798-using-ids/ Share on other sites More sharing options...
Ninjakreborn Posted February 23, 2007 Share Posted February 23, 2007 It's called a get query. You have to call a database, you use the id to formulate a query to another page that contains the database information. Quote Link to comment https://forums.phpfreaks.com/topic/39798-using-ids/#findComment-192281 Share on other sites More sharing options...
idgeit Posted February 23, 2007 Author Share Posted February 23, 2007 Thanks for that!, Anyone know of any examples of this at its simplest i can have a look at? ~Thanks Quote Link to comment https://forums.phpfreaks.com/topic/39798-using-ids/#findComment-192358 Share on other sites More sharing options...
Ninjakreborn Posted February 23, 2007 Share Posted February 23, 2007 It ends up getting used in everything day/day programming. For a basic example, here is something off one of my projects, with the same idea. <?php // get user information based on stored session $selectuser = "SELECT * FROM userinformation"; $queryuser = mysql_query($selectuser); echo "<p>Below is all the information about current Clients.</p>"; echo "<hr />"; while ($rowuser = mysql_fetch_array($queryuser)) { // if record found display there user information for editing ?> <?php // display admins here echo "<b>Id:</b> " . stripslashes($rowuser['id']); $edit = "<a href=\"editexistingclient.php?id={$rowuser[id]}\" title=\"Edit This Client\">Edit</a>"; $delete = "<a href=\"deleteclient.php?id={$rowuser[id]}\" title=\"Delete This Client\">Delete</a>"; $addproof = "<a href=\"addproof.php?id={$rowuser[id]}\" title=\"Add Proof\">Add Proof</a>"; $vieworeditproof = "<a href=\"vieworeditproof.php?id={$rowuser[id]}\" title=\"View or Edit Proof\">View or Edit Proof</a>"; echo "<br />"; echo "<b>Email:</b> " . stripslashes($rowuser['email']); echo "<br />"; echo "<b>Username:</b> " . stripslashes($rowuser['username']); echo "<br />"; echo $edit . " - " . $delete; echo "<br />"; echo "<br />"; echo $addproof; echo " - "; echo $vieworeditproof; echo "<hr />"; ?> <?php } ?> That pretty much pulls the list of clients, you see the id's getting passed to the various pages. On those pages things happen with the data. Like for adding a proof (vice versa. on the page you simply $id = $_GET['id']; clean it first however. And there is your id, from there it's basic query knowledge and you can work up your queries, and do whatever you want with it. Quote Link to comment https://forums.phpfreaks.com/topic/39798-using-ids/#findComment-192374 Share on other sites More sharing options...
idgeit Posted February 25, 2007 Author Share Posted February 25, 2007 thanks again!, Its working great Quote Link to comment https://forums.phpfreaks.com/topic/39798-using-ids/#findComment-193871 Share on other sites More sharing options...
idgeit Posted February 25, 2007 Author Share Posted February 25, 2007 i just came across one small problem, I can use echo and print the ID number, but what exactly should i do when I want to use it in a query? $query = 'SELECT products.product_id, products.product_dis, products.product_price, products.product_title FROM products WHERE products.product_id = 10001'; That works fine for the id as 10001 but how can I replace it with the $_GET result? thanks Quote Link to comment https://forums.phpfreaks.com/topic/39798-using-ids/#findComment-193891 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.