Re: selecting one item at a time from mysql

From: Date: Mon, 18 Sep 0000 01:19:38 +0000
Subject: Re: selecting one item at a time from mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-17124@lists.php.net to get a copy of this message
Richard, Just put this query in the WHILE loop of the previous query: $query0 = "Select * FROM newcustomers"; $result0 = " mysql_query($query0) or die("query0 failed"); while($myrow0 = mysql_fetch_array($result0)) { > $query1 = "SELECT * FROM ipaddress LIMIT 1"; > $result1 = mysql_query ($query1) or > die("Error in query"); > while($myrow1 = mysql_fetch_array($result1)) > { > $ipaddress = $myrow1["ip"]; } Your outer query runs only once, then the inner query runs once for each instance that meets your "assign an IP" criteria. It pulls exactly one IP consistently, no matter how many customer records are part of the batch. > It works just fine if I don't have more than one person signing up at a > time. I could use the LIMIT switch to just get the first record but then > if I have a second person that is in the database to be signed up I would > have to run the query again. (The program is run by cron and looks in a > database to see if there are any new subscribers if there are it grabs > them and runs all of them thru the script each one needs a different ip > address) All I what to do is grab another IP address each time the program > comes to a new subscriber without having to run the script over again. Sounds great - what else do you have the script doing? J!M ps: 8-), Do > I make any sense. Do > I make any sense. Do > I make any sense. Do > I make any sense. Do > I make a ny sense. Do > Im a keanys ense. Do > I may kane seens. Do > yes man kenseI. Do > ay make Insense. Do > many uke a sensei. NOTICE: unknown nonrecursive error in nonsense loop line 303, at position 19. > > > > > > > > > > > > Hello and welcome to FAR DOWN THE PAGE. Thank you for visiting. ;)) J!M

« previous php.general (#17124) next »