Jump to content

trying to figure out edit fuction for a form.


Birdmansplace

Recommended Posts

I have been searching for hours over the last day or 2 for find let alone understand how i would write code for calling the last data entered to mysql and then submiting the changed data.  I already have code for entering it and code to read it to display from html/php.  How would i go about doing that?  I know basic php, not so much mysql atm so, with that said much help would be needed.

 

this is part of the code that i have php connecting to mysql to read and then display the contents.

 

include("dbinfo.php");

mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM schedule ORDER BY date DESC";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

 

So lost.......

Link to comment
Share on other sites

do you want lastInsertID?

 

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb');

mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());
?>

 

or if you need it more advanced, check out mysql triggers

here is a video i made 

Link to comment
Share on other sites

my form has 153 enterys.  Once the submit button has been clicked it saves to mysql.  What i am trying to figure out is the best way to edit after submit.  Basicly from the "view" page is to be able to change 1 to 153 enterys then submit again but over write what has been saved with out creating a new entry.

 

the only idea i can come up with is manualy changing enterys in phpmyadmin or mate "view" and "form" page together.  meaning "view" page calls the info from sql and displays it then while on that page also have "form" code in it so you can submit the changes.  Doing it that way to me would create another entery and still would have to go into phpmyadmin and delete the other.

 

What i am making is an online schedule for work and would hate to delete the hole thing if the user while entering made a mistake.  I already have delete set up to wipe out the whole table but the manager would like to keep a record for so long to look back on.  I just looking for something to edit one entry.

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.