Jump to content

***SELECT INSERTION HELP....


seyz4all

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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??

Link to comment
Share on other sites

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)
?>

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.