pixeltrace Posted March 12, 2007 Share Posted March 12, 2007 guys, i need help, i have a form with 2 buttons named repost and close my form has a checkbox wherein if you check it, you can click repost to set the status of the checkbox item to open or you can click the close button to set the checkbox item status to close my problem now is, this result is just being submitted to a common page and i dont know what codes do i need to add to make this thing work below is my codes for the form page <?php session_start(); if (session_is_registered("username")){ include("pagina/my_pagina_class.php"); if(isset($_GET['sort1']) && $_GET['sort1']!='') $sort1 = $_GET['sort1']; else $sort1 = "j_position"; if(isset($_GET['sort2']) && $_GET['sort2']!='') $sort2 = $_GET['sort2']; else $sort2 = "ASC"; $test = new JHpage; $test->sql = "SELECT * FROM job_ads ORDER BY ".$sort1 ." ".$sort2.""; // the (basic) sql statement (use the SQL whatever you like) $result = $test->get_page_result(); // result set $num_rows = $test->get_page_num_rows(); // number of records in result set $nav_links = $test->navigation(" | ", "currentStyle"); // the navigation links (define a CSS class selector for the current link) $nav_info = $test->page_info(); // information about the number of records on page ("to" is the text between the number) $simple_nav_links = $test->back_forward_link(true); // the navigation with only the back and forward links, use true to use images $total_recs = $test->get_total_rows(); // the total number of records ?> <script type="text/JavaScript"> <!-- function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> </script> <table width="100" border="0" cellspacing="0" cellpadding="0"> <tr> <td><img src="../images/spacer.gif" width="6" height="10"></td> <td><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="1049" border="0" cellspacing="2" cellpadding="0"> <tr> <td colspan="13"><form method="get" action="jobmngr.php?id=2"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="799"><span class="text6"> <?php echo " total record found: " .$total_recs; ?> </span></td> <td width="246" align="right" class="text6">sort by : <select name="sort1"> <option value="j_position">name</option> <option value="jobid">ID</option> <option value="date_posted">date</option> </select> <select name="sort2"> <option value="ASC">ASC</option> <option value="DESC">DESC</option> </select> <input type="submit" name="Submit" value="Go" /> </td> </tr> </table> </form></td> </tr> <form action="changestatus.php" method="post"> <tr> <td colspan="13"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="60%" align="left" class="text8"> <input type="submit" name="Submit2" value="repost"> <input type="submit" name="Submit3" value="close" /></td> <td width="39%" align="right"><!-- nav top --> <? echo "<span class='link1'>".$nav_links."</span>"; ?> </td> <td width="1%" align="right"><img src="images/spacer.gif" width="12" height="10" /></td> </tr> </table></td> </tr> <tr> <td width="29" align="center" bgcolor="#83C2ED" class="text5"> </td> <td width="51" align="center" bgcolor="#83C2ED" class="text5">ID</td> <td width="230" align="center" valign="top" bgcolor="#83C2ED" class="text5">title</td> <td width="140" align="center" bgcolor="#83C2ED" class="text5">level </td> <td width="254" align="center" bgcolor="#83C2ED" class="text5">client</td> <td width="25" align="center" bgcolor="#83C2ED" class="text5">N</td> <td width="25" align="center" bgcolor="#83C2ED" class="text5">C</td> <td width="25" align="center" bgcolor="#83C2ED" class="text5">S</td> <td width="25" align="center" bgcolor="#83C2ED" class="text5">I</td> <td width="24" align="center" bgcolor="#83C2ED" class="text5">B</td> <td width="28" align="center" bgcolor="#83C2ED" class="text5">CV</td> <td width="60" align="center" bgcolor="#83C2ED" class="text5">status</td> <td width="105" bgcolor="#83C2ED"> </td> </tr> <?php for ($i = 0; $i < $num_rows; $i++) { $jobid = mysql_result($result, $i, "jobid"); $j_position = mysql_result($result, $i, "j_position"); $level = mysql_result($result, $i, "level"); $c_name = mysql_result($result, $i, "c_name"); $cperson = mysql_result($result, $i, "cperson"); $nconsidered = mysql_result($result, $i, "nconsidered"); $considered = mysql_result($result, $i, "considered"); $scheduled = mysql_result($result, $i, "scheduled"); $interviewed = mysql_result($result, $i, "interviewed"); $blocked = mysql_result($result, $i, "blocked"); $cv = mysql_result($result, $i, "cv"); $j_status = mysql_result($result, $i, "j_status"); ?> <tr> <td bgcolor="#FFFFCC" class="text8"><span class="text5"> <input type="checkbox" name="checkbox[]" value="<? echo"jobid"; ?>" /> </span></td> <td bgcolor="#FFFFCC" class="text8">J<? echo ($jobid <= 9) ? $jobid : $jobid;?> </td> <td bgcolor="#FFFFCC"> <a href="javascript:;" class="link1" onClick="MM_openBrWindow('../jobsearch/jobpost.php?jobid=<? echo "$jobid"; ?>','','scrollbars=yes,width=720,height=700')"> <? echo "$j_position";?></a></td> <td bgcolor="#FFFFCC" class="text8"> <? echo "$level";?> </td> <td bgcolor="#FFFFCC" class="text8"> <? echo "$c_name";?><br> <i><? echo "$cperson";?></i></td> <td bgcolor="#FFFFCC" class="text8"> <? echo "$nconsidered";?></td> <td bgcolor="#FFFFCC" class="text8"> <? echo "$considered";?></td> <td bgcolor="#FFFFCC" class="text8"> <? echo "$scheduled";?></td> <td bgcolor="#FFFFCC" class="text8"> <? echo "$interviewed";?></td> <td bgcolor="#FFFFCC" class="text8"> <? echo "$blocked";?></td> <td bgcolor="#FFFFCC" class="text8"> <? echo "$cv";?></td> <td bgcolor="#FFFFCC" class="text8"> <? echo "$j_status";?></td> <? echo "<td align='center' bgcolor='#FFFFCC'><a href='jobmngr.php?id=3&jobid=$jobid' class='link1'>edit</a> | <a href='jobmngr.php?id=4&jobid=$jobid' class='link1'>applications</a> </td></tr>"; ?> <? } ?> <tr> <td colspan="13" bgcolor="#83C2ED"><img src="../images/spacer.gif" width="10" height="2" /></td> </tr> <tr> <td colspan="13"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="60%" align="left" class="text8"> </td> <td width="39%" align="right"><!-- nav top --> <? echo "<span class='link1'>".$nav_links."</span>"; ?> </td> <td width="1%" align="right"><img src="images/spacer.gif" width="12" height="10" /></td> </tr> </table></td> </tr> </form> <tr> <td colspan="13"> </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></td> <td><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>"; } ?> my check box is named as checkbox[] since you can select as many items as you like and this is the code in my changestatus.php page <?php session_start(); if (session_is_registered("username")){ $checkbox = implode("\n", $_POST['checkbox']); $staff_updated = $_POST['username']; include '../db_connect.php'; $special = $_POST['specialization']; foreach($special as $key=>$val){ //print "$key".$val; $sql="UPDATE job_ads SET j_status = open WHERE jobid LIKE '%". $val ."%'"; mysql_query($sql) or die("error:".mysql_error()); echo '<script language=javascript> alert("jobs has been updated by '.$staff_updated.'!");top.location = "../jobmngr.php?id=2&type=1";</script>'; }else{ echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='index.php'>Login</a></font>"; } ?> i was only able to set condition for the open status but i dont know how to do it for the close status. need help on this. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/42332-need-help-on-form-with-2-submit-button/ Share on other sites More sharing options...
pixeltrace Posted March 12, 2007 Author Share Posted March 12, 2007 sorry, this is the code for my changestatus.php <?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>"; } $checkbox = implode("\n", $_POST['checkbox']); $staff_updated = $_POST['username']; include '../db_connect.php'; $check = $_POST['checkbox']; foreach($check as $key=>$val){ //print "$key".$val; $sql="UPDATE job_ads SET j_status = open WHERE jobid LIKE '%". $val ."%'"; mysql_query($sql) or die("error:".mysql_error()); echo '<script language=javascript> alert("jobs has been updated by '.$staff_updated.'!");top.location = "../jobmngr.php?id=2&type=1";</script>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/42332-need-help-on-form-with-2-submit-button/#findComment-205360 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.