Hi experts,
I have a form with many textboxes,listboxes in php.I have a edit button to edit the values in the form.once i click the edit button the existing values should be displayed so that the user can edit those particular values and also that should be updated in the mysql database.kindly reply me as early as possible.
Thanks
8 2046
So when the user clicks edit do you want the page to reload or to just display/enable the text boxes? If you reload you need to send the form to itself (via the action attribute) and check if the method of the page load is "post" and if so, you can have different options with the form via using PHP.
If you don't want the page to load, you need to use javascript to change the form inputs properties and show the "submit" button.
I am not going to write the code for you as the purpose of these forums is not to work for nothing, but help those with some code they already have. Try and get this script working and if you get stuck come back and we'll be happy to help.
PS - How much do you know about PHP and/or MySQL?
I don't see a question in that post. Please revise your post to include a question and sufficient details of your problem. Also, you should post the code you have attempted to solved your problem with - we do not hand out code.
Moderator.
hi experts,
I have attached the code for the form and the database connection.
I want the code to edit the existing values in the form and to store the edited values in the database.
res.html
res.php -
<?php
-
-
$con=mysql_connect("localhost","root","");
-
if(!con)
-
{
-
die("cannot connect".mysql_error());
-
}
-
-
-
mysql_select_db("resume_db",$con);
-
-
-
mysql_query("insert into res_table
-
-
(uname,email,qualification,mobile,percentage,location,institute,country,others,address,jobcategory,joblocation,experience,salary,keyskills,resumetitle,employer)
-
-
values
-
-
('$_POST[uname]','$_POST[email]','$_POST[qualification]','$_POST[mobile]','$_POST[percentage]','$_POST[location]','$_POST[institute]','$_POST[country]','$_POST[others]','$_POST[address]','$_POST[jobcategory]','$_POST[joblocation]','$_POST[experience]','$_POST[salary]','$_POST[keyskills]','$_POST[resumetitle]','$_POST[employer]')") or die(mysql_error());
-
-
$result = mysql_query("SELECT * FROM res_table");
-
-
-
echo "<h3>"."You have successfully uploaded your resume"."</h3>."."<br/>";
-
-
echo "<h4>"."The contents uploaded in your resume are as follows"."<h4>";
-
-
-
-
while($row = mysql_fetch_array($result))
-
{
-
-
echo "<table align='left' cellspacing='8' cellpadding='20'>";
-
-
-
-
echo "<tr>"."<td>"."<b>"."Email:"." "." ".$row['email']."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."Mobile:"." "." ".$row['mobile']."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."Location:"." "." ".$row['location']."</td>"."</tr>";
-
echo "<tr>"."<td>". "<b>"."Country:"." "." ".$row['country']."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."Address:"." "." ".$row['address']."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."Qualification:"." "." ".$row['qualification']."</td>"."<tr>";
-
echo "<tr>"."<td>"."<b>"."Percentage:"." "." ".$row['percentage']."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."Institute:"." "." ".$row['institute']."</td>"."</tr>";
-
-
-
echo "</table>";
-
-
-
echo "<table align='center' cellspacing='8' cellpadding='20'>";
-
-
-
-
echo "<tr>"."<td>"."<b>"."Job Category:"." "." ".$row['jobcategory'] ."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."Job Location:"." "." ".$row['joblocation']."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."Experience:"." "." ".$row['experience']."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."Salary:"." "." ".$row['salary']."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."KeySkills:"." "." ".$row['keyskills']."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."Resume Title:"." "." ".$row['resumtitle']."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."Employer:"." "." ".$row['employer']."</td>"."</tr>";
-
echo "<tr>"."<td>"."<b>"."Others:"." "." ".$row['others']."</td>"."</tr>";
-
-
-
echo "</table>";
-
-
-
-
}
-
-
-
-
?>
kindly somebody help me out on this code.urgent.
Thanks
The code display on this site is not wide enough in my opinion.
What exactly are you trying to achieve? I assume its an basic insert of a record, then pulling it out again and displaying it?
When you insert the data you could then get the last ID entered with mysql_insert_id() then you can pull it out again I guess something like: - mysql_query(".. insert all the data here ..");
-
$some_id = mysql_insert_id();
-
$display_q = mysql_query(" select foo from bar where some_id = '$some_id' ");
-
$row = mysql_fetch_array($display_q);
Then display the data as need be. It seems like you are trying to pull everything again and display it.
Can you advise what the actual problem is.
Thanks.
Thanks for u r reply hoopy,
I m a beginner to php.so the code will not be that much wide enough.any way i m developing a small demo application like a jobsite for my project.
created a login page,profile page and the post resume page to input the details of the candidates.here i have 2 buttons one to post resume and the other is to edit resume .
if we click the edit resume button the existing values of the user should be populated in the inputboxes and listboxes and the user is allowed to edit those values and once the edit resume button is clicked the values gets updated in the database and displayed again.
Able to catch atleast to some extent.pls try to help me out on this.need a sample code for this.
Thanks
I dont know how you have your DB setup and I have dont have a lot of time right now but if you can follow this then you can see quite simply how it works. Say your DB Is laid out like this: - --
-
-- Database: `job_db`
-
--
-
-
CREATE TABLE `resumes` (
-
`user_id` int(10) unsigned NOT NULL auto_increment,
-
`full_name` varchar(100) NOT NULL,
-
`salary` varchar(100) NOT NULL,
-
`joined` int(11) NOT NULL,
-
PRIMARY KEY (`user_id`)
-
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
Say you had this basic example as your form: - <form action="display.php" method="post">
-
Full Name: <input type="text" name="full_name"> <br />
-
Salary: <input type="text" name="salary"> <br />
-
<input type="submit" name="submit" value="Insert">
-
</form>
Then display.php would be like this: - <?
-
-
// db connection
-
mysql_connect("localhost", "root", "")
-
or die(mysql_error());
-
mysql_select_db("job_db")
-
or die(mysql_error());
-
-
// sanitise user input
-
$full_name = mysql_real_escape_string($_POST['full_name']);
-
$salary = mysql_real_escape_string($_POST['salary']);
-
$time = time();
-
-
// insert the data
-
mysql_query("
-
INSERT INTO resumes
-
(full_name, salary, joined)
-
VALUES
-
('$full_name', '$salary', $time)
-
") or die(mysql_error());
-
-
// retrieve the last id inserted
-
$user_id = mysql_insert_id();
-
-
// pull it back out
-
$query = mysql_query("
-
SELECT full_name, salary, joined
-
FROM resumes
-
WHERE user_id = '$user_id'
-
") or die(mysql_error());
-
-
// store the row
-
$row = mysql_fetch_array($query);
-
-
// display the output
-
echo ("Name: " . $row['full_name'] . "<br />");
-
echo ("Salary: " . $row['salary'] . "<br />");
-
echo ("Joined: " . strftime("%H:%M %d/%m/%y", $row['joined']));
-
-
?>
I have tried to keep it as simple as possible. So if you went to that form, and entered those variables it would sanitise the input. Input the data into the table then retrieve the ID which was just inserted, pull it out again and display it.
So it may look something like: - Name: Hoopy
-
Salary: 100
-
Joined: 17:40 26/02/09
If you follow this principle with your code then you should be OK. mysql_insert_id is what you need to look into and the ID it will return is determined by how your database table is setup.
Also the comment about the width was not about your code, it was about the width which Bytes makes the code display, its always a bit too narrow imo.
Hope this help. Good Luck.
hi hoopy,
Good After noon,
thanks for u r code.i will check out and revert back to u.
Thanks
Please keep off-topic discussion outside of this thread please.
Thank you.
- Markus.
Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
4 posts
views
Thread by Nomen Nescio |
last post: by
|
4 posts
views
Thread by Dan Weeb |
last post: by
|
reply
views
Thread by Bob Kaku |
last post: by
|
4 posts
views
Thread by webhigh |
last post: by
|
reply
views
Thread by Sebi |
last post: by
| | | | | | | | | | | | | | |