Re: Still trying to figure this out...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nope, I still dont get anything back from that.

So i'm still stuck in the mud.


----- Original Message ----- From: "Jochem Maas" <jochem@xxxxxxxxxxxxx>
To: "Rob W." <rob@xxxxxxxxxxxxxxx>
Cc: <php-general@xxxxxxxxxxxxx>
Sent: Monday, June 19, 2006 4:05 PM
Subject: Re:  Still trying to figure this out...


Rob W. 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..

I'll assume the DB creation and filling is something you have already covered/dealt with.

Now create a php statement that will take and pull that out of the database,

this you have already (as per your example code).

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.

huh? whats not a problem, what could have done a long time ago? (and why didn't you?)

Any help is appreciated but here is the current code that I have.


try the apples below....


  $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";
  }


$sqlRange = array();
if ($res = mysql_query('SELECT switchport FROM network')) {
while ($row = mysql_fetch_array($res)) $sqlRange[] = $row['switchport'];
}

echo '<select name="port">';
foreach (array_diff(range(1,24), $sqlRange) as $port) {
echo '<option value="',$port,'">',$port,'</option>';
}
echo '</select>';

/*

NOTE:

1. you have to loop your mysql result to get each port that is already used in the DB into you array 2. try to output something that resembles proper HTML (an <option> without a closing tag sucks)

*/



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux