hi i am new to php. I am having some problem.
i had created a dropdown list which contains project names. and below that a table with checkbox userid,username. till tat it is working properly.
after selecting the project name and one cheque box and press submit button.It should display in the database table, as userid, project id and assigned date. but i am not getting that code so please can anyone.
thank u.
<?php
ob_start();
@session_start();
require_once ("check.php");
createsessions($username,$password,$userid,$projectid);
$con=mysql_connect("10.70.1.50","invensis","invensis");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database_myproject",$con);
$sql="SELECT projectname from projects where createdby='$_SESSION[username]'";
mysql_error();
$result=mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result))
{
$id=$row["projectid"];
$projectname=$row["projectname"];
$options.="<option value=\"$id\">".$projectname.'</option>';
}
$sql2="SELECT * FROM users where reportingto='$_SESSION[username]' and role='2'";
mysql_error();
$result2=mysql_query($sql2);
$num=mysql_num_rows($result2);
mysql_close($con);
?>
<head>
<body>
<table width="100%">
<tr><td> <img src="Logofinalcopy.gif">
</td></tr>
<tr>
<td bgcolor="aqua"><h2>Project assign</h2></td>
</tr></table>
<br>
<table align="center">
<tr>
<td>projectassign</td>
<td><select name="id">
<option value=0 >---select----<?=$options?>
</select>
</td>
</tr>
</table>
<br><br><br>
<table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px">
<tr>
<th></th>
<th>userid</th>
<th>username</th>
</tr>
<?php
$sno=1;
while($row=mysql_fetch_array($result2, MYSQL_ASSOC)){
?>
<tr>
<td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $row['userid']; ?>"></td>
<td><? echo $row['userid']; ?></td>
<td><? echo $row['username'];?></td>
</tr>
<?php
$sno=$sno+1;
}
?>
</table>
<input type="submit" name="Submit" id="Submit" value="Submit">
<?php
if($_POST['Submit']=='Submit')
{
for($i=0;$i<count($checkbox);$i++)
{
$userid = $checkbox[$i];
$sql3 = "Insert into projectassign(projectid,userid,assigneddate)values('$_POST[projectid]','$userid','')";
mysql_error();
$result = mysql_query($sql);
}
}
?>
</body>
</head>