TimUSA Posted January 15, 2008 Share Posted January 15, 2008 I am starting to dread coming here for help.....rrrfff whats wrong here with my update code?: global $scripturl , $context; echo' <a href="http://vsk-ayc.totalh.com/index.php?page=221">RETURN TO THE START PAGE</a><br> <table class = "bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <tr class ="catbg"> <td width = "100%">Recent Race Reports:</td> </tr> </table> <form action="'.$scripturl.'?page=221'.$GET['page'].'" method="post"> <input id="submitted" name="submitted" type="hidden" value="TRUE" />'; $raceq = "SELECT race_table.raceID, race_table.raceDate, race_table.hostName, race_table.boatsInRace, race_table.seriesID, series_table.seriesName, race_table.factor , race_screenshots_table.imageURL, race_table.approved FROM race_table LEFT JOIN series_table ON race_table.seriesID = series_table.seriesID LEFT JOIN race_screenshots_table ON race_table.raceID = race_screenshots_table.raceID ORDER BY raceID DESC;"; $result = mysql_query($raceq); while($row = mysql_fetch_array($result)) { $raceID = $row['raceID']; echo '<br /> <table class="bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <tr class ="catbg"> <td>Race ID:</td> <td>Date:</td> <td>Host Name:</td> <td>Boats:</td> <td>Series Name:</td> <td>Factor</td> <td>Image URL:</td> <td>Approved</td> </tr> <tr class="catbg4"> <td width="10%">' . $row['raceID'] . '</td> <td width="10%">' . $row['raceDate'] . '</td> <td width="20%">' . $row['hostName'] . '</td> <td width="10%">' . $row['boatsInRace'] . '</td> <td width="20%">' . $row['seriesName'] . '</td> <td width="5%">' . $row['factor'] . '</td> <td width="20%"> <a href="javascript:void(window.open(\'' . $row['imageURL'] .'\',\'\',\' resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no, fullscreen=no,dependent=no,width=1024,height=768\'))">VIEW IMAGE</a></td>'; if ($context['allow_admin'] AND $row['approved'] != "Yes") { echo' <td width = "5%"> <select id="approved" name="approved" style="WIDTH: 50px" value ="" /> <option value="Yes">Yes</option> <option value="No">No</option></td> </tr> </table> <table class = "bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <TR class ="windowbg3"> <td width = "20%">Skipper Name</td> <td width = "20%">Position</td> <td width = "20%">Race Points</td> <td width = "20%">Match Points</td> <td width = "20%">Fleet Points</td> </tr> </table>'; } else echo' <td width = "5%">' . $row['approved'] . '</td> </tr> </table> <table class = "bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <TR class ="windowbg3"> <td width = "20%">Skipper Name</td> <td width = "20%">Position</td> <td width = "20%">Race Points</td> <td width = "20%">Match Points</td> <td width = "20%">Fleet Points</td> </tr> </table>'; $ptsq = "SELECT race_table.raceID , pts_table.skipperName, pts_table.position, pts_table.racePoints , pts_table.matchPoints , pts_table.fleetPoints FROM pts_table LEFT OUTER JOIN race_table ON pts_table.raceID = race_table.raceID WHERE race_table.raceID = '$raceID' GROUP BY pts_table.skipperName, race_table.raceID ORDER BY race_table.raceID, pts_table.racePoints DESC LIMIT 0 , 30;"; $result2 = mysql_query($ptsq); while($row2 = mysql_fetch_array($result2)) { echo' <TABLE class = "bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <TR class ="windowbg3"> <TD width = "20%">' . $row2['skipperName'] . '</td> <TD width = "20%">' . $row2['position'] . '</td> <TD width = "20%">' . $row2['racePoints'] . '</td> <TD width = "20%">' . $row2['matchPoints'] . '</td> <TD width = "20%">' . $row2['fleetPoints'] . '</td> </tr> </table>'; } } if ($context['allow_admin']) { echo' <br> <table class = "bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <tr class ="catbg"> <td>Submit Approvals:</td> </tr> </table> <br> <table> <tr> <INPUT type="submit" value="Submit"><INPUT type="reset" value="Reset"> </tr> </table> </form>'; } if (isset($_POST['submitted'])) { while (isset($_POST['approved'])) { echo $_POST['approved']; $approved = mysql_real_escape_string($_POST['approved']); mysql_query ("UPDATE race_table.approved SET race_table.approved = '$approved' WHERE race_table.raceID = '$raceID';"); } } Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted January 15, 2008 Share Posted January 15, 2008 I've no idea. What does it do? What doesn't it do? What's it supposed to do? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted January 15, 2008 Share Posted January 15, 2008 Try changing this bit: if (isset($_POST['submitted'])) { while (isset($_POST['approved'])) { echo $_POST['approved']; $approved = mysql_real_escape_string($_POST['approved']); mysql_query ("UPDATE race_table.approved SET race_table.approved = '$approved' WHERE race_table.raceID = '$raceID';"); } } To: if (isset($_POST['submitted'])) { while (isset($_POST['approved'])) { echo $_POST['approved']; $approved = mysql_real_escape_string($_POST['approved']); mysql_query ("UPDATE race_table SET race_table.approved = '$approved' WHERE race_table.raceID = '$raceID';"); } } Quote Link to comment Share on other sites More sharing options...
teng84 Posted January 15, 2008 Share Posted January 15, 2008 like what is always being mentioned here put a die on your query and put mysql error to know what is the error and your update.. mysql_query ("UPDATE race_table.approved SET race_table.approved = '$approved' WHERE race_table.raceID = '$raceID';"); dont know if that valid because race_table.approved should be databasename.tablename.. so this should be mysql_query ("UPDATE race_table SET race_table.approved = '$approved' WHERE race_table.raceID = '$raceID';"); nah ken is so fast.. Quote Link to comment Share on other sites More sharing options...
TimUSA Posted January 15, 2008 Author Share Posted January 15, 2008 something in this code is causing a max question overload:( Quote Link to comment Share on other sites More sharing options...
TimUSA Posted January 15, 2008 Author Share Posted January 15, 2008 when i try this if (isset($_POST['submitted'])) { while (isset($_POST['approved'])) { echo $_POST['approved']; $approved = mysql_real_escape_string($_POST['approved']); mysql_query ("UPDATE race_table SET race_table.approved = '$approved' WHERE race_table.raceID = '$raceID';// or die ("Could not execute query");"); } } Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted January 15, 2008 Share Posted January 15, 2008 Why did you comment out the ending? if (isset($_POST['submitted'])) { while (isset($_POST['approved'])) { echo $_POST['approved']; $approved = mysql_real_escape_string($_POST['approved']); mysql_query ("UPDATE race_table SET race_table.approved = '$approved' WHERE race_table.raceID = '$raceID'") or die ("Could not execute query"); } } Quote Link to comment Share on other sites More sharing options...
TimUSA Posted January 15, 2008 Author Share Posted January 15, 2008 cause I am still learning Quote Link to comment Share on other sites More sharing options...
KrisNz Posted January 15, 2008 Share Posted January 15, 2008 while (isset($_POST['approved'])) Wont this cause an infinite loop??? Where are you unsetting $_POST['approved']. Actually you should just get rid of that while bit altogether (not the code between the braces obviously) Quote Link to comment Share on other sites More sharing options...
TimUSA Posted January 15, 2008 Author Share Posted January 15, 2008 would this accomplish the same thing? if (isset($_POST['submitted'])) { if (isset($_POST['approved'])) { $approved = mysql_real_escape_string($_POST['approved']); mysql_query ("UPDATE race_table SET race_table.approved = '$approved' WHERE race_table.raceID = '$raceID'") or die ("Could not execute query"); } } Quote Link to comment Share on other sites More sharing options...
KrisNz Posted January 15, 2008 Share Posted January 15, 2008 Yes, but you might as well make it part of the first condition... if (isset($_POST['submitted']) and isset($_POST['approved'])) { Quote Link to comment Share on other sites More sharing options...
TimUSA Posted January 15, 2008 Author Share Posted January 15, 2008 next question: how do i get it to approve each ID that was marked in the loop above? Quote Link to comment 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.