selecting one item at a time from mysql databasse

admin

Administrator
Staff member
I don't know how to ask this question but hear go's I am writing a
script that will run at the command line at root invoked by cron
every 15 min.
It will access a mysql database that has new subscriber information
and take from that what it needs to set up a new hosting sit
automatically. This script I am writing calls another script to do all
the setup stuff.

Here is my problem I don't have any problem getting all the
information out of the database to fill in all the field except
one. That filed is the one that sets up the ipaddress. They are stored
in a separate table. This table is filled with unused ipadress.
Each new customer of corse gets it's own ipaddress. Now I have
no problem getting the first ipaddrss out of the list if there is
only one new customer in the new user database. But if there are
more than one I want the first one to get the first ipaddress
and then delete it from there. Then the second customer to get the
next one etc......
Below is some partial code I have been working with
What I need is a better way to implement this at this point I am
lost



ip Databasse
207.204.234.56
207.204.234.57
207.204.234.58
207.204.234.59
207.204.234.60


For selecting a new IPadress

$query1 = "SELECT * FROM ipaddress";
$result1 = mysql_query ($query1) or
die("Error in query");
while($myrow1 = mysql_fetch_array($result1))
{
$ipaddress = $myrow1["ip"];
}

For getting all new customer information

$query = "SELECT * FROM pcustomers ";// WHERE timestamp > SUBDATE( NOW() INTERVAL 15 MINUTES )";
$result = mysql_query ($query) or
die("Error in query");
while($myrow = mysql_fetch_array($result))
{


Setting verbals
$domainname = $myrow["domaname"];
$account = $myrow["account"];
$sdomaname = $myrow["sdomaname"];
$name = $myrow["name"];
etc................



if ($plan== "Commerce"){

$ipn = "-i $ipaddress"; This is the ipaddress
$host = " -n www";
$dom = " -d $domainname";
$mb = " -q 100";
$user = " -u 10";
etc................
 
Back
Top