greencoin Posted June 26, 2007 Share Posted June 26, 2007 I need some help creating a "modify / update records" page. Something that will grab a record and allow the user to post information into the fields that haven't been filled yet. I already have my create record page, I just don't know how to make a modify page. I'm also not sure if I should use checkboxes to select the record then modify on a different page or just allow the user to modify on the same page. The theory behind the worksheet is a person enters the customer name and date the contract is created. When we get confirmation, the person who received the confirmation enters the date it was received, the person who received it and who it was credited to. Any help or advice is as always, greatly appreciated. Thanks ~Rich Quote Link to comment Share on other sites More sharing options...
soycharliente Posted June 26, 2007 Share Posted June 26, 2007 SO what are the checkboxes doing? SOunds like you just want them to fill out a form for a record. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Share Posted June 26, 2007 yeah just make another form with all the same fields might as well copy the same form.. get the record by using mysql get record from table where name = name and date = date after that just echo out the result in the corresponding fields <input value="<?=$name?>" type="text"> it's always to think what you want to do first.. a good tip is to write it out since php is like English just write down what you want and work your way into the coding. Quote Link to comment Share on other sites More sharing options...
DJTim666 Posted June 26, 2007 Share Posted June 26, 2007 If you want to modify something in a MySQL database in forms. Use this code. <?php $result = mysql_query("SELECT `name`FROM `customers` WHERE customer='w.e'"); echo "Name: <input type='text' name='name' value='$result' />"; ?> That will echo the result of $result into the form field, then just edit what it is click submit at the bottom of the page, and WAALAA. xD! Quote Link to comment Share on other sites More sharing options...
greencoin Posted June 26, 2007 Author Share Posted June 26, 2007 SO what are the checkboxes doing? Sounds like you just want them to fill out a form for a record. Well, the checkbox would be used to select which record to modify - I think it would prolly be easier to generate a "modify" button on the end of each row that when pressed, passed that row to a modify page. What I need help with is what would the code that modifies the record look like? What would the code that passes the selected row to the modify page look like? Thanks ~Rich Quote Link to comment Share on other sites More sharing options...
soycharliente Posted June 26, 2007 Share Posted June 26, 2007 You don't need both a checkbox and a modify button. Just a modify button would work fine. Pass the recordId with $_GET or something and generate the form that way. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Share Posted June 26, 2007 i know you want to be illustrated, but it's too much work to create the file to show you how, you show try and any problem you have post your code and we can help you better.. just get all the records out with a modify bottom next to it and when you click on one use the get method to call the record by himself. Quote Link to comment Share on other sites More sharing options...
greencoin Posted June 26, 2007 Author Share Posted June 26, 2007 I guess what I'm asking is what will the INSERT line look like when I try to repost to a record that already has data in it? Is it the same as when you create a new record? and you're right, I don't want a checkbox cause it's not neccessary to modify multiple records at the same time. Just a modify button on the end. ~Rich Quote Link to comment Share on other sites More sharing options...
soycharliente Posted June 26, 2007 Share Posted June 26, 2007 UPDATE table SET field='$var' Quote Link to comment Share on other sites More sharing options...
greencoin Posted June 26, 2007 Author Share Posted June 26, 2007 UPDATE table SET field='$var' Thanks! ~Rich Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Share Posted June 26, 2007 ok here is a hint my friend.. <?php // THIS WOULD SEARCH FOR THE CLIENT WITH NAME AND DATE THAT YOU SPECIFY $getRecord=mysql_query("SELECT * FROM tablename WHERE name='$clientname' AND date='$givendate'")or die(mysql_error()); //THIS WILL CHECK IF ANY RECORD WAS FOUND $checkclient=mysql_num_rows($getRecord); if($checkclient>0){ // IF THE RECORD WAS FOUND THIS WILL LOOK THREW EVERY DETAIL OF THE CLIENT $getInfo=mysql_fetch_array($getRecord); //NOW IS UPTO YOU TO DO WHATEVER YOU WANT WITH THE INFO YOU GOT FROM THE CLIENT IN THE DATABASE }else{ //ELSE IF NO RECORD IS FOUNF DISPLAY THIS echo " Sorry the client you where searching for is not in the database."; }?> Quote Link to comment Share on other sites More sharing options...
greencoin Posted June 26, 2007 Author Share Posted June 26, 2007 Corillo81: your code is very helpful to me but in other applications. This form will not have to perform searches through records as it will only display records of contracts not received. Once the record is modified to show the contract has been received, it will "deactivate" the record thus excluding it from future general queries. The only time the record will surface is when the user chooses to view all records or queries records on specific fields. Thanks for your help everyone. I'm gonna call this one closed... ~Rich Quote Link to comment 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.