seyz4all Posted August 14, 2008 Share Posted August 14, 2008 I dont know how to go about this i have a form that i want to retrieve data, i mean some of the textfields. on the top frame, i would i have 1 textfield ID and a retrieve button user will insert the id of the data and click on the retrieve button to retrieve the data on the bottom frame. ///////////////////////////////////////////////////////////////////////// on the botton frame, i would 5 textfields. 3 are readonly from database after retrival and 2 others are not readonly, data would be inserted into those ID Name (readonly) Age (readonly) Sex Weight then a button in the bottom to submit all into the database... i tot of this and this is the solution to a small form i am creating, but i dont know how to create the script... Please anyone that can help me write this one script, or if you have a better solution to this, i would be very grateful Quote Link to comment https://forums.phpfreaks.com/topic/119674-select-insertion-help/ Share on other sites More sharing options...
seyz4all Posted August 15, 2008 Author Share Posted August 15, 2008 SOMEONE PLEASE HELP WITH THIS Quote Link to comment https://forums.phpfreaks.com/topic/119674-select-insertion-help/#findComment-617222 Share on other sites More sharing options...
ajclarkson Posted August 15, 2008 Share Posted August 15, 2008 How good is your knowledge of handling forms using php? Do you understand the basics of $_POST variables etc? Quote Link to comment https://forums.phpfreaks.com/topic/119674-select-insertion-help/#findComment-617232 Share on other sites More sharing options...
seyz4all Posted August 15, 2008 Author Share Posted August 15, 2008 am still a novice Quote Link to comment https://forums.phpfreaks.com/topic/119674-select-insertion-help/#findComment-617243 Share on other sites More sharing options...
seyz4all Posted August 15, 2008 Author Share Posted August 15, 2008 Please i need help on this, i am new with php, please can anyone help me with the code to this scenario... I will appreciate this is the case scenario of what i want to achieve the first textfield would accept the id and the user would click on the search button, and a form with 3 textfields is generated with the result of the search in the textfields, that is textfield 1 would display the id textfield 2 would display the name textfield 3 would display the age and then i can now click on a submit button to take the data into another table in that database have you seen a script like what i descibe if you can help me out with this i would appreicate Quote Link to comment https://forums.phpfreaks.com/topic/119674-select-insertion-help/#findComment-617244 Share on other sites More sharing options...
ajclarkson Posted August 15, 2008 Share Posted August 15, 2008 Im afraid I cannot write the script for this at the minute as I am at work and will not have the time. I would suggest that you do a google search on handling forms with php and look at how you can retrieve information from your HTML forms. It's quite straight forward. Also if you have not got the database aspect sorted, I would recommend looking at a brief php/mysql tutorial. It is all well and good someone giving you the script, but it is better for you to understand it, especially if something goes wrong in the future. Quote Link to comment https://forums.phpfreaks.com/topic/119674-select-insertion-help/#findComment-617254 Share on other sites More sharing options...
seyz4all Posted August 15, 2008 Author Share Posted August 15, 2008 ok... i just need a little snippet on how a textfield would show results from a search, that is after clicking on the button... i'll fgure out the rest... the databse is no problem... i'll appreciate ur help... Quote Link to comment https://forums.phpfreaks.com/topic/119674-select-insertion-help/#findComment-617262 Share on other sites More sharing options...
Kryllster Posted August 16, 2008 Share Posted August 16, 2008 Ok what I need to know is are you working with sessions or just data.I'm not real sure what you are doing. If you just want to update a data base with 2 fields I can show you somewhat of how the form would look. <form action="your_script_here.php" method="post"> <input type="text" name="id"> <br> <input type="text" name="name"> <br> <input type="text" name="age"> <br> <input type="submit" value="Update"> </form> From there how to get the value from the database to be editable in their respect fields is a little beyond me. I'm not sure you would want to update the id field as more than likely its unique and should not be changed, at least to my thinking. here might be the syntax for replacing the name and age. Something like this: name = replace(name,'name_in_db','name_from_form') age = replace(age,'age_from_db','age_from_form') This is where I would start personally. Hope that helps solve the problem a little?? Quote Link to comment https://forums.phpfreaks.com/topic/119674-select-insertion-help/#findComment-618129 Share on other sites More sharing options...
Kryllster Posted August 16, 2008 Share Posted August 16, 2008 Sorry for the double post but here is some code I just came up with. Hope is helps <?php session_start(); $uname = $_SESSION['uname']; // Post Variables $post_name = $_POST['name']; $post_age = $_POST['age']; // Connect to Db (I use an include for that) include('includes/db_connect.php'); // Select the right id or username ($tbl_name comes from config) $sql="SELECT * FROM $tbl_name WHERE uname='$uname'"; $result=mysql_query($sql); // Put info into array while($row=mysql_fetch_assoc($result)) { // give db info a name $db_name = $row['name']; $db_age = $row['age']; //Update the db $sql="UPDATE $tbl_name SET name = replace(name,'$db_name','$post_name'), age = replace(age,'$db_age','$post_age') WHERE uname='$uname'"; mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); } // A lot of this is just copy and paste as I basically use same code just different info // You might want to close db (I usually dont, I think its closed after session is destroyed) ?> Quote Link to comment https://forums.phpfreaks.com/topic/119674-select-insertion-help/#findComment-618151 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.