pixeltrace Posted March 12, 2007 Share Posted March 12, 2007 guys, i need help, i have a form wherein once submitted it 1. update table 1 2. insert in table 2 the form has a "specialization" select box wherein you can select multiple items and those items are updating "hits" row in table 1 adding 1 for every item that is being selected. my codes are working if i only select 1 item from the "specialization" select box but the problem comes if i select more that 1 item on the select box. this is the code for my form <form action="resume/addresume.php" method="post" enctype="multipart/form-data"> <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></form> and this is the code in my addresume.php <? 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'])); $hits = $hits+1; $sql="UPDATE specialization SET hits ='$hits' WHERE specialization LIKE '%". $specialization ."%'"; mysql_query($sql) or die("error:".mysql_error()); $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>'; } ?> hope you could help me with this. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/42293-need-help-on-query-update/ Share on other sites More sharing options...
pixeltrace Posted March 12, 2007 Author Share Posted March 12, 2007 help please thanks! Quote Link to comment https://forums.phpfreaks.com/topic/42293-need-help-on-query-update/#findComment-205178 Share on other sites More sharing options...
btherl Posted March 12, 2007 Share Posted March 12, 2007 What happens when you select more than one specialization? And how does that differ from what you expected to happen? Quote Link to comment https://forums.phpfreaks.com/topic/42293-need-help-on-query-update/#findComment-205303 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.