$range = array_flip( range( 1, 24 ) );
$query = "SELECT switchport FROM network ";
if( ($result = mysql_query( $query )) !== false )
{
while( ($row = mysql_fetch_array( $result )) !== false )
{
unset( $range[$row[0]] );
}
}
foreach( $range as $switchport => $foo )
{
echo '<option
value="'.$switchport.'">'.$switchport.'</option>'."\n";
$result = 0;
}
With that, I dont get anything, Not sure what you mean by empty to is_null
ect..
- Rob
----- Original Message -----
From: "Xavier Casto" <xavier@xxxxxxxxx>
To: "'Rob W.'" <rob@xxxxxxxxxxxxxxx>
Cc: <php-general@xxxxxxxxxxxxx>
Sent: Monday, June 19, 2006 7:37 PM
Subject: RE: Still trying to figure this out...
Ok Rob,
I tested my code in Oracle (obviously changed for that database type)
and discovered I needed to change "empty" to "is_null" I had forgotten
that
empty represents zero but we aren't getting a count so we needed to check
for a null.
it worked me for once I made that change and didn't need to do the other
change I had previously mentioned.
-----Original Message-----
From: Rob W. [mailto:rob@xxxxxxxxxxxxxxx]
Sent: Monday, June 19, 2006 6:50 PM
To: php-general@xxxxxxxxxxxxx
Subject: Re: Still trying to figure this out...
Yeah, that's what i'm trying to print is the missing numbers in the db.
That's what I've been trying to figure out this whole time.
----- Original Message -----
From: "Xavier Casto" <xavier@xxxxxxxxx>
To: "'Rob W.'" <rob@xxxxxxxxxxxxxxx>
Cc: <php-general@xxxxxxxxxxxxx>
Sent: Monday, June 19, 2006 6:34 PM
Subject: RE: Still trying to figure this out...
Are there any numbers missing in your database table between 0 and the
number you assigned to $maxport?
-----Original Message-----
From: Rob W. [mailto:rob@xxxxxxxxxxxxxxx]
Sent: Monday, June 19, 2006 6:26 PM
To: php-general@xxxxxxxxxxxxx
Subject: Re: Still trying to figure this out...
Yep, and still nothing output's.
----- Original Message -----
From: "Xavier Casto" <xavier@xxxxxxxxx>
To: "'Rob W.'" <rob@xxxxxxxxxxxxxxx>
Cc: <php-general@xxxxxxxxxxxxx>
Sent: Monday, June 19, 2006 6:20 PM
Subject: RE: Still trying to figure this out...
You did make sure to assign a numerical value to $maxport?
-----Original Message-----
From: Rob W. [mailto:rob@xxxxxxxxxxxxxxx]
Sent: Monday, June 19, 2006 6:15 PM
To: php-general@xxxxxxxxxxxxx
Subject: Re: Still trying to figure this out...
This also didnt work, Still giving me no output just like the last try.
----- Original Message -----
From: Xavier Casto
To: Rob W.
Cc: php-general@xxxxxxxxxxxxx
Sent: Monday, June 19, 2006 4:33 PM
Subject: Re: Still trying to figure this out...
Have you ever thought of doing something like this:
for($i = 0; $i <= $maxport; $i++)
{
$query="SELECT switchport FROM network WHERE switchport = ".$i;
$result=mysql_query($query);
if(empty($result))
{
echo "<p>$i</p>";
}
}
It should only return the ones that aren't in the table and they will
automatically be sorted in ascending order.
On 6/19/06, Rob W. <rob@xxxxxxxxxxxxxxx> wrote:
Ok, I am still trying to get this figured out from what I tried doing
last night. If anybody wants to try it, please be my guest. This is the
deal. Create an INTEGER table. Put the numbers 1 - 24 in it. Leave out
like
number 8, 9, 22, 23 ect.. Now create a php statement that will take and
pull
that out of the database, find out the missing numbers and display them
as
an html drop down selection.
And tedd in response to why, is because the values that are already
located in the database represent in use already. They represent a
server
port that a server is sitting on, so that's not the problem. I could
have
done that along time ago.
Any help is appreciated but here is the current code that I have.
$query="SELECT switchport FROM network";
$result=mysql_query($query);
$sql_range=mysql_fetch_array($result);
$true_range=range(1,24);
$next_range=array_diff($true_range,$sql_range);
foreach ($next_range as $final_range) {
echo "<option value='$final_range'>$final_range\n";
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php