Re: Retrieving URL of webpage etc.
"Jacob Kruger" <[email protected]>
| Newsgroups | gmane.comp.php.windows |
|---|---|
| Message-ID | <001901ca19bd$82d486c0$6401a8c0@spaceque1d2a04> |
Ok, will try out that one. Basically you're saying that the PHP backend will automatically make those checkboxes into an array if I implement that syntax? There is really only one other form field on that page - a search textbox - apart from the possible 50 checkbox fields, but will definitely look into it. Stay well Jacob Kruger Blind Biker Skype: BlindZA '...fate had broken his body, but not his spirit...' ----- Original Message ----- From: "Richard Quadling" <[email protected]> To: "Jacob Kruger" <[email protected]> Cc: <[email protected]> Sent: Monday, August 10, 2009 1:29 PM Subject: Re: [PHP-WIN] Retrieving URL of webpage etc. > 2009/8/10 Jacob Kruger <[email protected]>: >> Ok. >> >> Now got it working with the following two bits of script: >> if ($_POST['btnDel'] == "Multiple deletion") >> { >> // perform multiple delete first >> foreach ($_POST as $formField) >> checkField($formField); >> >> } // end of delete button pressed >> >> and above that (seems to only see function if located above the call to >> it): >> function checkField($field) >> { >> $start = substr($field, 0, 5); >> if ($start == "doDel") >> { >> $id = substr($field,5,strLen($field) - 5); >> $sql = "delete from article where ID = " . $id . ";"; >> $result = mysql_query($sql); >> } // end of if doDel in string >> } // end of function >> >> The checkboxes are generated with the following line of script/code: >> echo "<input type='checkbox' name='doDel" . $row['id'] . "' value='doDel" >> . >> $row['id'] . "' />"; >> >> I initially tried just using either strpos() or stripos() functions to >> check >> if the substring doDel was there, but for some reason it never returned a >> result of false no matter what was in the form field's value, so switched >> over to the instance of substr() as above. >> >> Will also just now add on some javascript to make the user confirm that >> they >> do in fact want to delete selected records, but anyway... >> >> Thanks for giving me the right ideas with regard to what route to follow, >> and I'll just also say that obviously I need to carry on with this stuff >> a >> bit since your examples mostly seemed a bit strange to me with regard to >> just including variables etc. inside the string values to be used, which >> is >> why I instead just used what I reckon is a simpler syntax as such. >> >> Stay well >> >> Jacob Kruger >> Blind Biker >> Skype: BlindZA >> '...fate had broken his body, but not his spirit...' >> >> >> __________ Information from ESET NOD32 Antivirus, version of virus >> signature >> database 4321 (20090810) __________ >> >> The message was checked by ESET NOD32 Antivirus. >> >> http://www.eset.com >> >> >> >> >> -- >> PHP Windows Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > Eek! > > echo "<input type='checkbox' name='doDel" . $row['id'] . "' > value='doDel" . $row['id'] . "' />"; > > really would be a lot easier on you if use ... > > echo "<input type='checkbox' name='doDel[" . $row['id'] . "]' > value='doDel" . $row['id'] . "' />"; > > Now, $_POST['doDel'] is an array you can foreach() on without any need > to decode ... > > foreach($_POST['doDel'] as $ID_to_delete => $value_associated_with_input) > { > if (intval($ID_to_delete) > 0) { > // Now you can delete based upon the id held in $ID_to_delete. > } > } > > > -- > ----- > Richard Quadling > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" > ZOPA : http://uk.zopa.com/member/RQuadling > > __________ Information from ESET NOD32 Antivirus, version of virus > signature database 4321 (20090810) __________ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > > > __________ Information from ESET NOD32 Antivirus, version of virus signature database 4321 (20090810) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php