Re: [PHP-DB] URGET HELP : Logic Help - for first record do_this for each record after do_that
On Saturday 26 October 2002 02:53, Aaron Wolski wrote: First, don't be so * lazy! You hijack an existing thread by replying to an existing post instead of starting a new one. AND you leave the original post hanging off the end of your message. Basically I need to pull some records out of a database and for the first record do_this logic and for each record after in the array do_something_else logic. How would I approach this? Using mysql as an example: if ($row = mysql_fetch_row($result)) { // do stuff for first row } while ($row = mysql_fetch_row($result)) { // do stuff for remaining rows } -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* When you get your PH.D. will you get able to work at BURGER KING? */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] URGET HELP : Logic Help - for first record do_this for each record after do_that
Hey guys, Not really off topic as this involves some Db work as I have to query the DB. Got a logic problem that was jumped dumped on me from UPS (dummys!). Basically I need to pull some records out of a database and for the first record do_this logic and for each record after in the array do_something_else logic. How would I approach this? something like: for ($first_record) { do_something; } else { do_something_else; } Any clues? Thanks! Aaron -Original Message- From: Graeme McLaren [mailto:mickel;ntlworld.com] Sent: Friday, October 25, 2002 2:40 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Inserting checkbox data Hi all, I'm having a problem inserting a value from a checkbox into a MySQL DB. I can print out what the variable holds, the problem is it just won't go into the DB. Weird thing is when I login to SSH there isn't a NULL value for it instead that field is just blank. Anyone got any ideas what the problem is? The HTML that is used for the checkbox is: Gift Wrapping: input type=checkbox Name=GiftWrapping[] Value=\Y\ So it should theoretically insert Y into the DB Here is the code that appears to be causing the problem: $number=count($GiftWrapping); for($a=0;$a=$number;$a++) { echo $GiftWrapping[$a]; $GW = $GiftWrapping[$a]; echo $GW; } if ($Submit == Submit) { $sql = INSERT INTO SiteMember SET FirstName = '$FirstName', LastName = '$LastName' Username = '$Username', Password = '$Password', GiftWrapping = '$GW'; } Thank you in advance for any help. Graeme :) Public Sub House() On Error Resume drink If Pint.empty = True Then Pint.refill Else Pint.drink End if stomach.add Pint MsgBox I've had stomach.count Pints MsgBox VERY DRUNK End Sub -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] URGET HELP : Logic Help - for first record do_this for each record after do_that
What about wrapping your logic in a counter? Set $count=1, if($count=1){do_this; then $count++;} else{do_that}. Wouldn't really add any overhead to your script since the counter only gets incremented once when the if() statement is true then stays at 2 and executes the else{} stuff after that. Pretty stupid solution and maybe not the most elegant, but you DID say URGENT. I just read Paul's post. This is pretty similar. -Original Message- From: Aaron Wolski [mailto:aaronjw;martekbiz.com] Sent: Friday, October 25, 2002 2:54 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] URGET HELP : Logic Help - for first record do_this for each record after do_that Hey guys, Not really off topic as this involves some Db work as I have to query the DB. Got a logic problem that was jumped dumped on me from UPS (dummys!). Basically I need to pull some records out of a database and for the first record do_this logic and for each record after in the array do_something_else logic. How would I approach this? something like: for ($first_record) { do_something; } else { do_something_else; } Any clues? Thanks! Aaron -Original Message- From: Graeme McLaren [mailto:mickel;ntlworld.com] Sent: Friday, October 25, 2002 2:40 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Inserting checkbox data Hi all, I'm having a problem inserting a value from a checkbox into a MySQL DB. I can print out what the variable holds, the problem is it just won't go into the DB. Weird thing is when I login to SSH there isn't a NULL value for it instead that field is just blank. Anyone got any ideas what the problem is? The HTML that is used for the checkbox is: Gift Wrapping: input type=checkbox Name=GiftWrapping[] Value=\Y\ So it should theoretically insert Y into the DB Here is the code that appears to be causing the problem: $number=count($GiftWrapping); for($a=0;$a=$number;$a++) { echo $GiftWrapping[$a]; $GW = $GiftWrapping[$a]; echo $GW; } if ($Submit == Submit) { $sql = INSERT INTO SiteMember SET FirstName = '$FirstName', LastName = '$LastName' Username = '$Username', Password = '$Password', GiftWrapping = '$GW'; } Thank you in advance for any help. Graeme :) Public Sub House() On Error Resume drink If Pint.empty = True Then Pint.refill Else Pint.drink End if stomach.add Pint MsgBox I've had stomach.count Pints MsgBox VERY DRUNK End Sub -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php