pixeltrace Posted March 14, 2007 Share Posted March 14, 2007 guys, i need help i have a page that displays the total number of items on each column my problem now, when i do some updates, the result is not being reflected to the form its kinda hard to explain, but below is my process page and i will just tell you want i wanted to happen on this page <?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'; $astatus = $_POST['astatus']; $ajid = $_POST['ajid']; $appid = $_POST['appid']; $jobid = $_POST['jobid']; //foreach($checkbo as $key=>$val){ //print "$key".$val; if ($astatus == 'Not Considered'){ $sql1="UPDATE job_ads SET nconsidered = nconsidered - 1 WHERE jobid= '$jobid'"; mysql_query($sql1) or die("error:".mysql_error()); $sql6="UPDATE job_ads SET nconsidered = nconsidered + 1 WHERE jobid= '$jobid'"; mysql_query($sql6) or die("error:".mysql_error()); } elseif ($astatus = 'Considered'){ $sql2="UPDATE job_ads SET considered = considered - 1 WHERE jobid= '$jobid'"; mysql_query($sql2) or die("error:".mysql_error()); $sql7="UPDATE job_ads SET considered = considered + 1 WHERE jobid= '$jobid'"; mysql_query($sql7) or die("error:".mysql_error()); } elseif ($astatus = 'Scheduled'){ $sql3="UPDATE job_ads SET scheduled = scheduled - 1 WHERE jobid= '$jobid'"; mysql_query($sql3) or die("error:".mysql_error()); $sql8="UPDATE job_ads SET scheduled = scheduled + 1 WHERE jobid= '$jobid'"; mysql_query($sql8) or die("error:".mysql_error()); } elseif ($astatus = 'Interviewed'){ $sql4="UPDATE job_ads SET interviewed = interviewed - 1 WHERE jobid= '$jobid'"; mysql_query($sql4) or die("error:".mysql_error()); $sql9="UPDATE job_ads SET interviewed = interviewed + 1 WHERE jobid= '$jobid'"; mysql_query($sql9) or die("error:".mysql_error()); } elseif ($astatus = 'Blacklisted'){ $sql5="UPDATE job_ads SET blocked = blocked - 1 WHERE jobid= '$jobid'"; mysql_query($sql5) or die("error:".mysql_error()); $sql10="UPDATE job_ads SET blocked = blocked + 1 WHERE jobid= '$jobid'"; mysql_query($sql10) or die("error:".mysql_error()); } $sql="UPDATE applicantjob SET a_status = '$astatus' WHERE ajid= '$ajid'"; mysql_query($sql) or die("error:".mysql_error()); echo '<script language=javascript> alert("job application has been updated!");top.location = "details.php?id=1&appid='.$appid.'&ajid='.$ajid.'";</script>'; ?> normally, i have a "astatus" radio button in my first page with values Not Considered Considered Scheduled Interviewed Blacklisted so on that page when i update let say the current value is "blacklisted" if i update it and change it to "considered" and value of "1" should be added to the field of "considered" field in my job_ads table and it will subtract "1" from "blocked" field in my job_ads table. same goes with the other conditions what is happening now in my current codes is, its not working and the vaules are still the same or hasnt changed at all hope you could help me with this thanks so much!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/42647-need-help-on-my-update-form/ Share on other sites More sharing options...
monk.e.boy Posted March 14, 2007 Share Posted March 14, 2007 I'm not sure, but I didn't think you could do: UPDATE job_ads SET nconsidered = nconsidered + 1 WHERE jobid= '$jobid'" in sql. Maybe this would work: UPDATE job_ads SET nconsidered = (SELECT nconsidered+1 FROM job_ads WHERE jobid= '$jobid') WHERE jobid= '$jobid'" if this don't work, just run two sql commands, one to select the val, then one to set the val. monk.e.boy Quote Link to comment https://forums.phpfreaks.com/topic/42647-need-help-on-my-update-form/#findComment-206979 Share on other sites More sharing options...
pixeltrace Posted March 14, 2007 Author Share Posted March 14, 2007 any help for this one please? its still not working. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/42647-need-help-on-my-update-form/#findComment-207014 Share on other sites More sharing options...
monk.e.boy Posted March 14, 2007 Share Posted March 14, 2007 does your sql work? monk.e.boy Quote Link to comment https://forums.phpfreaks.com/topic/42647-need-help-on-my-update-form/#findComment-207060 Share on other sites More sharing options...
pixeltrace Posted March 15, 2007 Author Share Posted March 15, 2007 hi, no, its not working. the last sql query that i have $sql="UPDATE applicantjob SET a_status = '$astatus' WHERE ajid= '$ajid'"; mysql_query($sql) or die("error:".mysql_error()); is working but the rest of the sql queries are not working maybe there just something wong with my if else conditions or maybe with my queries need help please Quote Link to comment https://forums.phpfreaks.com/topic/42647-need-help-on-my-update-form/#findComment-207697 Share on other sites More sharing options...
pixeltrace Posted March 15, 2007 Author Share Posted March 15, 2007 help please Quote Link to comment https://forums.phpfreaks.com/topic/42647-need-help-on-my-update-form/#findComment-207777 Share on other sites More sharing options...
monk.e.boy Posted March 15, 2007 Share Posted March 15, 2007 did you try the queries I suggested? monk.e.boy Quote Link to comment https://forums.phpfreaks.com/topic/42647-need-help-on-my-update-form/#findComment-207887 Share on other sites More sharing options...
AndyB Posted March 15, 2007 Share Posted March 15, 2007 Can you explain the logic of your code? It appears that for each condition you decrement a database value then increment it, i.e. the net result is no change. What isn't working? Quote Link to comment https://forums.phpfreaks.com/topic/42647-need-help-on-my-update-form/#findComment-207890 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.