Delaran Posted May 7, 2007 Share Posted May 7, 2007 Hey guys, I've got a quick question for you all. I don't want you to write my code for me; I want to learn it myself. However, what I'm trying to do I have no clue how to define or even where to look. My problem is this: I am trying to make a multi-page system which queries a database based upon two values, directory_id and company_name. The first page displays the two fields in a table and I would like to make the company_name field a hyperlink to a second page, in which you can update/insert the information based upon which company you clicked. Would this be using sessions, cookies, etc? However, I am unsure of how to do this or what it would be called in a tutorial. ??? Perhaps it has something to do with the URL I would be using to link the next .php page? ie. http://www.mysite.com/pagetwo.php?=company_name=costco&id=2 If anyone could direct me to a tutorial or even link one here I would be eternally grateful. Quote Link to comment https://forums.phpfreaks.com/topic/50372-solved-please-help-this-is-not-code-begging/ Share on other sites More sharing options...
MadTechie Posted May 7, 2007 Share Posted May 7, 2007 OK steps #1, Query the database and echo all company names #1.1, modify to echo as hyperlinks ie <a href="edit.php?cid="..$row['id']">$row['cname']</a> #1.2 NOTE: i used cid= id (this will be UID) 2.0 (the edit.php side) 2.1 create a 2nd file called edit.php design as a form (this will be for updating) 2.2 use $_GET['cid'] you get the id from 1.1 and select * from table where id = $_GET['cid'], this returns the record you selected. 2.3 now edit your edit.php form to set the default values to the data from the database 2.3.1 remember to add a hidden field and set the default to the $_GET['cid']. 2.4 now add a button called update and a extra block of code if(isset($_POST['update'])) { //update table set cname =$_POST['cname'] etc etc WHERE id = $_POST['cid'] } thats the basic build any questions ? (please use ref numbers) EDIT updated id to cid Quote Link to comment https://forums.phpfreaks.com/topic/50372-solved-please-help-this-is-not-code-begging/#findComment-247363 Share on other sites More sharing options...
Delaran Posted May 7, 2007 Author Share Posted May 7, 2007 Muchos gracias! I am always amazed at how quick and helpful the folks are on this site. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/50372-solved-please-help-this-is-not-code-begging/#findComment-247368 Share on other sites More sharing options...
Delaran Posted May 7, 2007 Author Share Posted May 7, 2007 OK steps #1, Query the database and echo all company names #1.1, modify to echo as hyperlinks ie <a href="edit.php?cid="..$row['id']">$row['cname']</a> #1.2 NOTE: i used cid= id (this will be UID) 2.0 (the edit.php side) 2.1 create a 2nd file called edit.php design as a form (this will be for updating) 2.2 use $_GET['cid'] you get the id from 1.1 and select * from table where id = $_GET['cid'], this returns the record you selected. 2.3 now edit your edit.php form to set the default values to the data from the database 2.3.1 remember to add a hidden field and set the default to the $_GET['cid']. 2.4 now add a button called update and a extra block of code if(isset($_POST['update'])) { //update table set cname =$_POST['cname'] etc etc WHERE id = $_POST['cid'] } thats the basic build any questions ? (please use ref numbers) EDIT updated id to cid Ok, so I've gotten my second page to reflect the choices from the first (ie. the name of the company/id via the $_GET command). This is displayed at the top of the page along with a stripslashes command to ignore apostrophes. When I get to your step 2.3 where you say to add a hidden input field, I decided to try changing the field momentarily to a text field. It displays nothing more than the text "$_GET['id']" etc. how would I go about making this string? I have: <input type="text" name="idnum" value=$_GET["id"]> <input type="text" name="conam" value=$_GET["cid"]> (type was changed to text to check if I am inserting it properly. I have tried using quotes around the $_GET field already) Quote Link to comment https://forums.phpfreaks.com/topic/50372-solved-please-help-this-is-not-code-begging/#findComment-247491 Share on other sites More sharing options...
MadTechie Posted May 7, 2007 Share Posted May 7, 2007 try if in a php block echo "<input type="text" name="conam" value=".$_GET['cid'].">"; or if in a html block <input type="text" name="conam" value="<?php echo $_GET['cid']; ".> Quote Link to comment https://forums.phpfreaks.com/topic/50372-solved-please-help-this-is-not-code-begging/#findComment-247522 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.