Haroskyline Posted May 20, 2009 Share Posted May 20, 2009 Alright, so here is what I'm trying to do. There is a page that shows a selection box to select a certain student. Each student has one or more services associated with them. When you select the service it goes to another page, one that displays the services that the selected child has. The Problem: When you select the service for the selected student that you with to update. It just goes back to the previous page that has the huge selection box of children. So somewhere in the code, which I'm trying to figure out, it isn't working. This is the index file associated with the update services page. /*{{{ Update Services */ // if ($_GET['serv'] == 2) case $_GET['serv'] == 2: // { if (isset($_POST['save']) && (!isset($_POST['service']))) { $query = "UPDATE services SET "; $query .= "ssn=".$_POST['ssn']; $query .= ", fhr=".$_POST['fhr']; $query .= ", service=".$_POST['services']; $query .= ", vendor=".$_POST['provider']; $beg = substr($_POST['begin'],4,4).substr($_POST['begin'],0,4); $query .= ", begin=".$beg; $end = substr($_POST['end'],4,4).substr($_POST['end'],0,4); $query .= ", end=".$end; $query .= ", days=".$_POST['days']; $query .= ", sessions=".$_POST['sessions']; $query .= ", amt=".$_POST['amount']; $query .= ", funded='".$_POST['funded']."'"; $query .= ", site=".$_POST['site']; $query .= ", schoolyear=".$_POST['schoolyear']; if ($_POST['stac'] == "Y") $query .= ", stac3=1"; else $query .= ", stac3=0"; $query .= " WHERE ssn=".$_POST['ssn']; $db->query($query); $upd = mysql_query($query); if (!$upd) $er->display_error(5,$query); // Update error else { print "<br /><br />"; print "<div style=\"text-align: center; background-color: #FFFFFF; margin: 0px; padding: 0px; border: 2px solid #CCCCCC; border-spacing: 0px; border-collapse: collapse; width: 70%; margin-left: auto; margin-right: auto;\">"; print "<div style=\"background-color: #f5f5f5; border: solid 1px #d5d5d5; padding: 1px 1px 1px 1px; border-collapse: collapse;\">"; print "<h1 align=\"center\">Update Child's Services</h1>"; print "</div>"; print "<br /><br /><h2 align=\"center\">Record successfully updated.</h2>"; print "<br />"; print "<form name=\"update\" method=\"post\" action=\"index.php?serv=2\"><input type=\"submit\" value=\"New Selection\"></form>"; print "<br /><br />"; print "</div>"; } } else { include "include/updateserv.inc.php"; } // } break; /*}}}*/ } //} break; /*}}}*/ The included page updateserv.ini.php (Probably where the problem is) It's just a snippet where the update is told what to do: <?PHP $cnt = $db->get_results("SELECT id,service,vendor,ssn,sessions FROM services WHERE ssn = $oldssn"); $x = 1; foreach($cnt as $key) { $ser = $db->get_var("SELECT service FROM serviceslookup WHERE code=".$key->service); $ven = $db->get_var("SELECT vendor_name FROM vendor WHERE vendor = ".$key->vendor); print "\t\t\t<tr>\n\t\t\t\t<td align=\"center\"><input type=\"radio\" name=\"service\" value=\"".$key->service.'-'.$key->id."\"></td>\n"; print "\t\t\t\t<td style=\"padding: 3px 3px 3px 3px;\">$ser</td>\n"; print "\t\t\t\t<td style=\"padding: 3px 3px 3px 3px;\">$ven</td>\n\t\t\t</tr>\n"; $x++; } print "\t\t</table></center>\n"; print "\t\t<br /><center>\n"; print "\t\t\t<input type=\"submit\" name=\"save\" value=\"Update\">\n"; print "\t\t\t<input type=\"reset\" name=\"reset\" value=\"Reset\">\n"; print "\t\t</center>\n"; print "\t\t</form>\n</body>\n</html>\n"; exit(); } else { if (isset($_POST['service'])) { $results = $db->get_results("SELECT * FROM services WHERE ((ssn = $oldssn) and (service = ".$_POST['service'].") and (id = $oldid))",OBJECT); } else { $results = $db->get_results("SELECT * FROM services WHERE ssn = $oldssn",OBJECT); } } foreach ($results as $info) { ?><!--}}}--> I'm honestly not sure what's doing it. Perhaps something isn't matching correctly? Link to comment https://forums.phpfreaks.com/topic/158941-solved-selecting-a-bullet-to-select-a-service-the-page-goes-back-to-the-selection/ Share on other sites More sharing options...
Haroskyline Posted May 20, 2009 Author Share Posted May 20, 2009 Heres another part that may have to do with it, this is also from the updateserv.inc.php, but in the beginning of the code. <?PHP if ((!isset($_POST['sssn'])) or (isset($_POST['newselect']))) { include "include/select_service1.inc.php"; exit(); } $oldssn = $_POST['sssn']; $oldserv = substrpos($_POST['service'], 0, '\-'); $oldid = substr(substrpos($_POST['service'], '\-', 10),1); $result = $db->get_results("SELECT fname, mname, lname FROM childdemo WHERE ssn = $oldssn",OBJECT); foreach ($result as $child) { $name = $child->fname; $name .= ($child->mname == NULL) ? "" : " ".$child->mname.""; $name .= " ".$child->lname; } $cnt = $db->get_var("SELECT count(*) FROM services WHERE ssn = $oldssn"); if ($cnt ==0) include "include/no_rec_found.inc.php"; if (($cnt > 1) && (!isset($_POST['service']))) { ?> Link to comment https://forums.phpfreaks.com/topic/158941-solved-selecting-a-bullet-to-select-a-service-the-page-goes-back-to-the-selection/#findComment-838317 Share on other sites More sharing options...
Haroskyline Posted May 20, 2009 Author Share Posted May 20, 2009 This is the part of updateserv.inc.php where you select the child. Once you select a child, it lists the services the child has. Once you select the service, it just goes back to the child selection part of updateserv.inc.php It SHOULD go to the update service page once you select the service, but it just goes back to the child selection. :\ Link to comment https://forums.phpfreaks.com/topic/158941-solved-selecting-a-bullet-to-select-a-service-the-page-goes-back-to-the-selection/#findComment-838343 Share on other sites More sharing options...
Ken2k7 Posted May 20, 2009 Share Posted May 20, 2009 Can you post the form for slide 2? Link to comment https://forums.phpfreaks.com/topic/158941-solved-selecting-a-bullet-to-select-a-service-the-page-goes-back-to-the-selection/#findComment-838354 Share on other sites More sharing options...
Haroskyline Posted May 21, 2009 Author Share Posted May 21, 2009 Can you post the form for slide 2? Yeah, sure. <br /><br /><br /> <div style="text-align: center; background-color: #FFFFFF; margin: 0px; padding: 0px; border: 2px solid #000180; border-spacing: 0px; border-collapse: collapse; width: 70%; margin-left: auto; margin-right: auto;"> <div style="background-color: #A4C8EE; border: solid 1px #000195; padding: 1px 1px 1px 1px; border-collapse: collapse;"> <h1 align="center">Update A Service For <br /><?PHP echo ($name); ?></h1> </div> </div> <br /> <form name="services" method="post" action="index.php?serv=2"><center> <input type="hidden" name="sname" value="<?PHP echo ($oldssn); ?>"> <table border="1" style="margin: 1em 1em 1em 1em;"> <tr style="background-color: #A4C8EE;"> <th>Select</th> <th width="40%">Service</th> <th width="40%">Vendor</th> </tr> Link to comment https://forums.phpfreaks.com/topic/158941-solved-selecting-a-bullet-to-select-a-service-the-page-goes-back-to-the-selection/#findComment-839100 Share on other sites More sharing options...
Haroskyline Posted May 21, 2009 Author Share Posted May 21, 2009 Oh cool! My boss came in, and we had another look using urlparams, and he noticed that at this part in the form, there was a variable wrong: <input type="hidden" name="sname" value="<?PHP echo ($oldssn); ?>"> I guess "sname" is supposed to be "sssn" <input type="hidden" name="sssn" value="<?PHP echo ($oldssn); ?>"> So now, when you get to slide 2, and you click update, it comes up with an error that says: "Warning: Invalid argument supplied for foreach() in C:\apache\htdocs\3to5\include\updateserv.inc.php on line 74 " Line 74: foreach ($results as $info) So something stated in $results is wrong. (The variable was posted previously) Link to comment https://forums.phpfreaks.com/topic/158941-solved-selecting-a-bullet-to-select-a-service-the-page-goes-back-to-the-selection/#findComment-839167 Share on other sites More sharing options...
Haroskyline Posted May 21, 2009 Author Share Posted May 21, 2009 Ah, crap I got it. I guess $results isn't the array, so if it was put where an array was supposed to be in a foreach() statement, it wouldn't work. So, I replaced it with the $child variable, which I suppose IS an array, and it works. Now I have MORE things to fix now that I got there. Link to comment https://forums.phpfreaks.com/topic/158941-solved-selecting-a-bullet-to-select-a-service-the-page-goes-back-to-the-selection/#findComment-839200 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.