On Sunday, June 23, 2002, at 09:30 PM, Vicki wrote:
> If you can suggest code that works, that would be great, or at least > point me in the right direction if I'm on the wrong track with > checkboxes. If you haven't noticed already, I'm very, very new to PHP > and haven't quite got the hang of it yet. :=) Someone else mentioned the "empty()" language construct. Learn this and use it everywhere. I find that it is probably one of my most-often used tricks to evaluate user input of any kind, especially checkboxes and radio buttons. The reason why is because if you use "if ($_POST['varname'])" or "if (isset($_POST['varname']))", you're testing to see if the variable was ever set. With HTML forms, they may in fact have been set but have no values. Using empty() will test to see if they evaluate to false (such as if they contain an empty string, which is what happens when someone submits a form but doesn't actually put some data into a certain input), and that is a reliable way to test for changes. Also, I have a shopping-cart-like feature on my site. I store my "purchased" objects in an array. One thing that I learned the hard way is that if you use unset() to remove items from this array, you will end up with empty array elements. If you need to re-order the array (to put the indexes into a sequential order once again), you can do something like this: array_push($array, 'dummy_value'); unset($array[$index_to_unset]); array_pop($array); Because using array_pop() will re-index the array. Much thanks to Nathan for that tip. Erik ---- Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php