[PHP] new set of eyes?

2003-12-06 Thread Jas
I think I am loosing my mind this afternoon... could someone review this 
snippit and tell me why it isn't working?

$sql = mysql_query(SELECT $i FROM $table WHERE $i = $i,$db)or 
die(mysql_error());
	while($b = mysql_fetch_array($sql)) {
		while($ar = current($b) != 0) {
			$v = array();
			list($v) = explode(},$ar); }
print_r($v); }

I am hoping to get something like
array([0]=first row of data[1]=second row of data)
Any help would be great...
Jas
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] new set of eyes?

2003-12-06 Thread olinux
try this: 
$ar = array();
while ($row = mysql_fetch_assoc($sql)) {
   $ar[] = $row;
}

olinux


--- Jas [EMAIL PROTECTED] wrote:
 I think I am loosing my mind this afternoon... could
 someone review this 
 snippit and tell me why it isn't working?
 
 $sql = mysql_query(SELECT $i FROM $table WHERE $i =
 $i,$db)or 
 die(mysql_error());
   while($b = mysql_fetch_array($sql)) {
   while($ar = current($b) != 0) {
   $v = array();
   list($v) = explode(},$ar); }
 print_r($v); }
 
 I am hoping to get something like
 array([0]=first row of data[1]=second row of data)
 
 Any help would be great...
 Jas
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

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



Re: [PHP] new set of eyes?

2003-12-06 Thread David Otton
On Sat, 06 Dec 2003 11:38:18 -0700, you wrote:

I think I am loosing my mind this afternoon... could someone review this 
snippit and tell me why it isn't working?

$sql = mysql_query(SELECT $i FROM $table WHERE $i = $i,$db)or 
die(mysql_error());
   while($b = mysql_fetch_array($sql)) {
   while($ar = current($b) != 0) {
   $v = array();
   list($v) = explode(},$ar); }
print_r($v); }

I am hoping to get something like
array([0]=first row of data[1]=second row of data)

Your code doesn't have any context, so I can't be sure whether you're doing
something very smart or very dumb with the SQL statement. The explode() is
kinda weird, too.

Try running this:

?
$sql = SELECT $i FROM $table WHERE $i = $i;
echo ($sql);

$rs = mysql_query ($sql, $db) or die (mysql_error ());

$result = array();

while ($row = mysql_fetch_array ($rs))
{
$result[] = $row;
}

print_r ($result);
?

and let us know how close it comes.

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



Re: [PHP] new set of eyes?

2003-12-06 Thread Jas
I should probably clarify a bit more on the data in the field and what I 
 am trying accomplish..

First the data:
host dhcp-01 {
hardware ethernet 00:D0:B7:BD:D2:8D;
fixed-address 155.97.1.190;
}
host dhcp-02 {
hardware ethernet 00:02:B3:A2:B6:FD;
fixed-address 155.97.1.191;
}
Second the plan:
Trying to break up (only one row in database  always will be only one 
row to retrieve) contents of field into an array so I can break it down 
into individual editable fields (eg. input type=\text\ name\$host\ 
etc.)

the explode() is so I can separate numerous static dhcp hosts into one 
big array of each setting.

eg.
$hosts = array(0 = host,
   1 = dhcp-02,
   2 = {,
   3 = hardware,
   4 = ethernet,
   5 = 00:02:B3:A2:B6:FD,
   6 = ;,
   etc...
I hope this clarifies my problem.  I have tried a few things such as a 
eregi statement, explode etc. and so far explode has done what i need it 
to by separating one db entry into multiple components for editing.

Jas

David Otton wrote:

On Sat, 06 Dec 2003 11:38:18 -0700, you wrote:


I think I am loosing my mind this afternoon... could someone review this 
snippit and tell me why it isn't working?

$sql = mysql_query(SELECT $i FROM $table WHERE $i = $i,$db)or 
die(mysql_error());
	while($b = mysql_fetch_array($sql)) {
		while($ar = current($b) != 0) {
			$v = array();
			list($v) = explode(},$ar); }
print_r($v); }

I am hoping to get something like
array([0]=first row of data[1]=second row of data)


Your code doesn't have any context, so I can't be sure whether you're doing
something very smart or very dumb with the SQL statement. The explode() is
kinda weird, too.
Try running this:

?
$sql = SELECT $i FROM $table WHERE $i = $i;
echo ($sql);
$rs = mysql_query ($sql, $db) or die (mysql_error ());

$result = array();

while ($row = mysql_fetch_array ($rs))
{
$result[] = $row;
}
print_r ($result);
?
and let us know how close it comes.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] new set of eyes?

2003-12-06 Thread Jas
Ok well I think I have it partially solved...
?php
$table = settings;
$db_vlans = 
array(hosts01,hosts02,hosts03,hosts04,hosts05,hosts06,hosts07,hosts08,hosts09,hosts10);
$vlans = 
array(VLAN-22,VLAN-27,VLAN-29,VLAN-56,VLAN-57,VLAN-151,VLAN-314,Empty-01,Empty-02,Empty-03);
$i = str_replace($vlans,$db_vlans,$_POST['dhcp_hosts']);
$_SESSION['dhcp_table'] = $i;
$sql = mysql_query(SELECT $i FROM $table WHERE $i = $i,$db)or 
die(mysql_error());
$result = array();
	while($b = mysql_fetch_array($sql)) {
	   $result[] = explode( ,$b);
 	   print_r($result);
		   $num = count($result);
		   print $num;
		   for ($x = 0; $x  $num; $x++) {
			print $result[$x]br /\n; }
?
On data in one field that looks like:
host dhcp-01 {
hardware ethernet 00:D0:B7:BD:D2:8D;
fixed-address 155.97.1.190;
}
host dhcp-02 {
hardware ethernet 00:02:B3:A2:B6:FD;
fixed-address 155.97.1.191;
}

Is returning this:
Array ( [0] = Array ( [0] = Array ) ) 1Array
So it sees 1 array and inside are two indexes both containing a new 
array... now I need to know how to pull the contents out of the second 
arrays.
Sorry, still trying to figure out arrays.
Jas

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