Hi..i have problem..
I have 2 pages..
1)tp.php
2)edit_advisor.php
The tp.php display all the members. once you click on the edit link it will take you the edit_advisor.php page where it display the value of that members from db.
The fields have many check boxes and one input field. Actually i am new to php i dont know how to update the information for that particular members..
Kindly help me out.
tp.php
<script language="javascript" type="text/javascript" >
function deleteNbr()
{
if(confirm("Are you sure ?"))
{
return true;
} else {
return false;
}
}
</script>
<?php
$username = "root";
$password = "root";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$db = mysql_select_db('madrid') or die(mysql_error());
$schoolusers="SELECT distinct first_name,last_name,faculty_id FROM faculty f join faculty_advisor a where f.faculty_id=a.user_id and a.deleted=0";
$rsschoolusers=mysql_query($schoolusers) or die(mysql_error());
echo "<br>";
echo "<br>";
while($rowusers=mysql_fetch_array($rsschoolusers))
{
?>
<? echo "<tr><td><br>".$rowusers['first_name']." ".$rowusers['last_name']." <a href='edit_advisor.php?faculty_id=".$rowusers['faculty_id']."'><img border=0 title='Edit' name='add' src='/images/edit.gif'></input></a> <a href='delete.php?faculty_id=".$rowusers['faculty_id']."'><img border=0 title='Delete' name='delete' id='delete' onClick='return deleteNbr();' src='/images/remove.gif'></input></a></td></tr>";
}
?>
edit_advisor.php
<form name="form1" method="post" action="update.php">
<?php
$host="localhost";
$username="root";
$password="root";
$db_name="madrid";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$user_id=$_GET['faculty_id'];
$sql="SELECT * FROM advisor WHERE user_id='$user_id'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
?><h3>Edit Faculty Advisor
<table cellpadding=11 cellspacing=5 border=0>
<tr><td><b>Select Advisor Type</td>
<td><table cellpadding=5 cellspacing=5 border=0><tr><td><input type=checkbox name=freshman value=1 <?php if ($rows['freshman'] == 1) {echo "checked";} ?>>Freshman</input></td>
<td><input type=checkbox name=concentration_major value=1 <?php if ($rows['concentration_major'] == 1) {echo "checked";} ?>>Concentration/Major</input></td>
<td><input type=checkbox name=coop value=1 <?php if ($rows['coop'] == 1) {echo "checked";} ?>>Coop</input></td>
<td><input type=checkbox name=program_advisor value=1 <?php if ($rows['program_advisor'] == 1) {echo "checked";} ?>>Program Advisor</input></td>
<td><input type=checkbox name=doctoral_advisor <?php if ($rows['doctoral_thesis_advisor'] == 1) {echo "checked";} ?>>Doctoral Thesis Advisor</input></td>
</td></tr></table></td>
</tr>
<tr><td><b>Note</td>
<td><table cellpadding=5 cellspacing=5 border=0><tr><td><input name="note" type="text" id="note" value="<? echo $rows['note']; ?>"></td>
</td></tr></table></td>
</tr>
<tr><td><b>Type</td>
<td><table cellpadding=5 cellspacing=5 border=0><tr><td><input type=checkbox name=internal value=1 <?php if ($rows['internal'] == 1) {echo "checked";} ?>>Internal</input></td>
<td><input type=checkbox name=external value=1 <?php if ($rows['external'] == 1) {echo "checked";} ?>>External</input></td>
</td></tr></table></td>
</tr>
<tr><td>
<input type="submit" name="Submit" value="Submit"></td>
</table>
<?
mysql_close();
?></form>
Now plz help me how to update the checkbox ..Right now the value of checkbox are coming from database..if value= 1 than checkbox is checked.....how to update it in the database....plz