Page 1 of 1

mark record read??

Posted: Tue Feb 17, 2004 2:47 pm
by melindaSA
I have an online job application that has an admin section where the HR admin can see all applications that have been submitted online. What I want to do is allow the HR admin to select a checkbox when the application has been read and printed.

Here is my code:

Code: Select all

<?php
$query = "SELECT * from application ORDER by appID DESC";

$result = mysql_query($query)
        or die ("could not execute query");

echo "<table>\n";
echo "<tr align="left"><th width="40"><font face="Verdana" size="1"><b>Printed</b></font></th>
      <tr align="left"><th width="120"><font face="Verdana" size="1"><b>Applicant Name</b></font></th>
      <th width="120"><font face="Verdana" size="1"><b>Position Applied</b></font></th>
      <th width="120"><font face="Verdana" size="1"><b>Application</b></font></th>
      <th width="120"><font face="Verdana" size="1"><b>Date</b></font></th>
      <th width="80"><font face="Verdana" size="1"><b>Resume</b></font></th>
      <th width="80"><font face="Verdana" size="1"><b>Delete</b></font></th></tr>\n";
      

while ( $row = mysql_fetch_array($result))
{
   extract($row);
   echo "<tr>\n";
   echo "<td width="40"><input type="checkbox" name="C1" value="ON"><br></td>\n";
   echo "<td width="120"><font face="Verdana" size="1">$first_name $last_name</font><br></td>\n";
   echo "<td width="120"><font face="Verdana" size="1">$position_apply</font><br></td>\n";
   echo "<td width="120"><font face="Verdana" size="1"><a href="../show_app.php?appID=$appID" target="_blank">view application</a></font><br></td>\n";
   echo "<td width="120"><font face="Verdana" size="1">$date</font><br></td>\n";

if(file_exists("../resume/".$first_name.$last_name.".doc")){
echo "<td width="80"><font face="Verdana" size="1"><a href="../resume/".$first_name.$last_name.".doc">Yes</a></font><br></td>\n";
} else {

echo "<td width="80"><font face="Verdana" size="1">No</font><br></td>\n";
}
echo "<td width="120"><font face="Verdana" size="1"><a href="../delete_app.php?appID=$appID" target="_blank">delete</a></font><br></td>\n";

}
   echo "</tr></table>\n";

?>
My problem is that I have no clue how to make the

Code: Select all

&lt;input type="checkbox" name="C1" value="ON"&gt;
work??

-How do I submit this to the database without a submit button?
-How do I put this checkbox into a form?or do I need to

Maybe I am going about this the wrong way, I would appreciate any help on this!

Thank you!!

Posted: Tue Feb 17, 2004 4:24 pm
by tim
Hello again:

By the prev post I helped with, I assume $AppID is a var that gives each application its own special idenification number, am I correct?

If so, you need to make the check boxes form a array of the applications so numerous apps can be passed at a time (if you check more than one checkbox so to say) I will have to kill one of your request about not wanting a submit buttom, but this will work for you as you want.

The solution: Make a confirm.php to validate and process the request made by the checkboxes, make your checkboxes like so:

Code: Select all

<?php
<form action=confirm.php?$data method=POST><input type=checkbox name=data[] value=$AppID>
//Now after you display your loop, add this submit butto
<input type=submit value=data></form>";
?>
if you'll notice, the [] will arrange the checked apps into a array for multiple processing at one time

now confirm.php code:

Code: Select all

<?php
if(isset($data)) {
foreach($data as $AppID) {
$del = "DELETE FROM table WHERE AppID=$AppID";
mysql_query($del);
echo "All the Applications that were checked have been deleted";
echo "<script language=javascript>location.replace('wherever you want to go.php')</script>";
 }

?>
Now this will delete the records, what did you want done with them after you checked them? I didnt get that, so I just created code that will delete them after checked, feel free to modify to your own terms.

kudos

Posted: Tue Feb 17, 2004 4:29 pm
by dethron
When does an application become "read" or "printed"?


Is this link to read the application?
<a href=\"../show_app.php?appID=$appID\" target=\"_blank\">view application</a>

Then send one more variable to understand the file (show_app.php) is requested from this table (where applications are listed.)

And of course do that if you request the file (show_app.php) from other pages.

Then put an update(SQL) statement to the top of this page. Set an flag value to 1 to mean that application has been read.

Hope this help.

Posted: Wed Feb 18, 2004 8:10 am
by melindaSA
Thank you Tim and Dethron!

The application becomes read or printed when the HR admin has manually read or printed the application.

Yes, this is the link to the application.

I will try what you suggest and luckly this is the only page that the application can be requested.

One more question, how do I set flag value to 1??

Thanks again,

Posted: Wed Feb 18, 2004 11:05 am
by dethron
Just add one more field to the application table.

So all applications have a status (default zero means unread).

When an application details are viewed by admin set this field to 1 (means that it is read).

And do that by

Code: Select all

<?php
$sql = "UPDATE application SET STATUS=1";
$sql_result = mysql_query($sql,$connection);
// I assume you connected to db
?>