bullbreed Posted January 18, 2010 Share Posted January 18, 2010 Hello PHP masters I have a page on my site called client info.php. This page shows information specific to one of my clients. I have a table in the db called trainingdata that holds the following info id-------description-------date-------username------dateactioned-------action The id, description, date and username have data that was collected when the user completed a form. dateactioned and action are empty columns I would like to be able to add data to the these empty ones by filling in a form on my page but it has to fill in the empty columns and not add a new row to the table because the info is associated with that user and that particular row of info as it will be displayed on the same page in the same html table. I cant do it Here is what I tried <?php $submit = $_POST['submit']; //Form data $action = addslashes(strip_tags($_POST['action'])); $dateactioned = date("d-m-Y"); if ($submit){ //Check for existing fields if ($action){ //Register the user $queryreg = mysql_query(" INSERT INTO " . TBL_TRAININGDATA . " (`action`, `dateactioned`) VALUES ('$action', '$dateactioned')"); echo("<td><font size=\"2\" color=\"#0066FF\">Your training request has been sent successfully. <br /> We will be in touch with more details.</font><td>"); }else{ echo "<td><font size=\"2\" color=\"#ff0000\">Please complete <b>ALL</b> fields</font><td>"; } } ?> Obviously this code doesn't add it to the users row. It adds a new row to the database.It also doesn't make it relevant to that user. I hope I have explained it well enough. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/188951-adding-data-in-to-a-user-specific-row/ Share on other sites More sharing options...
will35010 Posted January 19, 2010 Share Posted January 19, 2010 You need to use an update query. like: UPDATE TRAININGDATA SET action='$action',dateactioned='$dateactioned' WHERE some_column=some_value; more info can be found here: http://www.w3schools.com/sql/sql_update.asp Quote Link to comment https://forums.phpfreaks.com/topic/188951-adding-data-in-to-a-user-specific-row/#findComment-997752 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.