pixeltrace Posted March 10, 2007 Share Posted March 10, 2007 guys, i need help, i have 2 tables specialization and applicant table both on the same database i have a resume application form and on that form i have a selectbox wherein the user can select as many specialization that he/she wanted on the process page, those items are being imploded and inserted into the applicant table i have a page that list down all the specialization items from specialization table and it has a area there that shows the total number of applicant that falls on the specific specialization the field name of specialization from the specialization table and applicant table is the same my problem now is, how do i set in the other page that will show the total number of applicants that falls on that specific specialization below is my codes for the specialization page <? include 'db_connect.php'; $uSql = "SELECT * FROM specialization"; $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found'; }else{ while($uRow = mysql_fetch_array($uResult)){ ?> <tr> <td width="4" align="left" valign="top" class="text6"><img src="images/spacer.gif" width="4" height="10" /></td> <td width="536" align="left" valign="top" class="text6">» <?= $uRow[specialization]?> <a href="rlist.php?specialization=$specialization" class="link2">[<?= $uRow[hits]?>]</a></td> </tr> <? } } ?> and from my form page, this is the code that process my form <? session_start(); if (session_is_registered("username")){ }else{ echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='../index.php'>Login</a></font>"; } include '../db_connect.php'; $email = $_POST['email']; $fname = $_POST['fname']; $lname = $_POST['lname']; $dayregistered = $_POST['dayregistered']; $monthregistered = $_POST['monthregistered']; $yearregistered = $_POST['yearregistered']; $specialization = implode("\n", $_POST['specialization']); $level = $_POST['level']; $resume = $_POST['resume']; // 0000-00-00 $dateregistered = $yearregistered.'-'.$monthregistered.'-'.$dayregistered; //email verification 2 $sql_username_check = mysql_query("SELECT username FROM applicant WHERE email='$email'"); $username_check = mysql_num_rows($sql_username_check); if($username_check > 0){ echo '<script language=javascript> alert("Email is already used!");history.back() = "../resumemngr.php?id=1";</script>'; unset($username); exit(); } $email = stripslashes($email); $fname = stripslashes($fname); $lname = stripslashes($lname); $dateregistered = stripslashes($dateregistered); $specialization = stripslashes($specialization); $level = stripslashes($level); $resume = mysql_real_escape_string(stripslashes($_POST['resume'])); $sql = mysql_query("INSERT INTO applicant (email, username, fname, lname, dateregistered, specialization, level, resume ) VALUES('$email', '$email', '$fname', '$lname', '$dateregistered', '$specialization', '$level', '$resume')") or die (mysql_error()); if(!$sql){ echo '<script language=javascript> alert("Error adding candidate");history.back() = "../resumemngr.php?id=1";</script>'; exit(); } else { $appid = mysql_insert_id(); echo '<script language=javascript> alert("New candidate has been added!");top.location = "../resumemngr.php?id=1";</script>'; } ?> what codes do i need to add so that my process page will also update my specialization page with the items added base from the specialization that they selected. hope you could help me with this. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/42111-need-help-on-adding-items-on-2-different-tables/ Share on other sites More sharing options...
pixeltrace Posted March 10, 2007 Author Share Posted March 10, 2007 this is the code for my application submit page <? session_start(); if (session_is_registered("username")){ ?> <table width="100" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="6" align="left"><img src="../images/spacer.gif" width="6" height="10" /></td> <td width="100%"><form action="resume/addresume.php" method="post" enctype="multipart/form-data"> <table width="216" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td> </tr> <tr> <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td> <td width="214" valign="top"><table width="558" border="0" cellspacing="2" cellpadding="3"> <tr> <td colspan="3" valign="top"><img src="images/spacer.gif" width="10" height="1" /></td> </tr> <tr> <td colspan="3" bgcolor="#999999" class="text2">ADD CANDIDATE RESUME </td> </tr> <tr> <td colspan="3" valign="top" class="text7">* please fill-up every item on this form </td> </tr> <tr> <td width="119" align="right" valign="top" class="text6">Email :</td> <td> </td> <td width="412" class="text7"><input type="text" name="email" class="textfield"></td> </tr> <tr> <td align="right"><span class="text6">Date of registered : </span></td> <td> </td> <td><span class="text7"> <select name="dayregistered" class="textfield"> <option value="<? echo date('d'); ?>" selected><? echo date('d'); ?></option> <option value='1'>1</option> <option value='2'>2</option> <option value='3'>3</option> <option value='4'>4</option> <option value='5'>5</option> <option value='6'>6</option> <option value='7'>7</option> <option value='8'>8</option> <option value='9'>9</option> <option value='10'>10</option> <option value='11'>11</option> <option value='12'>12</option> <option value='13'>13</option> <option value='14'>14</option> <option value='15'>15</option> <option value='16'>16</option> <option value='17'>17</option> <option value='18'>18</option> <option value='19'>19</option> <option value='20'>20</option> <option value='21'>21</option> <option value='22'>22</option> <option value='23'>23</option> <option value='24'>24</option> <option value='25'>25</option> <option value='26'>26</option> <option value='27'>27</option> <option value='28'>28</option> <option value='29'>29</option> <option value='30'>30</option> <option value='31'>31</option> </select> <select name="monthregistered" class="textfield"> <option value="<? echo date('n'); ?>" selected><? echo date('M'); ?></option> <option value='1'>Jan</option> <option value='2'>Feb</option> <option value='3'>Mar</option> <option value='4'>Apr</option> <option value='5'>May</option> <option value='6'>Jun</option> <option value='7'>Jul</option> <option value='8'>Aug</option> <option value='9'>Sep</option> <option value='10'>Oct</option> <option value='11'>Nov</option> <option value='12'>Dec</option> </select> <select name="yearregistered" class="textfield"> <option value="<? echo date('Y'); ?>" selected><? echo date('Y'); ?></option> <?php for($i=2001; $i<=date("Y"); $i++){ print '<option value="'.$i.'"'; if($yearText == $i){ print '>'.$i.'</option>'; } } ?> </select> </span></td> </tr> <tr> <td align="right"><span class="text6">Job level :</span></td> <td> </td> <td><span class="text7"> <select name="level"> <option value=""></option> <?php $uSql = "SELECT level FROM level"; $uResult = mysql_query($uSql, $connection); while($uRow = mysql_fetch_array($uResult)){ echo "<option value=\"". $uRow['level'] ."\">". $uRow['level'] ."\n"; } ?> </select> </span></td> </tr> <tr> <td align="right" valign="top" class="text6">Job Specialization : </td> <td align="right" valign="top" class="text6"> </td> <td valign="top" class="text6"> <select name="specialization[]" size="8" class="textfield1" multiple> <? include 'db_connect.php'; $uSql = "SELECT specialization FROM specialization ORDER by sid ASC"; $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found'; } else{ while($uRow = mysql_fetch_row($uResult)){ ?> <option value="<?= $uRow[0]?>"><?= $uRow[0]?></option> <? } } ?> </select> </td> </tr> <tr> <td align="right" valign="top" class="text6"> </td> <td align="right" valign="top" class="text6"> </td> <td valign="top" class="text7">you can select up to 10 preferred specialization<br> * press CTRL then click on the items you wish to select </td> </tr> <tr> <td colspan="3" valign="top" class="text6"><hr></td> </tr> <tr> <td colspan="3" valign="top" class="text6">Resume : <span class="text7"> copy & paste resume here</span> </td> </tr> <tr> <td colspan="3" align="center" valign="top" class="text6"><textarea id="elm1" name="resume" rows="35" cols="80" style="width: 100%"></textarea></td> </tr> <tr> <td colspan="3" align="center" valign="top" class="text6"><input type="submit" name="Submit" value="Add Candidate" class="textfield1" /> <input type="hidden" name="fname" value="Jobhirings"><input type="hidden" name="lname" value="Database"></td> </tr> <tr> <td colspan="3" align="center" valign="top" class="text6"> </td> </tr> </table></td> <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td> </tr> <tr> <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td> </tr> </table> </form></td> <td width="6" align="right"><img src="../images/spacer.gif" width="6" height="10" /></td> </tr> </table> <? }else{ echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='../index.php'>Login</a></font>"; } ?> this is the code for my addresume.php page <? session_start(); if (session_is_registered("username")){ }else{ echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='../index.php'>Login</a></font>"; } include '../db_connect.php'; $email = $_POST['email']; $fname = $_POST['fname']; $lname = $_POST['lname']; $dayregistered = $_POST['dayregistered']; $monthregistered = $_POST['monthregistered']; $yearregistered = $_POST['yearregistered']; $specialization = implode("\n", $_POST['specialization']); $level = $_POST['level']; $resume = $_POST['resume']; // 0000-00-00 $dateregistered = $yearregistered.'-'.$monthregistered.'-'.$dayregistered; //email verification 2 $sql_username_check = mysql_query("SELECT username FROM applicant WHERE email='$email'"); $username_check = mysql_num_rows($sql_username_check); if($username_check > 0){ echo '<script language=javascript> alert("Email is already used!");history.back() = "../resumemngr.php?id=1";</script>'; unset($username); exit(); } $email = stripslashes($email); $fname = stripslashes($fname); $lname = stripslashes($lname); $dateregistered = stripslashes($dateregistered); $specialization = stripslashes($specialization); $level = stripslashes($level); $resume = mysql_real_escape_string(stripslashes($_POST['resume'])); $sql = mysql_query("INSERT INTO applicant (email, username, fname, lname, dateregistered, specialization, level, resume ) VALUES('$email', '$email', '$fname', '$lname', '$dateregistered', '$specialization', '$level', '$resume')") or die (mysql_error()); if(!$sql){ echo '<script language=javascript> alert("Error adding candidate");history.back() = "../resumemngr.php?id=1";</script>'; exit(); } else { $appid = mysql_insert_id(); echo '<script language=javascript> alert("New candidate has been added!");top.location = "../resumemngr.php?id=1";</script>'; } ?> and this is the code for my specialization page $uSql = "SELECT * FROM specialization"; $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found'; }else{ while($uRow = mysql_fetch_array($uResult)){ ?> <tr> <td width="4" align="left" valign="top" class="text6"><img src="images/spacer.gif" width="4" height="10" /></td> <td width="536" align="left" valign="top" class="text6">» <?= $uRow[specialization]?> <a href="rlist.php?specialization=$specialization" class="link2">[<?= $uRow[hits]?>]</a></td> </tr> <? } } ?> notice the uRow[hits]? i want to add a code in my addresume.php page that will add 1 on every specialization selected from my application form page to my specialization page. need help thanks! Quote Link to comment https://forums.phpfreaks.com/topic/42111-need-help-on-adding-items-on-2-different-tables/#findComment-204245 Share on other sites More sharing options...
pixeltrace Posted March 10, 2007 Author Share Posted March 10, 2007 any update on this? need help please thanks! i just need to know what code to add in such a way that it will add (1) on uRow[hits] for every item in the specialization that was selected. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/42111-need-help-on-adding-items-on-2-different-tables/#findComment-204275 Share on other sites More sharing options...
pixeltrace Posted March 11, 2007 Author Share Posted March 11, 2007 help please Quote Link to comment https://forums.phpfreaks.com/topic/42111-need-help-on-adding-items-on-2-different-tables/#findComment-204631 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.