Checkbox Form - Inserting row data from one Table to Another
Posted: Sun Nov 15, 2009 10:21 pm
This is driving me crazy. I have been trying to work this out for weeks and cannot get my head around it. any help would be greatly appreciated!! 
I have two tables "tbl_jobs" and "tbl_jobs_done". I have an SQL query which displays and formats my daily job list from tbl_jobs SQL database, and has a checkbox at the end of each row. I can't get the stupid checkboxs to work :*(
I want to be able to select 1, 2, 3 or more checkboxs and then click my submit button which will then insert the data into my second MySQL database named "tbl_jobs_done". i have spent hours and hours looking at tutorials and other peoples forum posts but can't seem to find something that hits home and works for me
I only need the jobs_id field data from the tbl_jobs to be inserted into tbl_jobs_done table and into jobs_id field. I have other data on the form that will also be submitted. But in general, that's all I need :*(
Here is my SQL Query ->
And here is my Insert code:
I have two tables "tbl_jobs" and "tbl_jobs_done". I have an SQL query which displays and formats my daily job list from tbl_jobs SQL database, and has a checkbox at the end of each row. I can't get the stupid checkboxs to work :*(
I want to be able to select 1, 2, 3 or more checkboxs and then click my submit button which will then insert the data into my second MySQL database named "tbl_jobs_done". i have spent hours and hours looking at tutorials and other peoples forum posts but can't seem to find something that hits home and works for me
I only need the jobs_id field data from the tbl_jobs to be inserted into tbl_jobs_done table and into jobs_id field. I have other data on the form that will also be submitted. But in general, that's all I need :*(
Here is my SQL Query ->
Code: Select all
if(!isset($cmd))
{
echo "<form method='post' action=''><table width='98%' cellspacing='1' cellpadding='1' border='0'>\n";
echo "<tr>\n";
echo "<td class='sectiontitle' valign='top' align='left' width='100%'>Today's Jobs!</td>";
echo "<td class='txt' colspan='2' valign='top' align='right'><input name='submit' type='submit' value='Complete'></td>";
echo "</tr>\n";
$everyday=EVERYDAY;
$dayname=date('l');
if($wtype=date('l'))
{
if ($wtype=="Saturday" or $wtype=="Sunday")
{
$wtype=WEEKEND;
}
elseif ($wtype=="Monday" or $wtype=="Tuesday" or $wtype=="Wednesday" or $wtype=="Thursday" or $wtype=="Friday")
{
$wtype=WEEKDAY;
}
}
$result = mysql_query("SELECT * FROM tbl_jobs WHERE jobs_datetype IN('$everyday', '$dayname', '$wtype') ORDER BY jobs_id ASC");
$count=mysql_num_rows($result);
$i = 0;
while($r=mysql_fetch_array($result))
{
$jobs_id=$r["jobs_id"];
$jobs_description=str_replace("\r\n","<br>",$r["jobs_description"]);
$jobs_datestart=$r["jobs_datestart"];
$jobs_dateend=$r["jobs_dateend"];
$jobs_datetype=$r["jobs_datetype"];
$jobs_user=$r["jobs_user"];
$jobs_updateuser=$r["jobs_updateuser"];
if($i%2 == 0){
echo "<tr class='rowresult1'>\n";
echo "<td class='txt' align='left' width='100%'> $jobs_description</td>";
echo "<td class='txt' align='right'><input name='jobs_comment' style='width: 50px;'></td>";
echo "<td class='txt' valign='top' align='center'><input name='checkbox[]' type='checkbox' id='checkbox[]' value='$jobs_id'></td>";
echo "</tr>\n";
$i++;
}else{
echo "<tr class='rowresult2'>\n";
echo "<td class='txt' align='left' width='100%'> $jobs_description</td>";
echo "<td class='txt' align='right'><input name='jobs_comment' style='width: 50px;'></td>";
echo "<td class='txt' valign='top' align='center'><input name='checkbox[]' type='checkbox' id='checkbox[]' value='$jobs_id'></td>";
echo "</tr>\n";
$i++;
}
}
echo "</table></form>\n";
}Code: Select all
Well... i have no real code here at the moment as it's chopped up in 100 different things in attempts to get this to work :*(