Greysoul Posted January 22, 2011 Share Posted January 22, 2011 seems as if every time i get something working i break something else. i have my main page that i display everything but i also always make a test.php to test things with. anyway...on my main page my check boxes delete fine..but on my new page that i've changed some things on..it doesn't work..1. the array for the delete box to display is the same2. the button is the same3. the query is the samei can't find the problem! ignore any changes with the table and other variables as thats working fine, i was changing some things with the updating porition..its just the deleting portion. whats different between the two?page where delete works <form name='william' method='post' action=''><?php$bills="SELECT * FROM bills WHERE Owner = 'Both' OR Owner = 'William' ORDER BY Owner,DueDate";$result=mysql_query($bills);$count=mysql_num_rows($result);$x=0;while($row = mysql_fetch_array($result)) {$x++;echo "<tr><th class='centerbox'>" . "<input name='checkbox[]' type='checkbox' id='checkbox[]' value='" . $row['ID'] . "'>" . "</th><input type='hidden' size='10' name='id[$x]' class='form' value='" . $row['ID'] . "'><th>" . "<input type='text' size='10' name='wname[$x]' class='form' value='" . $row['Name'] . "'>" . "</th><td>" . "<input type='text' size='10' name='wpa[$x]' class='form' value='$" . $row['ProjAmnt'] . "'>" . "</td><td>" . "<input type='text' size='10' name='waa[$x]' class='form' value='$" . $row['ActAmnt'] . "'>" . "</td><td>" . "<input type='text' size='10' name='wdd[$x]' class='form' value='" . $row['DueDate'] . "'>" . "</td><td>" . "<input type='text' size='10' name='wc[$x]' class='form' value='" . $row['Company'] . "'>" . "</td>";if($row['PayMethod'] != check)echo "<td>" . '<a href="' . $row['PayMethod'] . '" target=_blank>' . 'Website </a>' . "</td></tr>";elseecho "<td>" . "Check" . "</td></tr>";// ++$x; }$billtotals= mysql_query("SELECT SUM(ProjAmnt) AS projected, SUM(ActAmnt) AS actual FROM bills WHERE Owner = 'Both' OR Owner = 'William'");while($row = mysql_fetch_array($billtotals)) {$wbp=$row['projected'];$wba=$row['actual'];echo "<tr><th>" . "<input name='delete' class='button' type='submit' id='delete' value='DEL'>" . "</th><th>" . "Totals" . "</th><td>" . "$" . number_format($row['projected'],2) . "</td><td>" . "$" . $row['actual'] . "</td><th colspan='3' class='buttonbox'>" . "<input name='update' class='button' type='submit' id='update' value='Update'>" . "</th></tr></form>"; } page where it doesn't work <form name='update' method='post' action=''><table><tr><th colspan="2" class="centerbox">William's Bills</th><th colspan="5"> </th></tr><tr><th class='centerbox'><input type="checkbox" name="sAll" onClick="selectAll(this)" /></th><th>Bills</th><th>Project Amt</th><th>Actual Amnt</th><th>Due Date</th><th>Company</th><th>Pymnt Method</th></tr><?php$result = mysql_query("SELECT * FROM bills");$i = 0;while ($bills = mysql_fetch_array($result)) {echo "<input type='hidden' name='id[$i]' value='{$bills['ID']}'>";echo "<tr><th class='centerbox'>" . "<input name='checkbox[]' type='checkbox' id='checkbox[]' value='" . $bills['ID'] . "'>" . "</th><td><input type='text' size='15' class='form' name='name[$i]' value='{$bills['Name']}'></td><td><input type='text' size='15' class='form' name='projamnt[$i]' value='{$bills['ProjAmnt']}'></td><td><input type='text' size='15' class='form' name='actamnt[$i]' value='{$bills['ActAmnt']}'></td><td><input type='text' size='15' class='form' name='duedate[$i]' value='{$bills['DueDate']}'></td><td><input type='text' size='15' class='form' name='company[$i]' value='{$bills['Company']}'></td>";if($bills['PayMethod'] != check)echo "<td>" . '<a href="' . $bills['PayMethod'] . '" target=_blank>' . 'Website </a>' . "</td></tr>";elseecho "<td>" . "Check" . "</td></tr>";++$i;}$billtotals= mysql_query("SELECT SUM(ProjAmnt) AS projected, SUM(ActAmnt) AS actual FROM bills WHERE Owner = 'Both' OR Owner = 'William'");while($row = mysql_fetch_array($billtotals)) {$wbp=$row['projected'];$wba=$row['actual'];echo "<tr><th>" . "<input name='delete' class='button' type='submit' id='delete' value='DEL'>" . "</th><th>" . "Totals" . "</th><td>" . "$" . number_format($row['projected'],2) . "</td><td>" . "$" . $row['actual'] . "</td><th colspan='3' class='buttonbox'>" . "<input name='update' class='button' type='submit' id='update' value='Update'>" . "</th></tr></form>"; } query that works on one page and not the other.. if($delete){$checkbox = $_POST['checkbox'];$delete = $_POST['delete'];for($i=0;$i<$count;$i++){$del_id = $checkbox[$i];$sql = "DELETE FROM bills WHERE ID='$del_id'";$result = mysql_query($sql);}if($result){echo "<meta http-equiv=\"refresh\" content=\"0;URL=test.php\">";}} Link to comment Share on other sites More sharing options...
chokk Posted January 22, 2011 Share Posted January 22, 2011 the value of your "checkbox" is different Link to comment Share on other sites More sharing options...
Greysoul Posted January 22, 2011 Author Share Posted January 22, 2011 how? one uses bills and one uses row..same thing defined i believe..unless you are typing about something else Link to comment Share on other sites More sharing options...
chokk Posted January 22, 2011 Share Posted January 22, 2011 Oh wow I must be tired. I totally missed that. No wonder though, it's 03.47 in the night where I'm at.I'll check it out in greater detail this time Link to comment Share on other sites More sharing options...
Greysoul Posted January 22, 2011 Author Share Posted January 22, 2011 yeah lol. and i mean there's some obvious changes in things, but i'm just not sure what would keep it from functioning..its probably something small left out or something thats stopping it from working that i added Link to comment Share on other sites More sharing options...
Greysoul Posted January 22, 2011 Author Share Posted January 22, 2011 don't like stumping people Link to comment Share on other sites More sharing options...
Greysoul Posted January 22, 2011 Author Share Posted January 22, 2011 fixed, my count variable wasn't up there..FINALLY lol. Link to comment Share on other sites More sharing options...
chokk Posted January 22, 2011 Share Posted January 22, 2011 I'm glad you solved your problem. There's no better feeling than solving a problem that has been haunting you for a while. May I ask why you are leaving out delimiters for your if statements in both pages (line 19 on page 1 and line 33 on page 2)? Link to comment Share on other sites More sharing options...
Greysoul Posted January 23, 2011 Author Share Posted January 23, 2011 I'm glad you solved your problem. There's no better feeling than solving a problem that has been haunting you for a while. May I ask why you are leaving out delimiters for your if statements in both pages (line 19 on page 1 and line 33 on page 2)?i'm sort of a beginner, i don't even know what a delimiter is Link to comment Share on other sites More sharing options...
chokk Posted January 23, 2011 Share Posted January 23, 2011 i'm sort of a beginner, i don't even know what a delimiter isIn this case the delimiter of a function is the curly braces ({}) of a function.if(statement){ //code to be executed if true}else{ //code to be executed if statement is not true} Link to comment Share on other sites More sharing options...
Greysoul Posted January 23, 2011 Author Share Posted January 23, 2011 In this case the delimiter of a function is the curly braces ({}) of a function.if(statement){ //code to be executed if true}else{ //code to be executed if statement is not true} i remember trying to do it and getting errors, so i took them out and it worked. i was more than likely putting them in wrong. if it works, then is it required? Link to comment Share on other sites More sharing options...
chokk Posted January 23, 2011 Share Posted January 23, 2011 i remember trying to do it and getting errors, so i took them out and it worked. i was more than likely putting them in wrong. if it works, then is it required?Apparently not. However it did throw me off when looking at your code. I believe it is best practice to put them in there.One reason you might have gotten an error is if you did it like this:if(statement){ //code to be executed if trueelse //code to be executed if statement is not true} Notice the else statement is missing its own pair of curly brackets.Here is an example of proper use of the curly brackets: if(statement){ //code to be executed if true}else{ //code to be executed if statement is not true} Link to comment Share on other sites More sharing options...
Greysoul Posted January 23, 2011 Author Share Posted January 23, 2011 yeah i see now, i'll fix it, thanks Link to comment Share on other sites More sharing options...
ShadowMage Posted January 24, 2011 Share Posted January 24, 2011 May I ask why you are leaving out delimiters for your if statements in both pages (line 19 on page 1 and line 33 on page 2)?Brackets or braces would have been better terminology. A delimiter is something used to separate a list of items. Like a comma: red,orange,green,blue Link to comment Share on other sites More sharing options...
chokk Posted January 24, 2011 Share Posted January 24, 2011 Brackets or braces would have been better terminology. A delimiter is something used to separate a list of items. Like a comma: red,orange,green,blueWhy? Isn't the purpose of a set of delimiters to mark the boundaries of something (in this case the boundaries of the conditional statement)? Link to comment Share on other sites More sharing options...
thescientist Posted January 24, 2011 Share Posted January 24, 2011 Why? Isn't the purpose of a set of delimiters to mark the boundaries of something (in this case the boundaries of the conditional statement)?yes, but I think the context here is that of scoping, not delimiting. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.