Jump to content

[SOLVED] how to modify records with a button or check box...?


greencoin

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.";

}?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.