Hi Guys,
I'm fairly new at PHP and have been faced with a problem, I am doing a website for jobseekers to post resume details and employers to post vacancies. I am using MySQL database and using the adodb wrapper.
The problem is as follows:
the jobseeker can add Work Experience via a link that goes to a form that inserts (SQL insert) the necessary information on the work experience table, this form loops on itself and allows multiple instances of work experiences. Once the user is finished he/she can view the information which is displayed in another form that uses a foreach loop to print tables with input boxes populated by the database corresponding to the multiple work experiences. Up to this point it seems to be working, however each table has an update button and a delete button which should essentially update the particular record based on the input boxes or delete the record. So far I have just coded the update button and when it is clicked, it re-writes all the records that match the logged-in user id to the value that was in the input box for ALL records... The code thus far is:
<?php
session_start();
require('pconn.php');
$usr_id = $_SESSION[user_id];
$sqlwk = $conn->Execute("SELECT F_NAME, EMPLOYER, POSITION, GEN_INFO, JOB_ID FROM jobseeker, work_experience WHERE jobseeker.USER_ID = work_experience.USER_ID AND work_experience.USER_ID = '".$usr_id."'");
include_once('main.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Work Experience</title>
</head>
<body>
<div class="label">
<h1>Edit/Delete Work Experience</h1>
<h4>Click <a href="wrkexp.php">HERE</a> to ADD to the list OR Click <a href="jobseeker.php">HERE</a> to return to your PROFILE</h4>
<h4 style="color:#FF0000">* Required Fields</h4>
</div>
<div class="content">
<?php
foreach ($sqlwk as $value=>$row){
if (isset($_POST['update'])) {
$employer = trim($_POST['employer']);
$position = trim($_POST['position']);
$description = trim($_POST['description']);
$jb_id = $row['JOB_ID'];
//To test if update is successful
$conn->Execute("UPDATE work_experience SET EMPLOYER='$employer' WHERE USER_ID = '$usr_id' AND JOB_ID = '$jb_id'") or die(mysql_error());
echo $jb_id;
}
print(
"<form action='' method=post name=update >
<table width=441 border=0>
<tr>
<td width=21 align=center valign=bottom style=color:red>*</td>
<td width=189>Employer</td>
<td width=177><input name=employer type=text id=employer size=30 value = '".$row['EMPLOYER']."'> </td>
</tr>
<tr>
<td align=center valign=bottom style=color:red>*</td>
<td>Position</td>
<td><input name=position type=text id=position size=30 value = '".$row['POSITION']."'></td>
</tr>
<tr>
<td align=center valign=bottom> </td>
<td valign=top>Description</td>
<td><textarea name=description cols=30 rows=5 id=description>".$row['GEN_INFO']."</textarea></td>
</tr>
<tr>
<td align=center valign=bottom><div align=center><span class=style1><span class=style2></span></span></div></td>
<td> </td>
<td> </td>
</tr>
<tr align=center valign=bottom>
<td colspan=3>
<div align=center class=style1 style2>
<div align=right>
<input name=update type=submit value=Update>
<input name=delete type=submit value=Delete>
</div>
</div><span class=style2>
</label>
</span>
<div align=center class=style1 style2></label>
</div></td>
</tr>
<tr>
<td colspan=3 align=center valign=bottom style=border-top:thick solid black> </td>
</tr>
</table>
</form>"
);
}
?>
</div>
</body>
</html>
Any help or tips would be greatly appreciated.
Thanks
I'm fairly new at PHP and have been faced with a problem, I am doing a website for jobseekers to post resume details and employers to post vacancies. I am using MySQL database and using the adodb wrapper.
The problem is as follows:
the jobseeker can add Work Experience via a link that goes to a form that inserts (SQL insert) the necessary information on the work experience table, this form loops on itself and allows multiple instances of work experiences. Once the user is finished he/she can view the information which is displayed in another form that uses a foreach loop to print tables with input boxes populated by the database corresponding to the multiple work experiences. Up to this point it seems to be working, however each table has an update button and a delete button which should essentially update the particular record based on the input boxes or delete the record. So far I have just coded the update button and when it is clicked, it re-writes all the records that match the logged-in user id to the value that was in the input box for ALL records... The code thus far is:
<?php
session_start();
require('pconn.php');
$usr_id = $_SESSION[user_id];
$sqlwk = $conn->Execute("SELECT F_NAME, EMPLOYER, POSITION, GEN_INFO, JOB_ID FROM jobseeker, work_experience WHERE jobseeker.USER_ID = work_experience.USER_ID AND work_experience.USER_ID = '".$usr_id."'");
include_once('main.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Work Experience</title>
</head>
<body>
<div class="label">
<h1>Edit/Delete Work Experience</h1>
<h4>Click <a href="wrkexp.php">HERE</a> to ADD to the list OR Click <a href="jobseeker.php">HERE</a> to return to your PROFILE</h4>
<h4 style="color:#FF0000">* Required Fields</h4>
</div>
<div class="content">
<?php
foreach ($sqlwk as $value=>$row){
if (isset($_POST['update'])) {
$employer = trim($_POST['employer']);
$position = trim($_POST['position']);
$description = trim($_POST['description']);
$jb_id = $row['JOB_ID'];
//To test if update is successful
$conn->Execute("UPDATE work_experience SET EMPLOYER='$employer' WHERE USER_ID = '$usr_id' AND JOB_ID = '$jb_id'") or die(mysql_error());
echo $jb_id;
}
print(
"<form action='' method=post name=update >
<table width=441 border=0>
<tr>
<td width=21 align=center valign=bottom style=color:red>*</td>
<td width=189>Employer</td>
<td width=177><input name=employer type=text id=employer size=30 value = '".$row['EMPLOYER']."'> </td>
</tr>
<tr>
<td align=center valign=bottom style=color:red>*</td>
<td>Position</td>
<td><input name=position type=text id=position size=30 value = '".$row['POSITION']."'></td>
</tr>
<tr>
<td align=center valign=bottom> </td>
<td valign=top>Description</td>
<td><textarea name=description cols=30 rows=5 id=description>".$row['GEN_INFO']."</textarea></td>
</tr>
<tr>
<td align=center valign=bottom><div align=center><span class=style1><span class=style2></span></span></div></td>
<td> </td>
<td> </td>
</tr>
<tr align=center valign=bottom>
<td colspan=3>
<div align=center class=style1 style2>
<div align=right>
<input name=update type=submit value=Update>
<input name=delete type=submit value=Delete>
</div>
</div><span class=style2>
</label>
</span>
<div align=center class=style1 style2></label>
</div></td>
</tr>
<tr>
<td colspan=3 align=center valign=bottom style=border-top:thick solid black> </td>
</tr>
</table>
</form>"
);
}
?>
</div>
</body>
</html>
Any help or tips would be greatly appreciated.
Thanks