[PHP-DB] Array Display

2008-05-06 Thread A. Joseph
Please i knew this not the best place to post this message but i ain`t
gat no option
i need fast help on this

I have a Array and data are grouped according to level,
so want to display everybody on same level in same HTML row
os if you are on level 0
then you first,
to the next people on level one, then level 1 on samle row
so on..

Thank you.



On 5/6/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I am opening a rss file using fopen.

 If I use direct value, it can be opened, but I use a paremeter, I
 obtain an error.


 This works:

...
xml_set_character_data_handler($xml_parser, characterData);
$fp = fopen(http://www.arteglobal.net/news.xml,r;) or die(Error
 reading RSS data.);
while ($data = fread($fp, 4096))
  {
  xml_parse($xml_parser, $data, feof($fp))
  ...

 But this one not (Error reading RSS data):

...
$url_rss = http://www.arteglobal.net/news.xml;;
...
xml_set_character_data_handler($xml_parser, characterData);
$fp = fopen($url_rss,r) or die(Error reading RSS data.);
while ($data = fread($fp, 4096))
  {
  xml_parse($xml_parser, $data, feof($fp))
  ...


 Any idea about what is happening?.


 Thank you!



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




-- 
I develop dynamic website with PHP  MySql, Let me know about your site

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



[PHP-DB] Array Display

2008-05-06 Thread A. Joseph
Please i knew this not the best place to post this message but i ain`t
gat no option
i need fast help on this

I have a Array and data are grouped according to level,
so want to display everybody on same level in same HTML row
os if you are on level 0
then you first,
to the next people on level one, then level 1 on samle row
so on..

Array sample is

Array
(
[0] = Array
(
[0] = 1009603
[section_id] = 1009603
[1] = 4
[section_left] = 4
[2] = 11
[section_right] = 11
[3] = 1
[section_level] = 1
[4] = Joseph Abah
[section_name] = Joseph Abah
)

[1] = Array
(
[0] = 1009956
[section_id] = 1009956
[1] = 5
[section_left] = 5
[2] = 8
[section_right] = 8
[3] = 2
[section_level] = 2
[4] = Onuche Mikel
[section_name] = Onuche Mikel
)

[2] = Array
(
[0] = 1005539
[section_id] = 1005539
[1] = 9
[section_left] = 9
[2] = 10
[section_right] = 10
[3] = 2
[section_level] = 2
[4] = Owen Joncena
[section_name] = Owen Joncena
)

)


Thank you.



On 5/6/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I am opening a rss file using fopen.

 If I use direct value, it can be opened, but I use a paremeter, I
 obtain an error.


 This works:

...
xml_set_character_data_handler($xml_parser, characterData);
$fp = fopen(http://www.arteglobal.net/news.xml,r;) or die(Error
 reading RSS data.);
while ($data = fread($fp, 4096))
  {
  xml_parse($xml_parser, $data, feof($fp))
  ...

 But this one not (Error reading RSS data):

...
$url_rss = http://www.arteglobal.net/news.xml;;
...
xml_set_character_data_handler($xml_parser, characterData);
$fp = fopen($url_rss,r) or die(Error reading RSS data.);
while ($data = fread($fp, 4096))
  {
  xml_parse($xml_parser, $data, feof($fp))
  ...


 Any idea about what is happening?.


 Thank you!



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




-- 
I develop dynamic website with PHP  MySql, Let me know about your site

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



[PHP-DB] array issue

2007-11-27 Thread Clare Media
Guys really in need of some assistance here.

I am reading an xml file and want to loop through the entire file and
display the information.

Unfortunately I am only showing 1 item. how can I go about showing all news
item?

I've tried array and loop however I am not versed with any of them.

Thanks in advance

 

 

eg.

-

item

titletitle 1/title

descriptionDescription 1/description

/item

item

titletitle 2/title

descriptionDescription 2/description

/item

item

titletitle 3/title

descriptionDescription 3/description

/item

-

 

My current code

+

function getNews() 

{

$file = NEWS_FILE..xml;

if(!file_exists($file) || filemtime($file) 
time() - 43200) {

$this-data =
@file_get_contents(http://feeds.mydomain.com/dailynews;);

$fp = @fopen($file, 'w');

@fwrite($fp, $this-data);

@fclose($fd);

}

else $this-data =
@file_get_contents($file);

if(strlen($this-data) = 0) return;



// get the location

$attr = explode('', $this-tag('item'));


$return['title'] = $attr[1];

$return['title'] = substr($return['title'],
6);

 

$return['description'] = $attr[7];

$return['description'] =
substr($return['description'], 2);

 

return $return;

}



function view_news()

{



$currentNews = newsfeed::getNews();



$NEWS=
'strong'.$currentNews['title'].'/strongbr'.$currentNews['description']
..'br/';



return $NEWS;



}

 

function tag($tag, $skip=0) 

{

$start = -1;

for($i = 0; $i = $skip; $i++)

$start = strpos($this-data,
{$tag}, $start + 1);

if($start === false) return false;

$start += strlen($tag) + 1;

$end = strpos($this-data, /{$tag},
$start);

if($end === false)

$end = strpos($this-data,
'/', $start);

return trim(substr($this-data, $start, $end
- $start));

}



Re: [PHP-DB] array issue

2007-11-27 Thread Jason Gerfen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Clare Media wrote:
 Guys really in need of some assistance here.
 
 I am reading an xml file and want to loop through the entire file and
 display the information.
 
 Unfortunately I am only showing 1 item. how can I go about showing all news
 item?
 
 I've tried array and loop however I am not versed with any of them.
 
 Thanks in advance
 
  
 
  
 
 eg.
 
 -
 
 item
 
 titletitle 1/title
 
 descriptionDescription 1/description
 
 /item
 
 item
 
 titletitle 2/title
 
 descriptionDescription 2/description
 
 /item
 
 item
 
 titletitle 3/title
 
 descriptionDescription 3/description
 
 /item
 
 -
 
  
 
 My current code
 
 +
 
 function getNews() 
 
 {
 
 $file = NEWS_FILE..xml;

 if(!file_exists($file) || filemtime($file) 
 time() - 43200) {
 
 $this-data =
 @file_get_contents(http://feeds.mydomain.com/dailynews;);
 
 $fp = @fopen($file, 'w');
 
 @fwrite($fp, $this-data);
 
 @fclose($fd);
 
 }
 
 else $this-data =
 @file_get_contents($file);
 
 if(strlen($this-data) = 0) return;
 
 
Count the elements in $this-data = @file_get_contents( $file );
If more then one then loop else use the code below:

ex:
if( count( $this-data = @file_get_contents( $file )  1 ) ) {
 foreach( $this-data as $key = $value ) {
  // show your titles etc.
 }
} else {
 
 // get the location
 
 $attr = explode('', $this-tag('item'));
 
 
 $return['title'] = $attr[1];
 
 $return['title'] = substr($return['title'],
 6);
 
  
 
 $return['description'] = $attr[7];
 
 $return['description'] =
 substr($return['description'], 2);
 
  
 
 return $return;
 
 }
 
 
 
 function view_news()
 
 {
 
 
 
 $currentNews = newsfeed::getNews();
 
 
 
 $NEWS=
 'strong'.$currentNews['title'].'/strongbr'.$currentNews['description']
 ..'br/';
 
 
 
 return $NEWS;
 
 
 
 }
 
  
 
 function tag($tag, $skip=0) 
 
 {
 
 $start = -1;
 
 for($i = 0; $i = $skip; $i++)
 
 $start = strpos($this-data,
 {$tag}, $start + 1);
 
 if($start === false) return false;
 
 $start += strlen($tag) + 1;
 
 $end = strpos($this-data, /{$tag},
 $start);
 
 if($end === false)
 
 $end = strpos($this-data,
 '/', $start);
 
 return trim(substr($this-data, $start, $end
 - $start));
 
 }
 
 


- --
Jason Gerfen

I practice my religion
 while stepping on your
 toes...
~The Ditty Bops
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHTGMM5vk8bwKVAaIRAhAjAJ9FklveFH1PORVl0HC9nCb+klgcUACeOren
RgXSIP0bl/bt9rI6g9a/6Uk=
=y9XX
-END PGP SIGNATURE-

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



[PHP-DB] array

2007-03-29 Thread elk dolk
Hi all,
I want to put result of query in a two dimensional array like this:

title[0]=x   description [0]=y
title[1]=z   description [1]=w
.

any idea would be appreciated

$query = SELECT * FROM photo;
$result=mysql_query($query);


while ($row = mysql_fetch_array($result)) 
{
 
  $title=$row['title'];
  $description=$row['description'];
  
  }
 
-
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.

RE: [PHP-DB] array

2007-03-29 Thread Bastien Koert
That is not a two dimensional array. Its two one dimensional arrays and yo 
do it like this


while ($row = mysql_fetch_array($result))
{

 $title[]   =$row['title'];
 $description[]  =$row['description'];

 }



bastien


From: elk dolk [EMAIL PROTECTED]
To: php-db@lists.php.net php-db@lists.php.net
Subject: [PHP-DB] array
Date: Thu, 29 Mar 2007 13:29:45 -0700 (PDT)

Hi all,
I want to put result of query in a two dimensional array like this:

title[0]=x   description [0]=y
title[1]=z   description [1]=w
.

any idea would be appreciated

$query = SELECT * FROM photo;
$result=mysql_query($query);


while ($row = mysql_fetch_array($result))
{

  $title=$row['title'];
  $description=$row['description'];

  }

-
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.


_
Check Out Our List Of Trendy Restaurants. You'll Eat It Up! 
http://local.live.com/?mkt=en-ca/?v=2cid=A6D6BDB4586E357F!378


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



Re: [PHP-DB] array field type

2007-03-06 Thread Tony Marston

Sancar Saran [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Sunday 04 March 2007 23:04, Sancar Saran wrote:
 Hi,

 I want to know is there any db server around there for store php arrays
 natively.

 Regards

 Sancar
 Thanks for responses, it seems I have to give more info about situation.

 In my current project, we had tons of arrays. They are very deep and
 unpredictable nested arrays.

 Currently we are using serialize/unserialize and it seems it comes with 
 own
 cpu cost. Xdebug shows some serializing cost blips. Sure it was not SO BIG
 deal (for now of course).

 My db expertise covers a bit mysql and mysql does not have any array type
 field (enum just so simple).

Wrong! Take a look at the SET datatype 
http://dev.mysql.com/doc/refman/4.1/en/set.html. This allows you to have an 
array of values in a single field, and the user can select any number of 
them.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

 I just want to know is there any way to keep array data type natively in a 
 sql
 field.

 Regards.

 Sancar 

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



Re: [PHP-DB] array field type

2007-03-06 Thread Micah Stevens


Wrong! Take a look at the SET datatype 
http://dev.mysql.com/doc/refman/4.1/en/set.html. This allows you to have an 
array of values in a single field, and the user can select any number of 
them.


  
Sort of, but not really: This is a really specialized keyword, and 
depends on binary mapping of enum-ish sets. As a results you have a 
maximum of 64 possible values, and only 1 dimension. Large or 
multdimensional arrays wouldn't work with this.


-Micah

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



Re: [PHP-DB] array field type

2007-03-06 Thread Mark
Sancar Saran wrote:

 Thanks for all those replies. It seems there was no easy solution (and or
 serializing was better solution) for us.
 
 Our arrays contains lots of things.. XML may not fit because content of
 array may broke xml structure.
 

Before you give up, take a look at the XMLDBX PHP extension at
http://www.mohawksoft.org

It uses XML and works really well.

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



Re: [PHP-DB] array field type

2007-03-05 Thread Bastien Koert

another option might be to store xml snippets that match the array.

if you are using large numbers of arrays, perhaps a revamping of the db 
structure to map the arrays to sub-tables might be in order


bastien



From: Micah Stevens [EMAIL PROTECTED]
To: Sancar Saran [EMAIL PROTECTED]
CC: php-db@lists.php.net,  php-general@lists.php.net
Subject: Re: [PHP-DB] array field type
Date: Sun, 04 Mar 2007 15:04:42 -0800

Not a single field, but there's several methods of storing trees of 
information, which is what an array is. Here's one:


Nested Array storage table:

ArrayID (int, autonumber)
keyname (text)
parent   (int)
data (bigtext or whatever would be appropriate for the data you're storing)

For an array like this:

array('one'=1, 'two'=array('three'=3, 'four'=4))

the table would store these rows:

1, 'one', 0, 1
2, 'two', 0, 2
3, 'three', 2, 3
4, 'four', 2, 4

You can use a recursive function to restore the array, unless you require 
the granular functionality this type of process would give you such as 
sorting and filtering and statistics gathering.


-Micah

However, I think in the long run, you'd be better off serializing the data.

-Micah


On 03/04/2007 02:15 PM, Sancar Saran wrote:

On Sunday 04 March 2007 23:04, Sancar Saran wrote:


Hi,

I want to know is there any db server around there for store php arrays
natively.

Regards

Sancar


Thanks for responses, it seems I have to give more info about situation.

In my current project, we had tons of arrays. They are very deep and 
unpredictable nested arrays.


Currently we are using serialize/unserialize and it seems it comes with 
own cpu cost. Xdebug shows some serializing cost blips. Sure it was not SO 
BIG deal (for now of course).


My db expertise covers a bit mysql and mysql does not have any array type 
field (enum just so simple).


I just want to know is there any way to keep array data type natively in a 
sql field.


Regards.

Sancar




_
Win a trip for four to a concert anywhere in the world! 
http://www.mobilelivetour.ca/


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



Re: [PHP-DB] array field type

2007-03-05 Thread Sancar Saran
Thanks for all those replies. It seems there was no easy solution (and or 
serializing was better solution) for us.

Our arrays contains lots of things.. XML may not fit because content of array 
may broke xml structure. 

Thanks for help.

Regards

Sancar.

 Hi,
 
 I want to know is there any db server around there for store php arrays
 natively.
 
 Regards
 
 Sancar
 
 Thanks for responses, it seems I have to give more info about situation.
 
 In my current project, we had tons of arrays. They are very deep and
 unpredictable nested arrays.
 
 Currently we are using serialize/unserialize and it seems it comes with
 own cpu cost. Xdebug shows some serializing cost blips. Sure it was not
  SO BIG deal (for now of course).
 
 My db expertise covers a bit mysql and mysql does not have any array type
 field (enum just so simple).
 
 I just want to know is there any way to keep array data type natively in
  a sql field.
 
 Regards.
 
 Sancar

 _
 Win a trip for four to a concert anywhere in the world!
 http://www.mobilelivetour.ca/

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



[PHP-DB] array field type

2007-03-04 Thread Sancar Saran
Hi,

I want to know is there any db server around there for store php arrays 
natively.

Regards

Sancar

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



Re: [PHP-DB] array field type

2007-03-04 Thread Sancar Saran
On Sunday 04 March 2007 23:04, Sancar Saran wrote:
 Hi,

 I want to know is there any db server around there for store php arrays
 natively.

 Regards

 Sancar
Thanks for responses, it seems I have to give more info about situation.

In my current project, we had tons of arrays. They are very deep and 
unpredictable nested arrays.

Currently we are using serialize/unserialize and it seems it comes with own 
cpu cost. Xdebug shows some serializing cost blips. Sure it was not SO BIG 
deal (for now of course).

My db expertise covers a bit mysql and mysql does not have any array type 
field (enum just so simple). 

I just want to know is there any way to keep array data type natively in a sql 
field.

Regards.

Sancar

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



Re: [PHP-DB] array field type

2007-03-04 Thread Micah Stevens
Not a single field, but there's several methods of storing trees of 
information, which is what an array is. Here's one:


Nested Array storage table:

ArrayID (int, autonumber)
keyname (text)
parent   (int)
data (bigtext or whatever would be appropriate for the data you're storing)

For an array like this:

array('one'=1, 'two'=array('three'=3, 'four'=4))

the table would store these rows:

1, 'one', 0, 1
2, 'two', 0, 2
3, 'three', 2, 3
4, 'four', 2, 4

You can use a recursive function to restore the array, unless you 
require the granular functionality this type of process would give you 
such as sorting and filtering and statistics gathering.


-Micah

However, I think in the long run, you'd be better off serializing the data.

-Micah


On 03/04/2007 02:15 PM, Sancar Saran wrote:

On Sunday 04 March 2007 23:04, Sancar Saran wrote:
  

Hi,

I want to know is there any db server around there for store php arrays
natively.

Regards

Sancar


Thanks for responses, it seems I have to give more info about situation.

In my current project, we had tons of arrays. They are very deep and 
unpredictable nested arrays.


Currently we are using serialize/unserialize and it seems it comes with own 
cpu cost. Xdebug shows some serializing cost blips. Sure it was not SO BIG 
deal (for now of course).


My db expertise covers a bit mysql and mysql does not have any array type 
field (enum just so simple). 

I just want to know is there any way to keep array data type natively in a sql 
field.


Regards.

Sancar

  


Re: [PHP-DB] Array

2006-09-29 Thread Niel Archer
Hi Ron,

 how do I put each word into an array (so there would be 12 components in
 the array) as well as remove the period and make the C in Check and the
 Y in You lower case

This isn't a DB question, please ask questions in the appropriate list.

But for reference, look up the str_replace, strtolower, and  explode
functions.

Niel

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



RE: [PHP-DB] Array

2006-09-29 Thread Hutchins, Richard
Use the strtolower function to reduce all letters to lower case.

Then use the stripos() function to find where the spaces are in the string
and use that position in the substr() function to parse out the individual
words in the string. From there you can put the chunks into an array or a
query or whatever you're going to do with them.

You can also consider using the str_word_count(mystring, 1) to obtain an
array containing the words in the string. Check out the function in the
documentation to see how it treats different string types though - the
results may not be what you need.

You can also use the above strategy to find the periods in the sentences and
either remove them or just exclude them from whatever it is you're going to
do with the results of your parsing.

Probably a few other ways to get the results you're looking for including a
couple pre-built functions or classes if you Google for them.

-Original Message-
From: Ron Piggott (PHP) [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 29, 2006 11:21 AM
To: PHP DB
Subject: [PHP-DB] Array

If I have the sentences

Check one two three four.  You did well to count to four.

how do I put each word into an array (so there would be 12 components in the
array) as well as remove the period and make the C in Check and the Y in You
lower case

Ron

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



RE: [PHP-DB] Array

2006-09-29 Thread Shaun A Riches
Title: RE: [PHP-DB] Array






This is hardly database related but nonetheless.

?
$myString = Check one two three four. You did well to count to four.;
$myString = str_replace(.,,$myString);
$myString = strtolower($myString);

$myWords = explode( , $myString);

// do stuff here with your array
?

How is that?

___
Shaun Riches
Computer Science Student
http://www.sh4un.co.uk



-Original Message-
From: Ron Piggott (PHP) [mailto:[EMAIL PROTECTED]]
Sent: Fri 29/09/2006 16:21
To: PHP DB
Subject: [PHP-DB] Array

If I have the sentences

Check one two three four. You did well to count to four.

how do I put each word into an array (so there would be 12 components in
the array) as well as remove the period and make the C in Check and the
Y in You lower case

Ron







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

RE: [PHP-DB] Array problem...

2005-09-18 Thread Bastien Koert
Dunno if its relevant, but the recommended way to use sessions is to assign 
stuff to a $_SESSION['varname']...I don't really see anything wrong with the 
code...


Also, what arrays are causing the problems?

bastien



From: NIPP, SCOTT V (SBCSI) [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Array problem...
Date: Fri, 16 Sep 2005 09:04:34 -0500

I am migrating a web app from an old server running PHP 4.2.3 to
a new server running 4.3.8.  The problem I am running into at the moment
is building an array and passing it to another page.  This code works
fine on the old server, but the array is not coming across to the new
page on the new server.  Help...

mysql_select_db($database, $Prod);
$shell_list = getEnumOptions('accounts','shell');
$shell_tmp = select size=\1\ name=\shell[]\\n;
$shell_tmp .= optionDefault Shell/option\n;
$shell_tmp .= option-/option\n;
foreach ($shell_list as $item) {
  $shell_tmp .= option$item/option\n;
}
$shell_tmp .= /select\n;

$query_groups = SELECT name FROM grps;
$groups_tmp = mysql_query($query_groups, $Prod) or die(mysql_error());
$grp_list = select size=\1\ name=\grp[]\\n;
$grp_list .= optionPrimary Group/option\n;
$grp_list .= option---/option\n;
while($item2 = mysql_fetch_row($groups_tmp)) {
  $grp_list .= option$item2[0]/option\n;
}
$grp_list .= /select\n;

SNIP

?php
  while (isset($_POST['system'][$cntr])) {
echo td width=\20%\div align=\center\font
class=\style3\.$_POST['system'][$cntr]./font/div/td;
echo td width=\20%\div
align=\center\.$shell_tmp./div/td;
echo td width=\20%\div
align=\center\.$grp_list./div/td;
echo td width=\20%\div align=\center\input
type=\text\ name=\other[]\ value=\\ size=\15\/div/td/tr;
$tmp = $sbcuid.-.$_POST['system'][$cntr];
$cntr++;
array_push( $accnts, $tmp );
  }
?
/table
p align=centerfont class=style3strongIf the systems listed
above are correct, please
proceed. Otherwise, please hit the Back button on your browser and
review your
system selections again./strong/font/pp
align=centernbsp;/p
?php
  session_register(accnts, shell, grp, other, cntr);
?

Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com

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



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



[PHP-DB] Array problem...

2005-09-16 Thread NIPP, SCOTT V \(SBCSI\)
I am migrating a web app from an old server running PHP 4.2.3 to
a new server running 4.3.8.  The problem I am running into at the moment
is building an array and passing it to another page.  This code works
fine on the old server, but the array is not coming across to the new
page on the new server.  Help...

mysql_select_db($database, $Prod);
$shell_list = getEnumOptions('accounts','shell');
$shell_tmp = select size=\1\ name=\shell[]\\n;
$shell_tmp .= optionDefault Shell/option\n;
$shell_tmp .= option-/option\n;
foreach ($shell_list as $item) {
  $shell_tmp .= option$item/option\n;
}
$shell_tmp .= /select\n;

$query_groups = SELECT name FROM grps;
$groups_tmp = mysql_query($query_groups, $Prod) or die(mysql_error());
$grp_list = select size=\1\ name=\grp[]\\n;
$grp_list .= optionPrimary Group/option\n;
$grp_list .= option---/option\n;
while($item2 = mysql_fetch_row($groups_tmp)) {
  $grp_list .= option$item2[0]/option\n;
}
$grp_list .= /select\n;

SNIP

?php
  while (isset($_POST['system'][$cntr])) { 
echo td width=\20%\div align=\center\font
class=\style3\.$_POST['system'][$cntr]./font/div/td;
echo td width=\20%\div
align=\center\.$shell_tmp./div/td;
echo td width=\20%\div
align=\center\.$grp_list./div/td;
echo td width=\20%\div align=\center\input
type=\text\ name=\other[]\ value=\\ size=\15\/div/td/tr;
$tmp = $sbcuid.-.$_POST['system'][$cntr];
$cntr++;
array_push( $accnts, $tmp );
  }
?
/table
p align=centerfont class=style3strongIf the systems listed
above are correct, please 
proceed. Otherwise, please hit the Back button on your browser and
review your 
system selections again./strong/font/pp
align=centernbsp;/p
?php
  session_register(accnts, shell, grp, other, cntr);
?

Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com

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



[PHP-DB] array messing up

2004-11-19 Thread Rainer Bendig aka Ny
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

i don't know if this is the right list to post it, or php-general...
I am posting here because i think its database related.

so here we go:

I want to build an array containing two arrays $navm[] and $navs[],
$navs[] should go to $navm[items].

I am using an commercial db class to do my queries.

This is the snippet making my array:

- -sourcecode:start8--

$resultm = $db-query(SELECT * FROM .$p._cats  WHERE ms='m' \
   ORDER BY sortorder ASC);
while($work_res_navm = $db-fetch_array($resultm)) {
  $results = $db-query(SELECT * FROM .$p._cats  \
 WHERE master='.$work_res_navm['catid'].' \
 ORDER BY sortorder ASC);
 
   while($work_res_navs = $db-fetch_array($results)) {
 $navs[]=array('link'=$work_res_navs['link'], \
   'text'= $work_res_navs['name'], \
   'id'= $work_res_navs['catid'], \
   'master'=$work_res_navs['master']
   );
   }
  $navm[] =array('link'=$work_res_navm['link'], \
 'text'= $work_res_navm['name'], \
 'id'= $work_res_navm['catid'], \
 'items'=$navs);
};
- -sourcecode:stop-8--

table looks like this:
- -table:start-8--
 CREATE TABLE `ui_cats` (
   `catid` tinyint(11) NOT NULL auto_increment,
   `ms` char(1) NOT NULL default 's',
   `master` tinyint(1) NOT NULL default '1',
   `sortorder` tinyint(3) NOT NULL default '0',
   `name` varchar(150) NOT NULL default '',
   `link` varchar(150) NOT NULL default '',
   PRIMARY KEY  (`catid`)
   ) TYPE=MyISAM AUTO_INCREMENT=8 ;
- -table:stop--8--
 
MySQL Version: 3.23.58
PHP-Version:   4.2.2
( I can not update those versions..)

the array now looks like this:
$navm1-0
 $navs1-1
 $navs1-2
$navm2-0
 $navs1-1
 $navs1-2
 $navs2-1
$navm3-0
 $navs1-1
 $navs1-2
 $navs2-1
 $navs3-1

and the same procedure a lot more often... but it should look like
this:
$navm1-0
 $navs1-1
 $navs1-2
$navm2-0
 $navs2-1
$navm3-0
 $navs3-1
and so on

what is my error? i cant see it after trying several other querys in
two days :-(

any ideas?
thanks in advice
- -- 
- -
Rainer 'Ny' Bendig | http://UnresolvedIssue.org | GPG-Key: 0xCC7EA575
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBni4ltpAZoWtAN98RAi18AJ9ToJhWXlvJiVVE/GoH3ArHTYN/cACdHzU4
dU9lkx+M8UnVQPak/+ikQYs=
=su6z
-END PGP SIGNATURE-

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



[PHP-DB] Array and insert statement throws error

2004-10-15 Thread Stuart Felenstein
Trying to get array of values into table. 
Each value will be part of a new record, so it's a
loop.

I am getting a parse error though and for further down
in the code though I know this is what's causing it.
Is there anything wrong with this statement ?


if ( is_array( $_SESSION['l_industry'] ) ) {
foreach ( $_SESSION['l_industry'] as $p ) {
$query = INSERT INTO Profiles_Industries (ProfileID,
IndID)
VALUES ($LID, $p);   
}

Stuart

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Stuart Felenstein
Where would that go?

Stuart

--- Matt M. [EMAIL PROTECTED] wrote:

  if ( is_array( $_SESSION['l_industry'] ) ) {
  foreach ( $_SESSION['l_industry'] as $p )
 {
  $query = INSERT INTO Profiles_Industries
 (ProfileID,
  IndID)
  VALUES ($LID, $p);
  }
 
 do you have a } for the if statement?
 

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Matt M.
if ( is_array( $_SESSION['l_industry'] ) ) {
foreach ( $_SESSION['l_industry'] as $p ) {
$query = INSERT INTO Profiles_Industries (ProfileID,IndID) VALUES
($LID, $p);
} //foreach ( $_SESSION['l_industry'] as $p )
} //if ( is_array( $_SESSION['l_industry'] ) )

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Stuart Felenstein
Yep, I had found it shortly before.
Only it's not looping.  It is taking last value only.

Stuart


--- Matt M. [EMAIL PROTECTED] wrote:

 if ( is_array( $_SESSION['l_industry'] ) ) {
   foreach ( $_SESSION['l_industry'] as $p ) {
   $query = INSERT INTO Profiles_Industries
 (ProfileID,IndID) VALUES
 ($LID, $p);
   } //foreach ( $_SESSION['l_industry'] as $p )
 } //if ( is_array( $_SESSION['l_industry'] ) )
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Matt M.
where is your insert statement? I am guessing it is after your loop


if ( is_array( $_SESSION['l_industry'] ) ) {
foreach ( $_SESSION['l_industry'] as $p ) {
$query = INSERT INTO Profiles_Industries (ProfileID,IndID) VALUES
($LID, $p);
/This is where your insert statement should
be**/
} //foreach ( $_SESSION['l_industry'] as $p )
} //if ( is_array( $_SESSION['l_industry'] ) )

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Stuart Felenstein
Actually it did just loop.  I need to test again.  

The insert statement is the the one $query = 
So it's after yes, but contained in the braces, like
you diagram below.

Stuart
--- Matt M. [EMAIL PROTECTED] wrote:

 where is your insert statement? I am guessing it is
 after your loop
 
 
 if ( is_array( $_SESSION['l_industry'] ) ) {
   foreach ( $_SESSION['l_industry'] as $p ) {
   $query = INSERT INTO Profiles_Industries
 (ProfileID,IndID) VALUES
 ($LID, $p);
 /This is where your insert
 statement should
 be**/
   } //foreach ( $_SESSION['l_industry'] as $p )
 } //if ( is_array( $_SESSION['l_industry'] ) )
 

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Stuart Felenstein
Hopefully these functions will explain it.
I'm starting the transaction, then provided it takes
with no errors it gets the commit

function begin()
{
mysql_query(BEGIN);
}
function commit()
{
mysql_query(COMMIT);
}
function rollback()
{
mysql_query(ROLLBACK);
}

begin();
$query = INSERT INTO...

$result = mysql_query($query);
--- Brent Baisley [EMAIL PROTECTED] wrote:

 When are you actually performing the insert into the
 database? The code 
 you posted is only changing the value of the
 variable $query. You also 
 need to have the database function to insert into
 the database. 
 Assuming it MySQL:
 ...
 foreach(...) {
   $query = INSERT INTO ...;
   mysql_query($query);
 }
 
 On Oct 15, 2004, at 4:40 PM, Stuart Felenstein
 wrote:
 
  Yep, I had found it shortly before.
  Only it's not looping.  It is taking last value
 only.
 
  Stuart
 
 
  --- Matt M. [EMAIL PROTECTED] wrote:
 
  if ( is_array( $_SESSION['l_industry'] ) ) {
 foreach ( $_SESSION['l_industry'] as $p ) {
 $query = INSERT INTO Profiles_Industries
  (ProfileID,IndID) VALUES
  ($LID, $p);
 } //foreach ( $_SESSION['l_industry'] as $p )
  } //if ( is_array( $_SESSION['l_industry'] ) )
 
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
 
 
 
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
 
 
 -- 
 Brent Baisley
 Systems Architect
 Landover Associates, Inc.
 Search  Advisory Services for Advanced Technology
 Environments
 p: 212.759.6400/800.759.0577
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



[PHP-DB] Array

2004-08-26 Thread 'Miguel Guirao'
Hi!!

I have a table with many options from when the user can select them,
after that, his/her selections will be stored in a database.

In the mean time, I want to store his/her selections in an array like
this one:

PN  DescQty
|---|--|---|
|---|--|---|
|---|--|---|

How do I declare Duch an array like this??, let's call it Parts.


Miguel Guirao
Servicios Datacard
www.SIASA.com.mx

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



Re: [PHP-DB] Array

2004-08-26 Thread Justin Patrin
$arr = array('key' = array('key2' = 'value', 'key3' = 'value', ...),
...);

$arr['key2'] = array('key2' = 'value', ...);

$arr['key3]['key2'] = 'value';

On Thu, 26 Aug 2004 16:11:27 -0500, Miguel Guirao [EMAIL PROTECTED] wrote:
 Hi!!
 
 I have a table with many options from when the user can select them,
 after that, his/her selections will be stored in a database.
 
 In the mean time, I want to store his/her selections in an array like
 this one:
 
 PN  DescQty
 |---|--|---|
 |---|--|---|
 |---|--|---|
 
 How do I declare Duch an array like this??, let's call it Parts.
 
 Miguel Guirao
 Servicios Datacard
 www.SIASA.com.mx
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 !DSPAM:412dfd2d29942082615647!
 
 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP-DB] Array

2004-08-26 Thread Micah Stevens
Since you provided no value's it's a little tough, but the general for would 
be:

$parts = array(
  array(PN = $row1col1, Desc = $row1col2, Qty = $row1col3),
  array(PN = $row2col1, Desc = $row2col2, Qty = $row2col3)
 );

Depending on your implimentation, it maybe easier to use some sort of loop to 
assign things. If you wanted the array to be persistant across pages, you'd 
want to user instead of $parts, $_SESSION['parts']. (assuming of course you 
have initialized a session)

I personally would skip the array stuff and just pop it in a database. 
-Micah 

On Thursday 26 August 2004 02:11 pm, 'Miguel Guirao' wrote:
 Hi!!

 I have a table with many options from when the user can select them,
 after that, his/her selections will be stored in a database.

 In the mean time, I want to store his/her selections in an array like
 this one:

 PNDescQty

 |---|--|---|
 |---|--|---|
 |---|--|---|

 How do I declare Duch an array like this??, let's call it Parts.


 Miguel Guirao
 Servicios Datacard
 www.SIASA.com.mx

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



[PHP-DB] array months

2004-02-25 Thread peppe
Hi I realy need help hier
I have a aaray of months
$lang['months'] = array
( 1 = Januari, 2 = Februari, 3 = Maart, 4 = April, 5 = Mei,
6 = Juni, 7 = Juli, 8 = Augustus, 9 = September, 10 =
Oktober,
11 = November, 12 = December
);
and a function
function showMonths2($montharray)
{

$maand = sprintf(%d, date(m));
$jaar = date(Y);

for ($inx=$maand; $inx=12; $inx++)
echo a
href='welkom.php?welkom_id=6month=$inxyear=$jaar'$montharray[$inx]
/anbsp; ;

$jaar++;
for ($inx=0; $inx$maand; $inx++)
echo a
href='welkom.php?welkom_id=6month=$inxyear=$jaarver=ok'$montharray[$inx]
/anbsp;;
}

The result is starts from Februari Maart .. .. December and then Januari
2005 the problem is when I click Januari 2005 I want to show months from
Januari 2005 till December 2005 and so on

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



[PHP-DB] Array sorting question...

2004-01-23 Thread NIPP, SCOTT V (SBCSI)
I am trying to populate an array from a MySQL database.  I think I
have the code correct to populate the array, but I need to somehow sort the
array eliminating duplicate values.  I think I can loop through the array
doing a comparison and building a new array by discarding the value if it is
a duplicate, but I was not sure if there was a more efficient way of doing
this.  I am already looping through the database query results, and I am
just thinking about efficiency here.
Here is a code sample with a little more description of what I am
attempting...

?php
  do {
$entry = $list['id_sys'];
$id = split('-', $list['id_sys'], 1);
$sbcuid = $id[0];
$users[] = '$sbcuid';  
  } while ($list = mysql_fetch_assoc($result));
?

This query pulls a value from the database that is a
username-hostname value.  What I am working on is building a page that has a
unique list of usernames that link to a second page of user account
information.  There may be twenty user account on different hosts for the
same username.  I only want to have the username link created once on this
page.  I hope that makes since to everyone.  Thanks in advance for any help.

Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com

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



RE: [PHP-DB] Array sorting question...

2004-01-23 Thread Katie Evans-Young
NIPP, SCOTT V (SBCSI) wrote:
   I am trying to populate an array from a MySQL database.  I think I
 have the code correct to populate the array, but I need to somehow
 sort the array eliminating duplicate values.  I think I can loop
 through the array doing a comparison and building a new array by
 discarding the value if it is a duplicate, but I was not sure if
 there was a more efficient way of doing this.

You can ask for only unique values to be returned in the database result.

Try something like this:

$sql = SELECT UNIQUE username FROM table WHERE where_clause ORDER BY
username;

Katie Dewees
Web Developer/PHP Programmer
[EMAIL PROTECTED]
http://www.evans-young.com

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



[PHP-DB] array

2003-12-11 Thread peppe
Hi
I have a variable cold $access and there are values 1,2,3,4,5
How can I check for example
If ($access =='2'){
echo go further;
}
How can I make this work
Thanx in advance

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



RE: [PHP-DB] array

2003-12-11 Thread brettking

Hi

From what I can work out you need to use a function called
in_array(value,array);
http://www.php.net/manual/en/function.in-array.php here is the php manual
link

Hope this is what you want
Brett
-Original Message-
From: peppe [mailto:[EMAIL PROTECTED]
Sent: 11 December 2003 16:07
To: [EMAIL PROTECTED]
Subject: [PHP-DB] array


Hi
I have a variable cold $access and there are values 1,2,3,4,5
How can I check for example
If ($access =='2'){
echo go further;
}
How can I make this work
Thanx in advance

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


Email has been scanned for viruses by www.emf-systems.com

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



Re: [PHP-DB] array

2003-12-11 Thread peppe
Hi
Pete I forgot to write that $acces is a field from Db and there are values
1,2,3,4
a need to split those values to make that IF
Brettking thanx mate I think that is a solution


Brettking [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 Hi

 From what I can work out you need to use a function called
 in_array(value,array);
 http://www.php.net/manual/en/function.in-array.php here is the php manual
 link

 Hope this is what you want
 Brett
 -Original Message-
 From: peppe [mailto:[EMAIL PROTECTED]
 Sent: 11 December 2003 16:07
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] array


 Hi
 I have a variable cold $access and there are values 1,2,3,4,5
 How can I check for example
 If ($access =='2'){
 echo go further;
 }
 How can I make this work
 Thanx in advance

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


 Email has been scanned for viruses by www.emf-systems.com

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



Re: [PHP-DB] Array question

2003-11-25 Thread CPT John W. Holmes
From: ShortStay [EMAIL PROTECTED]

 How do you delete a value and key from an array?  I know the value.

You need to know the key.

unset($Array[$key]);

There are various array functions that'll find the key for you if you know
the value.

 Is it OK to post array questions to the db list?

Not really... use php-general

---John Holmes...

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



[PHP-DB] array issue

2003-08-17 Thread OpenSource
hi ya'll

I am having a nightmare on this issue of mine.
I've got this array that I need to write to a file...
 sample code below 

while (something);
{
query data base

$r_ul=ifx_fetch_row($sideQuery4);

$type1 = array($rotation.\n);

switch ($r_ul['number'])
   {
case '4';
$linea = $type1;
break;
   }

$final = $linea[0];

$my_array = array();
array_push ($my_array, $final);

}
 
$file = 'db_dump.dat';
$fp = fopen($file, w);
fputs($fp, $my_array); --- I would like to write the complete array into the file
fclose($fp);

kindly assist with this issue..

Thanks in advance


RE: [PHP-DB] array issue

2003-08-17 Thread Aaron Wolski
First, are you sure there is data in $my_array?

Add this after you set the array:

echo pre.print_r($my_array)./pre;

You'll need to loop through the array , writing each line in the file at
a time.

Something like:

//open the file stuff here
foreach ($my_array AS $values)
{

fputs($fp, $value);

}
//close the file stuff here

HTH

Aaron

 -Original Message-
 From: OpenSource [mailto:[EMAIL PROTECTED]
 Sent: August 17, 2003 11:31 AM
 To: PHP-DB
 Subject: [PHP-DB] array issue
 Importance: High
 
 hi ya'll
 
 I am having a nightmare on this issue of mine.
 I've got this array that I need to write to a file...
  sample code below 
 
 while (something);
 {
 query data base
 
 $r_ul=ifx_fetch_row($sideQuery4);
 
 $type1 = array($rotation.\n);
 
 switch ($r_ul['number'])
{
 case '4';
 $linea = $type1;
 break;
}
 
 $final = $linea[0];
 
 $my_array = array();
 array_push ($my_array, $final);
 
 }
 
 $file = 'db_dump.dat';
 $fp = fopen($file, w);
 fputs($fp, $my_array); --- I would like to write the complete array
into
 the file
 fclose($fp);
 
 kindly assist with this issue..
 
 Thanks in advance



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



RE: [PHP-DB] array issue

2003-08-17 Thread jeffrey_n_Dyke

This may or may not make sense for your issue.  but if you have the whole
array in memory you can serialize()  it and write the string that the
function returns to the file.

$fp = fopen(yourfilename.txt, w);
$my_array_s = serialize($my_array);
if (isset($fp)) {
  fwrite($fp, $my_array_s);
}

//to get it back into the same array as it was written, use
$fp_cache = fopen(yourfilename.txt, r) or die(can't open file);
$fp_readc = fread($fp_cache, filesize(yourfilename.txt);
$my_array_new = unserialize($fp_readc);

the data is exactly as it was returned from the db after you looped through
the record set.

another idea. --http://www.php.net/manual/en/function.serialize.php
hth
jeff


   

  Aaron Wolski   

  [EMAIL PROTECTED]To:   'OpenSource' [EMAIL 
PROTECTED], 'PHP-DB' [EMAIL PROTECTED]  
  z.com   cc: 

   Subject:  RE: [PHP-DB] array issue  

  08/17/2003 11:33 

  AM   

   

   





First, are you sure there is data in $my_array?

Add this after you set the array:

echo pre.print_r($my_array)./pre;

You'll need to loop through the array , writing each line in the file at
a time.

Something like:

//open the file stuff here
foreach ($my_array AS $values)
{

 fputs($fp, $value);

}
//close the file stuff here

HTH

Aaron

 -Original Message-
 From: OpenSource [mailto:[EMAIL PROTECTED]
 Sent: August 17, 2003 11:31 AM
 To: PHP-DB
 Subject: [PHP-DB] array issue
 Importance: High

 hi ya'll

 I am having a nightmare on this issue of mine.
 I've got this array that I need to write to a file...
  sample code below 

 while (something);
 {
 query data base

 $r_ul=ifx_fetch_row($sideQuery4);

 $type1 = array($rotation.\n);

 switch ($r_ul['number'])
{
 case '4';
 $linea = $type1;
 break;
}

 $final = $linea[0];

 $my_array = array();
 array_push ($my_array, $final);

 }

 $file = 'db_dump.dat';
 $fp = fopen($file, w);
 fputs($fp, $my_array); --- I would like to write the complete array
into
 the file
 fclose($fp);

 kindly assist with this issue..

 Thanks in advance



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






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



RE: [PHP-DB] array issue

2003-08-17 Thread Aaron Wolski
Good point and nice find, Jeff!

I wasn't sure where he was going with the data.. was he trying to save
the actual array, intact, for say a chaching exercise or did he want to
insert the contents of that array into a file?

Could go either way I suppose :)

Aaron

P.S. Working on a Sunday too?

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: August 17, 2003 11:48 AM
 To: Aaron Wolski
 Cc: 'PHP-DB'; 'OpenSource'
 Subject: RE: [PHP-DB] array issue
 
 
 This may or may not make sense for your issue.  but if you have the
whole
 array in memory you can serialize()  it and write the string that the
 function returns to the file.
 
 $fp = fopen(yourfilename.txt, w);
 $my_array_s = serialize($my_array);
 if (isset($fp)) {
   fwrite($fp, $my_array_s);
 }
 
 //to get it back into the same array as it was written, use
 $fp_cache = fopen(yourfilename.txt, r) or die(can't open file);
 $fp_readc = fread($fp_cache, filesize(yourfilename.txt);
 $my_array_new = unserialize($fp_readc);
 
 the data is exactly as it was returned from the db after you looped
 through
 the record set.
 
 another idea. --http://www.php.net/manual/en/function.serialize.php
 hth
 jeff
 
 
 
   Aaron Wolski
   [EMAIL PROTECTED]To:
'OpenSource'
 [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED]
   z.com   cc:
Subject:  RE: [PHP-DB]
 array issue
   08/17/2003 11:33
   AM
 
 
 
 
 
 
 First, are you sure there is data in $my_array?
 
 Add this after you set the array:
 
 echo pre.print_r($my_array)./pre;
 
 You'll need to loop through the array , writing each line in the file
at
 a time.
 
 Something like:
 
 //open the file stuff here
 foreach ($my_array AS $values)
 {
 
  fputs($fp, $value);
 
 }
 //close the file stuff here
 
 HTH
 
 Aaron
 
  -Original Message-
  From: OpenSource [mailto:[EMAIL PROTECTED]
  Sent: August 17, 2003 11:31 AM
  To: PHP-DB
  Subject: [PHP-DB] array issue
  Importance: High
 
  hi ya'll
 
  I am having a nightmare on this issue of mine.
  I've got this array that I need to write to a file...
   sample code below 
 
  while (something);
  {
  query data base
 
  $r_ul=ifx_fetch_row($sideQuery4);
 
  $type1 = array($rotation.\n);
 
  switch ($r_ul['number'])
 {
  case '4';
  $linea = $type1;
  break;
 }
 
  $final = $linea[0];
 
  $my_array = array();
  array_push ($my_array, $final);
 
  }
 
  $file = 'db_dump.dat';
  $fp = fopen($file, w);
  fputs($fp, $my_array); --- I would like to write the complete array
 into
  the file
  fclose($fp);
 
  kindly assist with this issue..
 
  Thanks in advance
 
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 




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



Re: [PHP-DB] array issue

2003-08-17 Thread OpenSource
Hey guys thanks a lot
your method worked perfect Aaron, thanks
and that serialize() function, hummm i got to go do some reading and
testing.

thanks for enlightenment and the assistance guys.

RedHat.OpenSource.bz

- Original Message - 
From: Aaron Wolski [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: 'PHP-DB' [EMAIL PROTECTED]; 'OpenSource' [EMAIL PROTECTED]
Sent: Sunday, August 17, 2003 10:04 AM
Subject: RE: [PHP-DB] array issue


 Good point and nice find, Jeff!

 I wasn't sure where he was going with the data.. was he trying to save
 the actual array, intact, for say a chaching exercise or did he want to
 insert the contents of that array into a file?

 Could go either way I suppose :)

 Aaron

 P.S. Working on a Sunday too?

  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
  Sent: August 17, 2003 11:48 AM
  To: Aaron Wolski
  Cc: 'PHP-DB'; 'OpenSource'
  Subject: RE: [PHP-DB] array issue
 
 
  This may or may not make sense for your issue.  but if you have the
 whole
  array in memory you can serialize()  it and write the string that the
  function returns to the file.
 
  $fp = fopen(yourfilename.txt, w);
  $my_array_s = serialize($my_array);
  if (isset($fp)) {
fwrite($fp, $my_array_s);
  }
 
  //to get it back into the same array as it was written, use
  $fp_cache = fopen(yourfilename.txt, r) or die(can't open file);
  $fp_readc = fread($fp_cache, filesize(yourfilename.txt);
  $my_array_new = unserialize($fp_readc);
 
  the data is exactly as it was returned from the db after you looped
  through
  the record set.
 
  another idea. --http://www.php.net/manual/en/function.serialize.php
  hth
  jeff
 
 
 
Aaron Wolski
[EMAIL PROTECTED]To:
 'OpenSource'
  [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED]
z.com   cc:
 Subject:  RE: [PHP-DB]
  array issue
08/17/2003 11:33
AM
 
 
 
 
 
 
  First, are you sure there is data in $my_array?
 
  Add this after you set the array:
 
  echo pre.print_r($my_array)./pre;
 
  You'll need to loop through the array , writing each line in the file
 at
  a time.
 
  Something like:
 
  //open the file stuff here
  foreach ($my_array AS $values)
  {
 
   fputs($fp, $value);
 
  }
  //close the file stuff here
 
  HTH
 
  Aaron
 
   -Original Message-
   From: OpenSource [mailto:[EMAIL PROTECTED]
   Sent: August 17, 2003 11:31 AM
   To: PHP-DB
   Subject: [PHP-DB] array issue
   Importance: High
  
   hi ya'll
  
   I am having a nightmare on this issue of mine.
   I've got this array that I need to write to a file...
    sample code below 
  
   while (something);
   {
   query data base
  
   $r_ul=ifx_fetch_row($sideQuery4);
  
   $type1 = array($rotation.\n);
  
   switch ($r_ul['number'])
  {
   case '4';
   $linea = $type1;
   break;
  }
  
   $final = $linea[0];
  
   $my_array = array();
   array_push ($my_array, $final);
  
   }
  
   $file = 'db_dump.dat';
   $fp = fopen($file, w);
   fputs($fp, $my_array); --- I would like to write the complete array
  into
   the file
   fclose($fp);
  
   kindly assist with this issue..
  
   Thanks in advance
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 




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


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



RE: [PHP-DB] array issue

2003-08-17 Thread Aaron Wolski
Hey,

That's what we're here for :)

As for serialize? It's a great function if you need to preserve an array
in its original form.

Useful for sending back and forth between pages in the URL. Though, I'd
never use on an open URL for the general public. Maybe in an
Administration system not seen by many users.

Aaron

 -Original Message-
 From: OpenSource [mailto:[EMAIL PROTECTED]
 Sent: August 17, 2003 12:28 PM
 To: Aaron Wolski
 Cc: PHP-DB; [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] array issue
 Importance: High
 
 Hey guys thanks a lot
 your method worked perfect Aaron, thanks
 and that serialize() function, hummm i got to go do some reading and
 testing.
 
 thanks for enlightenment and the assistance guys.
 
 RedHat.OpenSource.bz
 
 - Original Message -
 From: Aaron Wolski [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Cc: 'PHP-DB' [EMAIL PROTECTED]; 'OpenSource'
 [EMAIL PROTECTED]
 Sent: Sunday, August 17, 2003 10:04 AM
 Subject: RE: [PHP-DB] array issue
 
 
  Good point and nice find, Jeff!
 
  I wasn't sure where he was going with the data.. was he trying to
save
  the actual array, intact, for say a chaching exercise or did he want
to
  insert the contents of that array into a file?
 
  Could go either way I suppose :)
 
  Aaron
 
  P.S. Working on a Sunday too?
 
   -Original Message-
   From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
   Sent: August 17, 2003 11:48 AM
   To: Aaron Wolski
   Cc: 'PHP-DB'; 'OpenSource'
   Subject: RE: [PHP-DB] array issue
  
  
   This may or may not make sense for your issue.  but if you have
the
  whole
   array in memory you can serialize()  it and write the string that
the
   function returns to the file.
  
   $fp = fopen(yourfilename.txt, w);
   $my_array_s = serialize($my_array);
   if (isset($fp)) {
 fwrite($fp, $my_array_s);
   }
  
   //to get it back into the same array as it was written, use
   $fp_cache = fopen(yourfilename.txt, r) or die(can't open
file);
   $fp_readc = fread($fp_cache, filesize(yourfilename.txt);
   $my_array_new = unserialize($fp_readc);
  
   the data is exactly as it was returned from the db after you
looped
   through
   the record set.
  
   another idea.
--http://www.php.net/manual/en/function.serialize.php
   hth
   jeff
  
  
  
 Aaron Wolski
 [EMAIL PROTECTED]To:
  'OpenSource'
   [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED]
 z.com   cc:
  Subject:  RE:
[PHP-DB]
   array issue
 08/17/2003 11:33
 AM
  
  
  
  
  
  
   First, are you sure there is data in $my_array?
  
   Add this after you set the array:
  
   echo pre.print_r($my_array)./pre;
  
   You'll need to loop through the array , writing each line in the
file
  at
   a time.
  
   Something like:
  
   //open the file stuff here
   foreach ($my_array AS $values)
   {
  
fputs($fp, $value);
  
   }
   //close the file stuff here
  
   HTH
  
   Aaron
  
-Original Message-
From: OpenSource [mailto:[EMAIL PROTECTED]
Sent: August 17, 2003 11:31 AM
To: PHP-DB
Subject: [PHP-DB] array issue
Importance: High
   
hi ya'll
   
I am having a nightmare on this issue of mine.
I've got this array that I need to write to a file...
 sample code below 
   
while (something);
{
query data base
   
$r_ul=ifx_fetch_row($sideQuery4);
   
$type1 = array($rotation.\n);
   
switch ($r_ul['number'])
   {
case '4';
$linea = $type1;
break;
   }
   
$final = $linea[0];
   
$my_array = array();
array_push ($my_array, $final);
   
}
   
$file = 'db_dump.dat';
$fp = fopen($file, w);
fputs($fp, $my_array); --- I would like to write the complete
array
   into
the file
fclose($fp);
   
kindly assist with this issue..
   
Thanks in advance
  
  
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
  
 
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php




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



RE: [PHP-DB] array fill/sort question

2003-06-11 Thread Snijders, Mark
hi,

no the both sollutions won't work cause:

I can't sort within a query cause subnetaddr is a varchar (10.10.10.10)

so it will be ordere like this

10.10.10.10
100.10.10.10
60.10.10.10

and that's not good cause 60 is smaller as 100, so with the function
ip2long() i will first make an integer of it


the second array solution you gave, won't work, cause I need ALL the query
results in the array, and that's the problem I can't handle


if I would do it like you said, I can sort it, but then I have a sorted
array and for each element I have to do a query again to get the other
fields of the table, and that's not good (2500 rows)

so can please still somebody help me with this?




-Original Message-
From: Becoming Digital [mailto:[EMAIL PROTECTED]
Sent: dinsdag 10 juni 2003 15:42
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] array fill/sort question


I might be overlooking something, but can't you just do this?

$query = SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain,
location, contact, ccn FROM subnets ORDER BY subnetaddr;


If you can't, you can sort the array like this.

?
$query = SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain,
location, contact, ccn FROM subnets;
$results = mysql_query( $query );

while ( $iptable = mysql_fetch_array( $result ) ) {
$iptable['subnetaddr'] = ip2long( $iptable['subnetaddr'] );
}
?

You can subsequently sort the array for the desired result.

Edward Dudlik
Becoming Digital
www.becomingdigital.com


- Original Message - 
From: Snijders, Mark [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, 10 June, 2003 08:55
Subject: [PHP-DB] array fill/sort question


hi,

I'm working on a ipaddres/subnet programm

now i have a talbe with a lot of information about ip-addresses

i'm having this query:

SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain, location, contact,
ccn FROM subnets

the subnetaddr field looks like this : 100.20.20.1  and is ofcourse a
varchar field

BUT before displaying it on the screen i have to sort it by subnetaddr and
then show it

but i have to sort it as integer, so i use the php-function ip2long();

so you get a decimal...

so what i have to do:

do the query make a decimal field of the 'subnetaddr' put it in an array,
sort it and display it


BUT how can i put ALL of the fields in the query in an array, sort it, and
then display it?

please help me, I can't work it out :(

thanks, Mark




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



Re: [PHP-DB] array fill/sort question

2003-06-11 Thread Ignatius Reilly
Another approach:

1. Load all results from the query in an array
2. Sort the array using a custom-defined user-defined comparison function
( usort() ). Study the example in the PHP manual.
Writing your own comparison function is easy:
- explode your IP addresses in 4 items each ( explode() )
- compare successively item by item

HTH
Ignatius
_
- Original Message -
From: Snijders, Mark [EMAIL PROTECTED]
To: 'Becoming Digital' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, June 11, 2003 8:33 AM
Subject: RE: [PHP-DB] array fill/sort question


 hi,

 no the both sollutions won't work cause:

 I can't sort within a query cause subnetaddr is a varchar (10.10.10.10)

 so it will be ordere like this

 10.10.10.10
 100.10.10.10
 60.10.10.10

 and that's not good cause 60 is smaller as 100, so with the function
 ip2long() i will first make an integer of it


 the second array solution you gave, won't work, cause I need ALL the query
 results in the array, and that's the problem I can't handle


 if I would do it like you said, I can sort it, but then I have a sorted
 array and for each element I have to do a query again to get the other
 fields of the table, and that's not good (2500 rows)

 so can please still somebody help me with this?




 -Original Message-
 From: Becoming Digital [mailto:[EMAIL PROTECTED]
 Sent: dinsdag 10 juni 2003 15:42
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] array fill/sort question


 I might be overlooking something, but can't you just do this?

 $query = SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain,
 location, contact, ccn FROM subnets ORDER BY subnetaddr;


 If you can't, you can sort the array like this.

 ?
 $query = SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain,
 location, contact, ccn FROM subnets;
 $results = mysql_query( $query );

 while ( $iptable = mysql_fetch_array( $result ) ) {
 $iptable['subnetaddr'] = ip2long( $iptable['subnetaddr'] );
 }
 ?

 You can subsequently sort the array for the desired result.

 Edward Dudlik
 Becoming Digital
 www.becomingdigital.com


 - Original Message -
 From: Snijders, Mark [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, 10 June, 2003 08:55
 Subject: [PHP-DB] array fill/sort question


 hi,

 I'm working on a ipaddres/subnet programm

 now i have a talbe with a lot of information about ip-addresses

 i'm having this query:

 SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain, location,
contact,
 ccn FROM subnets

 the subnetaddr field looks like this : 100.20.20.1  and is ofcourse a
 varchar field

 BUT before displaying it on the screen i have to sort it by subnetaddr and
 then show it

 but i have to sort it as integer, so i use the php-function ip2long();

 so you get a decimal...

 so what i have to do:

 do the query make a decimal field of the 'subnetaddr' put it in an array,
 sort it and display it


 BUT how can i put ALL of the fields in the query in an array, sort it, and
 then display it?

 please help me, I can't work it out :(

 thanks, Mark




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




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



Re: [PHP-DB] array fill/sort question

2003-06-11 Thread Sean Burlington
Snijders, Mark wrote:
hi,

no the both sollutions won't work cause:

I can't sort within a query cause subnetaddr is a varchar (10.10.10.10)

so it will be ordere like this

10.10.10.10
100.10.10.10
60.10.10.10
and that's not good cause 60 is smaller as 100, so with the function
ip2long() i will first make an integer of it
the second array solution you gave, won't work, cause I need ALL the query
results in the array, and that's the problem I can't handle
if I would do it like you said, I can sort it, but then I have a sorted
array and for each element I have to do a query again to get the other
fields of the table, and that's not good (2500 rows)
so can please still somebody help me with this?


can you change the database format ?

store the address  as four ints - then you can concatenate them when you 
need to, and sort as you wish

SELECT s_id, subnet_name, concat(subnetaddr1, '.', subnetaddr2, '.', 
subnetaddr3, '.', subnetaddr4) as subnetaddr ,subnetmask,dnsdomain, 
location, contact, ccn
FROM subnets
ORDER BY subnetaddr1, subnetaddr2, subnetaddr3, subnetaddr4;

--

Sean

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


[PHP-DB] array fill/sort question

2003-06-10 Thread Snijders, Mark
hi,

I'm working on a ipaddres/subnet programm

now i have a talbe with a lot of information about ip-addresses

i'm having this query:

SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain, location, contact,
ccn FROM subnets

the subnetaddr field looks like this : 100.20.20.1  and is ofcourse a
varchar field

BUT before displaying it on the screen i have to sort it by subnetaddr and
then show it

but i have to sort it as integer, so i use the php-function ip2long();

so you get a decimal...

so what i have to do:

do the query make a decimal field of the 'subnetaddr' put it in an array,
sort it and display it


BUT how can i put ALL of the fields in the query in an array, sort it, and
then display it?

please help me, I can't work it out :(

thanks, Mark



Re: [PHP-DB] array fill/sort question

2003-06-10 Thread Kieu D. Trang
hi,

you can add the ip2long() function into your SELECT statement and have
an ORDER BY clause at the end like this...

SELECT s_id, subnet_name, ip2long('subnetaddr'), subnetmask,dnsdomain,
location, contact, ccn FROM subnets ORDER BY subnetaddrr;

hope it helps.
KD


On Tue, 10 Jun 2003, Snijders, Mark wrote:

 hi,

 I'm working on a ipaddres/subnet programm

 now i have a talbe with a lot of information about ip-addresses

 i'm having this query:

 SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain, location, contact,
 ccn FROM subnets

 the subnetaddr field looks like this : 100.20.20.1  and is ofcourse a
 varchar field

 BUT before displaying it on the screen i have to sort it by subnetaddr and
 then show it

 but i have to sort it as integer, so i use the php-function ip2long();

 so you get a decimal...

 so what i have to do:

 do the query make a decimal field of the 'subnetaddr' put it in an array,
 sort it and display it


 BUT how can i put ALL of the fields in the query in an array, sort it, and
 then display it?

 please help me, I can't work it out :(

 thanks, Mark



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



Re: [PHP-DB] array fill/sort question

2003-06-10 Thread Becoming Digital
I might be overlooking something, but can't you just do this?

$query = SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain,
location, contact, ccn FROM subnets ORDER BY subnetaddr;


If you can't, you can sort the array like this.

?
$query = SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain,
location, contact, ccn FROM subnets;
$results = mysql_query( $query );

while ( $iptable = mysql_fetch_array( $result ) ) {
$iptable['subnetaddr'] = ip2long( $iptable['subnetaddr'] );
}
?

You can subsequently sort the array for the desired result.

Edward Dudlik
Becoming Digital
www.becomingdigital.com


- Original Message - 
From: Snijders, Mark [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, 10 June, 2003 08:55
Subject: [PHP-DB] array fill/sort question


hi,

I'm working on a ipaddres/subnet programm

now i have a talbe with a lot of information about ip-addresses

i'm having this query:

SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain, location, contact,
ccn FROM subnets

the subnetaddr field looks like this : 100.20.20.1  and is ofcourse a
varchar field

BUT before displaying it on the screen i have to sort it by subnetaddr and
then show it

but i have to sort it as integer, so i use the php-function ip2long();

so you get a decimal...

so what i have to do:

do the query make a decimal field of the 'subnetaddr' put it in an array,
sort it and display it


BUT how can i put ALL of the fields in the query in an array, sort it, and
then display it?

please help me, I can't work it out :(

thanks, Mark




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



Re: [PHP-DB] Array Pointer

2003-06-05 Thread Chris Mach
My database is set up in this way:

fan_roster: has player id (play_id) , week, and stats on that player for
that week. So there are 20 records for each player, because there are 20
weeks.

So what I need to do is add up all the players weekly totals. so pass_yrd1
for week1 + pass_yrd1 for week2 etc.

Then I need to put the season total for that players passing yards into my
roster table under pass_yrd. The roster table only as 1 record per player
and has season stats instead of weekly stats.

So when my loop goes through and doesn't match $i with ros_id. I need to
advance $i one but ros_id needs to stay the same until there is a match.

As you can see form this url:
http://55yardline.cflmain.com/55main/2003/fantasy/tests/update.php
it's kind of working, except where there are holes in the roster table..
for example, there is no ros_id equal to 12 so it should echo 12 no player
but it seems to skip.

Hope that makes sense.


Mike Ford [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
  -Original Message-
  From: Ian Fingold [mailto:[EMAIL PROTECTED]
  Sent: 03 June 2003 16:58
 
  Ok I'm trying to write this function to up date some fields
  in my database
  so i'm grabbing some info from a query and throwing it into
  an array (with
  mysql_fetch_array).
 
  one of the values i'm puting into that array is the table id. I'm then
  comparing the table id with the value of $i in my loop. Now
  my problem is
  when I loop through and the table id is not equal to $i I
  need to add 1 to
  $i but I need to move the array pointer back one.
 
  In the code below I used prev() but i'm getting warnings
  about the Passed
  variable is not an array.
  http://55yardline.cflmain.com/55main/2003/fantasy/tests/update.php
 
  I'm thinking that prev() must not view an array fetch from a
  database the
  same or something. But what else can I use besides prev() to
  rewind the
  pointer by 1?
 
  Thanks,
 
 
  ?php
 
  include function.php;
  connect1();
 
  //query roster database and put results into an array.
  $num1 = mysql_query(SELECT * FROM roster);
  $num2 = mysql_fetch_array($num1);
  //set i to zero
  $i = 0;
 
  //start loop to determine if $i matches the current roster id
  do {
$i = $i + 1;
if ($num2[ros_id] == $i) {
  //if a match is found, query the fan_roster database
  where the play_id =
  $i
  //and put the results into a array
  $upd = mysql_query(SELECT * FROM fan_roster WHERE play_id='$i');
  $updr = mysql_fetch_array($upd);
  //loop through the passing field and add them up
  do {
  $passing = $passing + $updr[pass_yrd1];
  } while($updr = mysql_fetch_array($upd));
 
  //Print feedback
  echo Player:$i total Passing: $passing $updr[play_id]br;
 
  //update the roster table with the total $passing where ros_id=$i
  $upd1 = mysql_query(UPDATE roster SET pass_yrd='$passing' WHERE
  ros_id='$i');
  //reset passing for next loop
  $passing = 0;
} else {
  //if there isn't a match, add 1 to $i
  $i = $i + 1;
 
  //print feedback
  echo $i no playerbr;
 
  //put the array pointer back one for next loop
  $num2 = prev($num2[ros_id];

 (1) prev() takes an array as its argument, not an individual element, so
prev($num2) would be syntactically correct (but I doubt it's what you really
mean).
 (2) anyway, this whole statement is pointless as you immediately do:

}
  } while($num2 = mysql_fetch_array($num1));

 Which promptly overwrites the value of $num2 you just put there!

 What are you *really* trying to do?
  ?
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 



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



[PHP-DB] Array Pointer

2003-06-04 Thread Ian Fingold
Ok I'm trying to write this function to up date some fields in my database
so i'm grabbing some info from a query and throwing it into an array (with
mysql_fetch_array).

one of the values i'm puting into that array is the table id. I'm then
comparing the table id with the value of $i in my loop. Now my problem is
when I loop through and the table id is not equal to $i I need to add 1 to
$i but I need to move the array pointer back one.

In the code below I used prev() but i'm getting warnings about the Passed
variable is not an array.
http://55yardline.cflmain.com/55main/2003/fantasy/tests/update.php

I'm thinking that prev() must not view an array fetch from a database the
same or something. But what else can I use besides prev() to rewind the
pointer by 1?

Thanks,


?php

include function.php;
connect1();

//query roster database and put results into an array.
$num1 = mysql_query(SELECT * FROM roster);
$num2 = mysql_fetch_array($num1);
//set i to zero
$i = 0;

//start loop to determine if $i matches the current roster id
do {
  $i = $i + 1;
  if ($num2[ros_id] == $i) {
//if a match is found, query the fan_roster database where the play_id =
$i
//and put the results into a array
$upd = mysql_query(SELECT * FROM fan_roster WHERE play_id='$i');
$updr = mysql_fetch_array($upd);
//loop through the passing field and add them up
do {
$passing = $passing + $updr[pass_yrd1];
} while($updr = mysql_fetch_array($upd));

//Print feedback
echo Player:$i total Passing: $passing $updr[play_id]br;

//update the roster table with the total $passing where ros_id=$i
$upd1 = mysql_query(UPDATE roster SET pass_yrd='$passing' WHERE
ros_id='$i');
//reset passing for next loop
$passing = 0;
  } else {
//if there isn't a match, add 1 to $i
$i = $i + 1;

//print feedback
echo $i no playerbr;

//put the array pointer back one for next loop
$num2 = prev($num2[ros_id];
  }
} while($num2 = mysql_fetch_array($num1));
?



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



RE: [PHP-DB] Array Pointer

2003-06-04 Thread Ford, Mike [LSS]
 -Original Message-
 From: Ian Fingold [mailto:[EMAIL PROTECTED]
 Sent: 03 June 2003 16:58
 
 Ok I'm trying to write this function to up date some fields 
 in my database
 so i'm grabbing some info from a query and throwing it into 
 an array (with
 mysql_fetch_array).
 
 one of the values i'm puting into that array is the table id. I'm then
 comparing the table id with the value of $i in my loop. Now 
 my problem is
 when I loop through and the table id is not equal to $i I 
 need to add 1 to
 $i but I need to move the array pointer back one.
 
 In the code below I used prev() but i'm getting warnings 
 about the Passed
 variable is not an array.
 http://55yardline.cflmain.com/55main/2003/fantasy/tests/update.php
 
 I'm thinking that prev() must not view an array fetch from a 
 database the
 same or something. But what else can I use besides prev() to 
 rewind the
 pointer by 1?
 
 Thanks,
 
 
 ?php
 
 include function.php;
 connect1();
 
 //query roster database and put results into an array.
 $num1 = mysql_query(SELECT * FROM roster);
 $num2 = mysql_fetch_array($num1);
 //set i to zero
 $i = 0;
 
 //start loop to determine if $i matches the current roster id
 do {
   $i = $i + 1;
   if ($num2[ros_id] == $i) {
 //if a match is found, query the fan_roster database 
 where the play_id =
 $i
 //and put the results into a array
 $upd = mysql_query(SELECT * FROM fan_roster WHERE play_id='$i');
 $updr = mysql_fetch_array($upd);
 //loop through the passing field and add them up
 do {
 $passing = $passing + $updr[pass_yrd1];
 } while($updr = mysql_fetch_array($upd));
 
 //Print feedback
 echo Player:$i total Passing: $passing $updr[play_id]br;
 
 //update the roster table with the total $passing where ros_id=$i
 $upd1 = mysql_query(UPDATE roster SET pass_yrd='$passing' WHERE
 ros_id='$i');
 //reset passing for next loop
 $passing = 0;
   } else {
 //if there isn't a match, add 1 to $i
 $i = $i + 1;
 
 //print feedback
 echo $i no playerbr;
 
 //put the array pointer back one for next loop
 $num2 = prev($num2[ros_id];

(1) prev() takes an array as its argument, not an individual element, so prev($num2) 
would be syntactically correct (but I doubt it's what you really mean).
(2) anyway, this whole statement is pointless as you immediately do:

   }
 } while($num2 = mysql_fetch_array($num1));

Which promptly overwrites the value of $num2 you just put there!

What are you *really* trying to do?
 ?
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



[PHP-DB] Array Question

2003-06-03 Thread Boa Constructor
Hello everyone.  If I wanted to pass a item ID along with a quantity to an
associative array called CartArray how would I pass it to the PHP script?

I'll get this shopping cart working yet !!

Cheers,

Graeme :)


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



RE: [PHP-DB] Array Question

2003-06-03 Thread Gary . Every
CartArray['itemid'] = $itemid;

note
where $qty = CartArray['qty'];
/note


Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
Pay It Forward
mailto:[EMAIL PROTECTED]
http://accessingram.com


 -Original Message-
 From: Boa Constructor [mailto:[EMAIL PROTECTED]
 Sent: Monday, June 02, 2003 2:27 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Array Question
 
 
 Hello everyone.  If I wanted to pass a item ID along with a 
 quantity to an
 associative array called CartArray how would I pass it to 
 the PHP script?
 
 I'll get this shopping cart working yet !!
 
 Cheers,
 
 Graeme :)
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


Re: [PHP-DB] Array Question

2003-06-03 Thread Boa Constructor
RE: [PHP-DB] Array QuestionCheers Gary, and in the html would I put something like:

a href=myscript.php?itemid=1qty=2buy this item/a

Simple question I know!


Jay, yup thats all I want to do, just assign two values into an array.


Thank you,

Graeme :)
  - Original Message - 
  From: [EMAIL PROTECTED] 
  To: [EMAIL PROTECTED] ; [EMAIL PROTECTED] 
  Sent: Monday, June 02, 2003 8:30 PM
  Subject: RE: [PHP-DB] Array Question


  CartArray['itemid'] = $itemid; 

  note 
  where $qty = CartArray['qty']; 
  /note 



  Gary Every 
  Sr. UNIX Administrator 
  Ingram Entertainment 
  (615) 287-4876 
  Pay It Forward 
  mailto:[EMAIL PROTECTED] 
  http://accessingram.com 



   -Original Message- 
   From: Boa Constructor [mailto:[EMAIL PROTECTED] 
   Sent: Monday, June 02, 2003 2:27 PM 
   To: [EMAIL PROTECTED] 
   Subject: [PHP-DB] Array Question 
   
   
   Hello everyone.  If I wanted to pass a item ID along with a 
   quantity to an 
   associative array called CartArray how would I pass it to 
   the PHP script? 
   
   I'll get this shopping cart working yet !! 
   
   Cheers, 
   
   Graeme :) 
   
   
   -- 
   PHP Database Mailing List (http://www.php.net/) 
   To unsubscribe, visit: http://www.php.net/unsub.php 
   


Re: [PHP-DB] Array Question

2003-06-03 Thread CPT John W. Holmes
 Hello everyone.  If I wanted to pass a item ID along with a quantity to an
 associative array called CartArray how would I pass it to the PHP
script?

 I'll get this shopping cart working yet !!

If the question is how do you pass an array to another PHP page, you
serialize() and urlencode() it, then pass it in the URL. On the following
page you unserialize() it.

---John Holmes...


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



[PHP-DB] array question

2003-06-02 Thread John Coder
After Wracking my brain for too long on this I decided to give in and ask.
I have holes in an array that came from a database. I put the holes there with 
unset some values so no prob. Now I need to fill the holes. Below is what I 
have and what I need for further manipulations.

Array
(
[0] = Array
(
[0] = Completed
)

[1] = Array
(
[1] = In Progress
)

[2] = Array
(
[0] = Completed
)

[3] = Array
(
[0] = Completed
[1] = In Progress
[3] = Deferred
)
 What I need is:
Array
(
[0] = Array
(
[0] = Completed
)

[1] = Array
(
[0] = In Progress
)

[2] = Array
(
[0] = Completed
)

[3] = Array
(
[0] = Completed
[1] = In Progress
[2] = Deferred
)
Hope this makes sense

John Coder

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



[PHP-DB] array manipulation with foreach

2003-03-26 Thread David Rice
I am trying to make a bit of code that takes values from 2 arrays,

one array has a list of all the date's of this week starting from sunday,

$arraydate[$n] = the date

where $n is an integer between 0+6

the other is a multidimensional array composition as such;

$rota[$staffid][$x] = date staff member is working

where staffid is a unique id number for each staff member. $x is just a 
number to denote the second array that stores all the days that staff are 
working.

The output created by the code is as follows, it is not displaying all the 
days that every staff member is working... it should have staff member 1 
working sunday and tuesday, and staff member 2 working monday and wednesday.

==
div align=centercentertable border=1 cellpadding=0
   cellspacing=0
   tr
   tdnbsp;/td
   tdSunday/td
   tdMonday/td
   tdTuesday/td
   tdWednesday/td
   tdThursday/td
   tdFriday/td
   tdSaturday/td
   /tr
   tr
   tdBar/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
   /tr
		trtd2/td
		td/tdtd/tdtd/tdtdp align=centerinput type=checkbox 
checked name=C1 value=ON/p/tdtd/tdtd/tdtd/td
   /tr
   /table

==
here is the code i used ( i know it isn't right, but i just don't know how 
to fix it)

==

?

$weekbeginning = weekbeginningYmd();
$arraydate = createdatearray($weekbeginning);
$rota = getrotafromdb($date);
?
form method=POST
   pnbsp;/p
   div align=centercentertable border=1 cellpadding=0
   cellspacing=0
   tr
   tdnbsp;/td
tdSunday/td
   tdMonday/td
   tdTuesday/td
   tdWednesday/td
   tdThursday/td
   tdFriday/td
   tdSaturday/td
   /tr
   tr
   tdBar/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
   /tr
?
	foreach($rota as $staffid = $variable){
		?
		trtd? echo $staffid; ?/td
		?
		foreach($arraydate as $key = $date){
			?td?
			foreach($variable as $key2 = $workdate){
if($date == $workdate){
	?p align=centerinput type=checkbox checked name=C1 
value=ON/p?
}
			}
		?/td?
   }
	}
	?
   /tr
   /table
   /center/divpnbsp;/p
/form

_
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger

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


[PHP-DB] Array loops

2003-03-06 Thread Robin Sanchez
I am creating a results page for completed and uncompleted procedures.  I am
repeating a lot of the code and wonder if there is an easier way to do this.
$neh=select * from pro_list, complete_pro where pro_list.pro_name
='Neurological Exam/History'
and complete_pro.proid=pro_list.proid
and complete_pro.sysid='$sysid'
and complete_pro.transid='$transid';
$resneh=safe_query($neh);
while ($rown=mysql_fetch_array($resneh)){
$compl_date1=$rown['compl_date'];
}
echo p1. Neurological Exam and History $compl_date1;

$neh=select * from pro_list, complete_pro where pro_list.pro_name ='Ankle
Arm BP Measurement'
and complete_pro.proid=pro_list.proid
and complete_pro.sysid='$sysid'
and complete_pro.transid='$transid';
$resneh=safe_query($neh);
while ($rown=mysql_fetch_array($resneh)){
$compl_date2=$rown['compl_date'];
}
 echo P2. Ankle/Arm BP Measurement $compl_date2; and so on and so on...

It seems that I could use a 'for' loop in the searches, but how do I
populate the result fields (some of which will be empty) with the
appropriate tests.
Any thoughts.
Ozzie


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



[PHP-DB] Array key problem

2003-02-25 Thread Jorge Miguel Fonseca Martins
Hi! Anyone got an idea what the problem may be with the following code
 
 $test[]=a;
 $test[]=b;
 
 foreach ($test as $key=$value)
 {
  if($key == something) echo $key
 }
 
even though theres no key in the array named something the code will
print the key 0
 
Thanks


Re: [PHP-DB] Array key problem

2003-02-25 Thread Jason Wong
On Wednesday 26 February 2003 00:37, Jorge Miguel Fonseca Martins wrote:

As this has nothing to do with databases you should post to the php-general 
list.

  $test[]=a;
  $test[]=b;

  foreach ($test as $key=$value)
  {
   if($key == something) echo $key
  }

 even though theres no key in the array named something the code will
 print the key 0

PHP is doing automatic type conversion for you. Use:

  if ($key === something { ... }

instead. See manual for details.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
If I were a grave-digger or even a hangman, there are some people I could
work for with a great deal of enjoyment.
-- Douglas Jerrold
*/


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



[PHP-DB] array with two dimensions

2003-02-17 Thread Lars Rasmussen
Hi all,
 
Got a little problem here,
 
I have a mysql query that looks like this
SELECT SUM(value) as value, YEAR(dileveret) as year FROM table GROUP BY
YEAR(dileveret)
 
It works just fine, but i need to make a array that can could do
somthing like this (know it doesent work)
$ALL_VALUES[$year] += $value;
 
The script is running the script up to 100 times to get all the specific
data's, i hope that you know a way that i can hold the values, and year
and later print one value for each year..
 
THANKS A LOT!
 
Regards
Lasse (newbie)



RE: [PHP-DB] array with two dimensions

2003-02-17 Thread Kelly Protsko
There are really a few ways that you can solve this problem. I would use
and associative array to do this. 

Making the array associative would work like this:
$ALL_VALUES[$year] += $value;

To retrieve the information back you would use the following loop:

While($element = each($ALL_VALUES))
{
echo $element[ key ]; //this would display the year
echo $element[ value ]; //displays the value associated with
the year

}

Hope that helps, I have tested it and it works for me

Kelly Protsko


-Original Message-
From: Lars Rasmussen [mailto:[EMAIL PROTECTED]] 
Sent: February 17, 2003 8:28 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] array with two dimensions

Hi all,
 
Got a little problem here,
 
I have a mysql query that looks like this
SELECT SUM(value) as value, YEAR(dileveret) as year FROM table GROUP BY
YEAR(dileveret)
 
It works just fine, but i need to make a array that can could do
somthing like this (know it doesent work)
$ALL_VALUES[$year] += $value;
 
The script is running the script up to 100 times to get all the specific
data's, i hope that you know a way that i can hold the values, and year
and later print one value for each year..
 
THANKS A LOT!
 
Regards
Lasse (newbie)



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




[PHP-DB] Array

2003-01-31 Thread Rui Miguel Palma
como posso adicionar valores a um array com dois campos
 É algo assim:
tenho n alunos para os quais vou á base de dados buscar resultados e quero criar uma 
array com o id e o email de cada um, por forma a ir buscar da seguinte forma 
$aluno[0][email] e $aluno[0][id]??

Desde já os melhores cumprimentos:Rui Palma
__
Rui Palma
ICQ#: 171381429
  Current ICQ status: 
+  More ways to contact me 
__



[PHP-DB] Array Trouble

2003-01-29 Thread Tyler Whitesides
Hi,
I e-mailed this before, but the attachments didnt go through.  I am
designing something that my tech team can use to track the maintenancing
of our school district computers.  I have a table of data (formitems)
that contains tasks that must be completed for that computer depending
on the platform.  I loaded the results from the apple.php form into an
array ($item).  I need to make a row ($makerow) then, assuming all of
the proper columns are there, load each value in the array into its
corresponding column in the database.  For some reason, PHP is not
returning the current value of the array, it is handing MySQL the whole
array.
Any help would be appreciated.

-Tyler
Web and Database Administrator
East Valley School District

?
include './include/dbconnect.php';
include 'accessConnect.php';
include './include/vars.php';
$sql = select * from inventory where ID like $id and notNetworked IS NULL;;
$row = odbc_exec($db, $sql) or die (Could not execute SQL query);
?
html
head
title?= $title ?/title
script language=javascript
function checkAll()
{
?
$sql = SELECT * FROM FORMITEMS WHERE PLATFORM LIKE '%mac%' ORDER BY ID;;
$result = mysql_query($sql);
while($list = mysql_fetch_array($result))
{
echo if(document.form.item$list[id].value == \1\)\n{\ndocument.$list[id].value = 
\2\;\n}\n;
}
?
}
/script
/head
body bgcolor=#CBe5Db link=#405266 vlink=#3F593E alink=#3F593E
div align=center
  center
  table border=0 cellspacing=0 cellpadding=0 width=780
tr
  td width=15 height=15img border=0 src=images/corner_tl.gif width=15 
height=15/td
  td bgcolor=#FF height=15img border=0 src=images/clear.gif 
width=1 height=1/td
  td width=15 height=15img border=0 src=images/corner_tr.gif width=15 
height=15/td
/tr
tr
  td bgcolor=#FF width=15img border=0 src=images/clear.gif 
width=1 height=1/td
  td bgcolor=#FF
table border=0 width=100% cellpadding=0 cellspacing=0
/tr
  tr
td valign=top rowspan=3 bgcolor=#C0C0C0 
background=images/main_bg.gifimg border=0 src=images/clear.gif width=18 
height=1
/td
td valign=topimg border=0 src=./images/logo.png hspace=2 
alt=Computer Maintenance align=top
/td
!--WebAdmin Info---
td valign=top align=rightimg src=./images/macos.gif 
align=lefttable cellpadding=0 cellspacing=0 border=0trtdApple - 
?
echo ID b/tdtdb;
echo $id;
echo /b/td/trtrtdLocation: /tdtdb;
echo odbc_result($row, location);
echo  - ;
echo odbc_result($row, roomNo);
echo /b/td/trtrtdTeacher: /tdtdb;
echo odbc_result($row, teacher);
echo /b/td/trtrtdModel: /tdtdb;
echo odbc_result($row, modelNo);
echo /b/td/trtrtdSerial: /tdtdb;
echo odbc_result($row, serialNo);
echo /b/td/trtrtdMac Address: nbsp;/tdtdb;
echo odbc_result($row, macAddress);
echo /b/td/trtrtdDrop: /tdtdb;
echo odbc_result($row, dropID);
echo /b/td/trtrtdOS: /tdtdb;
echo odbc_result($row, OS);
echo /b/td/trtrtdProcessor: /tdtdb;
echo odbc_result($row, processor);
echo /b/td/tr;
echo trtda 
href='http://support.evsd.org/webadmin/edit_entry.asp?database=newDBfound=singledeviceNum=1autoNo=;
 . odbc_result($row, autoNo) . 'Edit This Info/a/td/tr;
?
/table
!--End WebAdmin Info---
/td
  /tr
tr
td valign=bottom colspan=2
img border=0 src=images/clear.gif width=5 
height=5

/td
/tr
tr
td valign=top colspan=2   
!-Empty Cell---
table border=0 cellpadding=5 cellspacing=7
  tr
td valign=top
!-Maintenance Form---
form method=post action=data.php name=form
table
trtd align=bottomNotbrDone nbsp;nbsp;/tdtdN/A 
nbsp;nbsp;/tdtdDone/tr/tr
?
$sql = SELECT * FROM FORMITEMS WHERE PLATFORM LIKE '%mac%' ORDER BY ID;;
$result = mysql_query($sql);
while($list = mysql_fetch_array($result))
{
echo trtdinput type=radio name=item$list[id] value=\1\ checked/tdtdinput 
type=radio name=item$list[id] value=\2\/tdtdinput type=radio 
name=item$list[id] value=\3\/tdtd$list[item]/td/tr\n;
}
?

Re: [PHP-DB] Array trouble

2003-01-24 Thread Jason Wong
On Friday 24 January 2003 14:18, Tyler Whitesides wrote:

 I have been having a lot of trouble getting an array into the MySQL table
 like I want it.  This is supposed to take the current maintenance tasks
 from a table in the database on apple.php each of these is given a name
 $item[autoNo] where autoNo is the auto_increment id that task is associated
 with.  This is passed to data.php where it is supposed to make a row in the
 maintenanceditems table, then in a loop directly below that it is supposed
 to run the array and place each array value into its associated column in
 the database.  Considering all of the columns exist, I think the problem
 just has to do with how I am pulling the array values out and placing them
 into their column.  Any help would be appreciated. Thanks in advance,

Please post your code and DB schema.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
Don't worry if you're a kleptomaniac; you can always take something for it.
*/


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




[PHP-DB] Array trouble

2003-01-23 Thread Tyler Whitesides



Hi,
I have been having a lot of trouble getting an 
array into the MySQL table like I want it. This is supposed to take the 
current maintenance tasks from a table in the database on apple.php each of 
these is given a name $item[autoNo] where autoNo is the auto_increment id that 
task is associated with. This is passed to data.php where it is supposed 
to make a row in the maintenanceditems table, then in a loop directly below that 
it is supposed to run the array and place each array value into its associated 
column in the database. Considering all of the columns exist, I think the 
problem just has to do with how I am pulling the array values out and placing 
them into their column. Any help would be appreciated.
Thanks in advance,
Tyler
-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Array trouble

2003-01-23 Thread Tyler Whitesides



Hi,
I have been having a lot of trouble getting an 
array into the MySQL table like I want it. This is supposed to take the 
current maintenance tasks from a table in the database on apple.php each of 
these is given a name $item[autoNo] where autoNo is the auto_increment id that 
task is associated with. This is passed to data.php where it is supposed 
to make a row in the maintenanceditems table, then in a loop directly below that 
it is supposed to run the array and place each array value into its associated 
column in the database. Considering all of the columns exist, I think the 
problem just has to do with how I am pulling the array values out and placing 
them into their column. Any help would be appreciated.
Thanks in advance,
Tyler
-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Array problems

2003-01-22 Thread Paul Burney
on 1/22/03 12:08 AM, Michael Conway at [EMAIL PROTECTED] appended the
following bits to my mbox:

 I find myself stuck in coming up with a way to cycle through this
 array of db results for porting to a graphing script that I did not
 write.  My latest attempt to get around this problem is below.  Outside
 of the $graph-SetDataValues(array( ));, echoing $array[$i] produces the
 desired results for three sets of two bar graphs with the corresponding
 title.  However, inside the $graph function, I get only the last
 expected set of bar graphs and title.  I originally iterated through
 each anticipated result from mysql_fetch_array($result) and plugged each
 of these values into an array calling the columns individually. I got
 the desired graph, but, of course this is bad programming and not useful
 for queries producing a greater number of rows (I simply needed to know
 it worked).  Any help would be appreciated.

What exactly is the Graph class expecting in terms of data?  Is it supposed
to generate several graphs when you give it the data, or one graph per
specified dataset?

If it's the latter, move the $graph-DrawGraph(); call inside your while
loop. 

If not, let us know what format it needs the data in and we'll help you
figure out how to get it from the database into that format.

If you can't figure out what format of data the class needs, you should let
us see the graph class source.

HTH.

Sincerely,

Paul Burney
http://paulburney.com/

?php

if ($your_php_version  4.1.2) {
upgrade_now();  // to avoid major security problems
}

?


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




[PHP-DB] Array problems

2003-01-21 Thread Michael Conway
  I find myself stuck in coming up with a way to cycle through this
array of db results for porting to a graphing script that I did not
write.  My latest attempt to get around this problem is below.  Outside
of the $graph-SetDataValues(array( ));, echoing $array[$i] produces the
desired results for three sets of two bar graphs with the corresponding
title.  However, inside the $graph function, I get only the last
expected set of bar graphs and title.  I originally iterated through
each anticipated result from mysql_fetch_array($result) and plugged each
of these values into an array calling the columns individually. I got
the desired graph, but, of course this is bad programming and not useful
for queries producing a greater number of rows (I simply needed to know
it worked).  Any help would be appreciated.

 

__

 

$query = 1st SELECT code;

   // Run the query created above on the database through the connection
  if (!($result1 = @ mysql_query ($query, $connection)))
 showerror();
  

  
  $query = 2nd SELECT code;

   // Run the query created above on the database through the connection
  if (!($result2 = @ mysql_query ($query, $connection)))
 showerror();
while ($row_1st= @ mysql_fetch_array($result1))  ($row_2nd = @
mysql_fetch_array($result2)))
  { 
   
  $field1[$i]=$row_1st[column1];
  $field2[$i]=$row_1st[column2];
  $field3[$i]=$row_2nd[column1];
  $array[$i]=array($field1[$i], $field2[$i], $field3[$i]); 



  
  $graph-SetDataValues(array(
$array[$i]
   
  ));
}
$graph-DrawGraph(); 
?
 

 

Michael Conway

[EMAIL PROTECTED]

(703) 968-8875

 




[PHP-DB] Array Issue help please

2003-01-20 Thread Dave Carrera
Hi All
I have nearly got this working but it dose not seem to loop though or
return the result
 
I have done something wrong and I ask one of you coders that are much
cleverer that I to glance over my code to see the obvious mistake / s.
 
Thank you in advance for any help
 
Dave Carrera
 
// Start of my code
 
if(isset($_POST[domain])){
$uswhois = whois.networksolutions.com;
$ukwhois = whois.nic.uk;
$arr =
array(.co.uk,.org.uk,.plc.uk,.ltd.uk,.me.uk,.com,.net,.or
g);
echo Top Level Domains: br /br /;
 $domname = $_POST[domain];
  while(list(,$tld)=each($arr)) {
   if(($tld == .com) || ($tld == .net) || ($tld == .org)){
   $whois = $uswhois;
   $linenumber = 8;
   }
   else
   {
   $whois = $ukwhois;
   $linenumber = 2;
   }
   $stld = $domname$tld to $whois using line $linenumberbr /;
   echo $stld;
   for($i=0;$i=count($arr);$i++){
 $fp = fsockopen ($whois, 43, $errno, $errstr, 30) or die($errno:
$errstr);
fputs($fp, $domname$tld\n);
while (!feof($fp)) {
$serverReturn = fgets($fp, 2048);
$x++;
if ($x == $lineNumber) {
$line = $serverReturn;
}
}
fclose($fp);
$token = strtok($line, );
if ($token == 'No') {
$result = 0;
} else {
$result = 1;
}
return $result;
}
$answer = $result;
   if(isset($answer)) {
 $checkeddom .= img src=\./img/x.jpg\ border=\0\nbsp;font
color=red$_POST[domain]$tld/fontbr /;
   } else {
 $checkeddom .= img src=\./img/tick.jpg\
border=\0\nbsp;font color=green$_POST[domain]$tld/b/fontbr
/;
   }
 }
 
}
//End of my code
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.443 / Virus Database: 248 - Release Date: 10/01/2003
 



Re: [PHP-DB] Array Issue help please

2003-01-20 Thread Jason Wong
On Monday 20 January 2003 17:50, Dave Carrera wrote:

 I have nearly got this working but it dose not seem to loop though or
 return the result

 I have done something wrong and I ask one of you coders that are much
 cleverer that I to glance over my code to see the obvious mistake / s.

Can you describe in more detail how your code doesn't behave the way you 
expected it to behave? 

So do you see anything at all?

What exactly does it do?

Error messages?

Have you checked the logs?

Have you tried echo() on the important variables to see what they contain?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
The last time I saw him he was walking down Lover's Lane holding his own hand.
-- Fred Allen
*/


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




[PHP-DB] Array help please

2003-01-19 Thread Dave Carrera
Hi All
I am trying to create a tld lookup script for uk and main us domains.
 
I have success by creating multiple function hardcode the whois server
and tld but I would love to be able to make an array of tlds then step
through the array to check availability of domain.
 
Example
 
$arr = array(‘.co.uk’,’.com’,’.net’,’.me.uk’);
 
How do I step though one at a time and give a viewable result?
 
I know I have to check the value of the array and assign the relevant
whois server. How do I do that?
 
Any help, guidance, code examples will be very much appreciated.
 
Thank you in advance as always
 
Dave Carrera

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.443 / Virus Database: 248 - Release Date: 10/01/2003
 



Re: [PHP-DB] Array help please

2003-01-19 Thread Peter Beckman

$arr = array(.co.uk,.com,.net,.me.uk);
echo Top Level Domains: ;
while(list(,$tld)=each($arr)) {
   echo $tld., ;
}

On Sun, 19 Jan 2003, Dave Carrera wrote:

 Hi All
 I am trying to create a tld lookup script for uk and main us domains.

 I have success by creating multiple function hardcode the whois server
 and tld but I would love to be able to make an array of tlds then step
 through the array to check availability of domain.

 Example

 $arr = array(‘.co.uk’,’.com’,’.net’,’.me.uk’);

 How do I step though one at a time and give a viewable result?

 I know I have to check the value of the array and assign the relevant
 whois server. How do I do that?

 Any help, guidance, code examples will be very much appreciated.

 Thank you in advance as always

 Dave Carrera

 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.443 / Virus Database: 248 - Release Date: 10/01/2003



---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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




[PHP-DB] array sorting

2002-11-12 Thread Martin Allan Jensen
Hi everyone...


I got a bit longer now..

But i have some trouble sorting my arrays

I get this array returned.

Array ( [0] = Array ( [0] = 10 [1] = 40 [2] = 50 [3] = 80 [4] = 130 [5] = 220 
[6] = 320 ) [1] = Array ( [0] = 10 [1] = 40 [2] = 50 [3] = 80 [4] = 130 [5] = 
220 [6] = 320 [7] = 440 [8] = 570 ) [2] = ) 

I ain't good at it, but i guess this is a two dimesioned array...

The question is now,  i need to get the highest values of each sub array witch would 
be 320  570 in THIS CASE ??

Thanks so much!!

Martin Allan Jensen


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




Re: [PHP-DB] array sorting

2002-11-12 Thread Ignatius Reilly
Just loop through the first index, then search on the second index:

while ( list( $key, $value ) = each( $my_arr ) ) {

// now $value is your ( [0] = 10 [1] = 40 [2] = 50 [3] = 80 [4] =
130 [5] = 220 [6] = 320 ) array
// sort your array by values
sort( $value ) ;
// get the last value
$last_value = array_pop( $value ) ;
// do something with this value...

}

But it seems to me there still misses a link between your two series of data
(years, values)

So try to get an array where keys are years, not numerical indexes?

HTH
Ignatius

- Original Message -
From: Martin Allan Jensen [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, November 12, 2002 1:37 PM
Subject: [PHP-DB] array sorting


Hi everyone...


I got a bit longer now..

But i have some trouble sorting my arrays

I get this array returned.

Array ( [0] = Array ( [0] = 10 [1] = 40 [2] = 50 [3] = 80 [4] = 130
[5] = 220 [6] = 320 ) [1] = Array ( [0] = 10 [1] = 40 [2] = 50 [3] =
80 [4] = 130 [5] = 220 [6] = 320 [7] = 440 [8] = 570 ) [2] = )

I ain't good at it, but i guess this is a two dimesioned array...

The question is now,  i need to get the highest values of each sub array
witch would be 320  570 in THIS CASE ??

Thanks so much!!

Martin Allan Jensen


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




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




[PHP-DB] Array question

2002-11-08 Thread nikos
Does anybody know how to remove an item from an array?
Let's say

$array('banna', 'apple','cherry')
foreach ($array as $value) {
if ($value=='chery') DELETE $value FROM $array
...

Thanks




Re: [PHP-DB] Array question

2002-11-08 Thread Maxim Maletsky
to precise:

$array = Array('name'='Maxim', 'surname'='Maletsky');

unset($array['name']);

// now array has this structure:
// Array('surname'='Maletsky')


--
Maxim Maletsky
[EMAIL PROTECTED]



Jason Wong [EMAIL PROTECTED] wrote... :

 On Friday 08 November 2002 17:25, nikos wrote:
  Does anybody know how to remove an item from an array?
  Let's say
 
  $array('banna', 'apple','cherry')
  foreach ($array as $value) {
  if ($value=='chery') DELETE $value FROM $array
  ...
 
 unset().
 
 
 -- 
 Jason Wong - Gremlins Associates - www.gremlins.com.hk
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 
 
 /*
 Kiss me, Kate, we will be married o' Sunday.
   -- William Shakespeare, The Taming of the Shrew
 */
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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




[PHP-DB] Array Initialization

2002-10-13 Thread Rich Hutchins

Please forgive me ahead of time, but I didn't want to subscribe to the
high-vol general list for a single question. Actually, I need this to prep
data to be passed to a db, so it's kind of close.

I have a variable number of hidden fields being passed from page A into page
B via POST. On page B, I want to take those hidden fields and turn them into
an associative array. I am able to get the data out of the $HTTP_POST_VARS
and make it look the way I want with the following code:

!-- BEGIN POST VARS --
!-- { mySelect = '40', mySelect_10 = 'Miami', mySelect_20 = 'New England',
mySelect_30 = 'Buffalo', mySelect_40 = 'New York' } --

foreach ($HTTP_POST_VARS as $key = $value) {
if (preg_match(/mySelect_/, $key ))
{
echo(Found a match.br);
$stripped = substr_replace($key, , 0, 9);
echo(Content ID=.$stripped.br);
echo(Its text value is: .$value);
echo(brbr);

$newInfo = array($stripped = $value);
}
}

print_r($newInfo);

The resulting sample HTML data looks like this:
Found a match.
Content ID=10
Its text value is: Miami

Found a match.
Content ID=20
Its text value is: New England

Found a match.
Content ID=30
Its text value is: Buffalo

Found a match.
Content ID=40
Its text value is: New York

Array ( [40] = New York ) //here's the problem

The problem is in the $newInfo = array($strippd = $value); and it's the
last line of the sample HTML code.

What I want to achieve is:
Array ( [10] = Miami, [20] = New England, [30] = Buffalo, [40] = New
York ).

Any ideas how to get there?

Thanks in advance.


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




RE: [PHP-DB] Array Initialization

2002-10-13 Thread John W. Holmes

$newInfo[$stripped] = $value;

---John Holmes...

 -Original Message-
 From: Rich Hutchins [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, October 13, 2002 3:42 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Array Initialization
 
 Please forgive me ahead of time, but I didn't want to subscribe to the
 high-vol general list for a single question. Actually, I need this to
prep
 data to be passed to a db, so it's kind of close.
 
 I have a variable number of hidden fields being passed from page A
into
 page
 B via POST. On page B, I want to take those hidden fields and turn
them
 into
 an associative array. I am able to get the data out of the
$HTTP_POST_VARS
 and make it look the way I want with the following code:
 
 !-- BEGIN POST VARS --
 !-- { mySelect = '40', mySelect_10 = 'Miami', mySelect_20 = 'New
 England',
 mySelect_30 = 'Buffalo', mySelect_40 = 'New York' } --
 
   foreach ($HTTP_POST_VARS as $key = $value) {
   if (preg_match(/mySelect_/, $key ))
   {
   echo(Found a match.br);
   $stripped = substr_replace($key, , 0, 9);
   echo(Content ID=.$stripped.br);
   echo(Its text value is: .$value);
   echo(brbr);
 
   $newInfo = array($stripped = $value);
   }
   }
 
   print_r($newInfo);
 
 The resulting sample HTML data looks like this:
 Found a match.
 Content ID=10
 Its text value is: Miami
 
 Found a match.
 Content ID=20
 Its text value is: New England
 
 Found a match.
 Content ID=30
 Its text value is: Buffalo
 
 Found a match.
 Content ID=40
 Its text value is: New York
 
 Array ( [40] = New York ) //here's the problem
 
 The problem is in the $newInfo = array($strippd = $value); and it's
the
 last line of the sample HTML code.
 
 What I want to achieve is:
 Array ( [10] = Miami, [20] = New England, [30] = Buffalo, [40] =
New
 York ).
 
 Any ideas how to get there?
 
 Thanks in advance.
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




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




[PHP-DB] Array help needed :-(

2002-10-07 Thread Chris Payne

Hi there everyone,

I have a problem i'm trying to figure out but i'm not too good with arrays, just know 
the basics, if anyone could help me out on this it would be wonderful :-)

I have two sets of data in columns of a MySQL DB, these items are size and price.

Size is seperate by comma's in the first column, and I have it split into a dropdown 
box no problem to read (For example):

small
medium
large

but then I have a price field, which contains 1.99,2.99,3.99 etc . what I need to 
do is when someone selects an item from the dropdown - say small as an example, it 
would know how to get 1.99 from the price entry in the DB.  I guess what I need to do 
is somehow associate each entry in the price field with those in the size, but I have 
no idea how to do it :-(

Any help would be really appreciated as this stumps the hell out of me.

Thanks

Chris


[PHP-DB] array intersect with 2 arrays created from mysql

2002-10-07 Thread Nigel Dunn

Hi,

If anyone can help me with this I'd be most appreciative.

I'm constructing 2 arrays of IDs from 2 different tables. Then I want to 
compare one to the other and only use the results that both arrays share 
in common to do a query loop that pulls the information for the related 
IDs to display.

The error I get from the code below is:

Warning: Argument #2 to array_intersect() is not an array in 
/usr/local/www/vhosts/trustbuild.co.nz/htdocs/partners_region.php on 
line 185

I cant see what is causing the problem.

 Start of My Existing Code 

$result = mysql_query(SELECT partner_id FROM partner_region WHERE 
region_id = '$r' ORDER BY partner_id);
if ($row = mysql_fetch_array($result)) {
   do {
 partner_region[] = $row['partner_id'];
   } while ($row = mysql_fetch_array($result));
}

if (count($partner_region) != 0) {
   array_unique($partner_region);
}

$result2 = mysql_query(SELECT id FROM partner WHERE type = '$t' ORDER 
BY id);
if ($row2 = mysql_fetch_array($result2)) {
   do {
 partner_type[] = $row2['id'];
   } while ($row2 = mysql_fetch_array($result2));
}

if (count($partner_type) != 0) {
   array_unique($partner_type);
}

$partner = array_intersect($partner_region, $partner_type);

if (count($partner) != 0) {
   foreach ($partner as $p) {
 $result3 = mysql_query(SELECT * FROM partner WHERE id = '$p');
 if ($row3 = mysql_fetch_array($result3)) {
   do {
 $company_name = $row3['company_name'];
 $contact_name = $row3['contact_name'];
 $physical_address = $row3['physical_address'];
 $postal_address = $row3['postal_address'];
 $city = $row3['city'];
 $phone = $row3['phone'];
 $fax = $row3['fax'];
 $email = $row3['email'];
 $url = $row3['url'];
 $gst_number = $row3['gst_number'];
 $company_age = $row3['company_age'];
 $services = $row3['services'];
$region = region($r);

 if ($count == 0) {
  echo trtd bgcolor='#FF'a href='closeup.php?id=$id'$region 
$company_name/abrType: $company_typebrContact Name: 
$contact_namebr.nl2br($physical_address)./td/tr;
   $count++;
 } else {
   echo trtd bgcolor='#DD'a 
href='closeup.php?id=$id'$region $company_name/abrType: 
$company_typebrContact Name: 
$contact_namebr.nl2br($physical_address)./td/tr;
   $count--;
 }
   } while ($row3 = mysql_fetch_array($result3));
 }
   }
} else {
   echo There are no listings for your criteria. Please try again.br;
}

 End of My Existing Code 

Thanks in advance for any help with this one,

Nigel Dunn


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




[PHP-DB] ARRAY, IF INSERT

2002-06-21 Thread César Aracena

Hi all.
 
I have this form in which one Administrator can insert new members and
after that, in another page, a form where he/she can insert the new
member’s sons  daughters. I want to display a table with “text inserts”
into the admin can type let’s say a maximum of 5 kids in the second
page. The “members” table will have one memberID field (which will be
shared between parents and kids) and a levelID which will grant 0 for
the parent and 1, 2, 3, 4, 5 for the kids.
 
Now, how do I tell PHP to make an array from the kids input, but only
from the fields in which let’s say the “name” field was filled out in
order to spend the necessary table’s rows. Another thing… the Array
should also specify new levelID’s for each kid from 1 to 5. It would be
great if you also show me how to deal with it after it’s created.
 
Thanks a lot and sorry for so many questions,
 
Cesar Aracena mailto:[EMAIL PROTECTED] 
CE / MCSE+I
Neuquen, Argentina
+54.299.6356688
+54.299.4466621
 



Re: [PHP-DB] array problem

2002-06-21 Thread Jason Wong

On Thursday 20 June 2002 23:26, Richard Black wrote:
 By passing a second parameter to mysql_fetch_array, MYSQL_ASSOC

 This means you only get back an array with the values indexed by
 fieldname.

Or just use mysql_fetch_assoc().

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
disks spinning backwards - toggle the hemisphere jumper.
*/


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




Re: [PHP-DB] Array HELL!!!!

2002-02-25 Thread biorn

Try putting the hidden element statement down inside the while loop in he 
second page, but change it to INPUT TYPE=\hidden\ NAME=\id[]\ 
VALUE=\$id\ and add 

$id=$row['id']; 

before it.

I will show below where it should go. 

HTH

MB

jas [EMAIL PROTECTED] said:

 I have made the changes you suggested which if you ask me have been the most
 informative answers I have recieved thus far.  I did run into a slight snag
 on line 21 which is this on my confirmation page INPUT TYPE=\hidden\
 NAME=\id[]\ VALUE=\$id[]\ and the parse error is as follows...
 Parse error: parse error, expecting `STRING' or `NUM_STRING' or `'$'' in
 /php/rem_conf_t.php3 on line 21
 Wouldn't I need to adjust the value=\$id[]\ to something like
 value=\.$id[].\ because we passed an array not a string?  Not sure. Thanks
 again.  You are sincerely helping me understand this whole php bit. =)
 Jas
 [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Ok, you have almost got it.  I have made little remarks further down in
 your
  code which should just about do it for you.
 
 
  jas [EMAIL PROTECTED] said:
 
   I don't know what it is but I am having a hell of a time trying to get
 some
   results of a query setup into an array or variable (too much of a newbie
 to
   know which) that can be passed to a confirmation page before deleting
 the
   record from a table.  I have given up working on this but for those of
 you
   that want to finish it here is the code and the table structure...
  
   [Table Structure]
   id int(30) DEFAULT '0' NOT NULL auto_increment,
  car_type varchar(30),
  car_model varchar(30),
  car_year varchar(15),
  car_price varchar(15),
  car_vin varchar(25),
  dlr_num varchar(25),
  PRIMARY KEY (id)
  
   [Page 1 - Queries DB table for records]
   ?php
   require '../path/to/db.php';
   $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
   execute query, please try again later);
   echo table border=\0\ class=\table-body\ width=\100%\form
   name=\rem_inv\ method=\post\ action=\rem_conf.php3\
   trtd align=\center\ colspan=\3\font size=\4\BCurrent
   Inventory/B/fonthr color=\33\/td/tr;
   $count = -1;
 
  $count should start at 0 and then increment at the bottom of the while
 loop
 
   while ($myrow = mysql_fetch_array($result)) {
$id = $row[id];
 
  $row should be $myrow since that is what it is called above (or change
 $myrow
  above to $row)
 
 
$car_type = $row[car_type];
$car_model = $row[car_model];
$car_year = $row[car_year];
$car_price = $row[car_price];
$car_vin = $row[car_vin];
$count ++;
 
  $count ++; should be moved to the bottom of the loop just before it is
 closed
 
   echo trtd width=\30%\BType Of Car: /B/tdtd;
   printf(mysql_result($result,$count,car_type));
 
  mysql_result is not needed here, you have defined the variable $car_type
 to
  be this here as well as the rows below, so replace mysql_result($result,
  $count, car_type) with just $car_type
 
   echo /tdtdinput type=\checkbox\ name=\id[]\
   value=\.$myrow[id].\remove/td/tr\n;
 
  replace $myrow[id] with $id since it is already defined above
  when id[] is passed to page 2, it will contain an array of the id numbers
  that got checked
 
 
   echo trtd width=\30%\BModel Of Car: /B/tdtd;
   printf(mysql_result($result,$count,car_model));
 
  same as above, replace mysql_result($result,$count,car_model) with
  $car_model
 
   echo /td/tr\n;
   echo trtd width=\30%\BYear Of Car: /B/tdtd;
   printf(mysql_result($result,$count,car_year));
 
  same as above replace with $car_year
 
   echo /td/tr\n;
   echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
   printf(mysql_result($result,$count,car_price));
 
  same as above replace with $care_price
 
   echo /td/tr\n;
   echo trtd width=\30%\BVIN Of Car: /B/tdtd;
   printf(mysql_result($result,$count,car_vin));
 
  same as above replace with $car_vin
 
   echo /td/trtrtd colspan=\3\hr
 color=\33\/td/tr\n;
 
  $count ++; should go here
 
   }
   echo trtdinput type=\submit\ name=\delete\
   value=\delete\/td/tr/form/table;
   ?
  
   [Page 2 - Takes records and confirms which ones to be deleted]
   ?php
   print(
   table border=\0\ class=\table-body\ width=\100%\
   form name=\rem_inv\ method=\post\ action=\done2.php3\
 
  send id[] array passed from previous page to the next page:
  INPUT TYPE=\hidden\ NAME=\id[]\ VALUE=\$id[]\
 
  If you are planning on deleting multiple items at a time, you won't need
 the
  following hidden elements at all, just make a database call at this point
  using the id[] array passed to this page from the first page.  The only
 value
  it needs for the 3rd page is the id value since that is what it uses to
  determine what to delete.
 
  Here is an example of the database call to make:
 
  $i=0;
  while ($id[$i]) {
  $result = @mysql_query(SELECT * FROM cur_inv where id=$id[$i],$dbh) or
 die
  (Could not execute query, please try again later);
  

[PHP-DB] Array HELL!!!!

2002-02-22 Thread jas

I don't know what it is but I am having a hell of a time trying to get some
results of a query setup into an array or variable (too much of a newbie to
know which) that can be passed to a confirmation page before deleting the
record from a table.  I have given up working on this but for those of you
that want to finish it here is the code and the table structure...

[Table Structure]
id int(30) DEFAULT '0' NOT NULL auto_increment,
   car_type varchar(30),
   car_model varchar(30),
   car_year varchar(15),
   car_price varchar(15),
   car_vin varchar(25),
   dlr_num varchar(25),
   PRIMARY KEY (id)

[Page 1 - Queries DB table for records]
?php
require '../path/to/db.php';
$result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
echo table border=\0\ class=\table-body\ width=\100%\form
name=\rem_inv\ method=\post\ action=\rem_conf.php3\
trtd align=\center\ colspan=\3\font size=\4\BCurrent
Inventory/B/fonthr color=\33\/td/tr;
$count = -1;
while ($myrow = mysql_fetch_array($result)) {
 $id = $row[id];
 $car_type = $row[car_type];
 $car_model = $row[car_model];
 $car_year = $row[car_year];
 $car_price = $row[car_price];
 $car_vin = $row[car_vin];
 $count ++;
echo trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
echo /tdtdinput type=\checkbox\ name=\id[]\
value=\.$myrow[id].\remove/td/tr\n;
echo trtd width=\30%\BModel Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_model));
echo /td/tr\n;
echo trtd width=\30%\BYear Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_year));
echo /td/tr\n;
echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
printf(mysql_result($result,$count,car_price));
echo /td/tr\n;
echo trtd width=\30%\BVIN Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_vin));
echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
}
echo trtdinput type=\submit\ name=\delete\
value=\delete\/td/tr/form/table;
?

[Page 2 - Takes records and confirms which ones to be deleted]
?php
print(
table border=\0\ class=\table-body\ width=\100%\
form name=\rem_inv\ method=\post\ action=\done2.php3\
INPUT TYPE=\hidden\ NAME=\id\ VALUE=\$id\
INPUT TYPE=\hidden\ NAME=\car_type\ VALUE=\$car_type\
INPUT TYPE=\hidden\ NAME=\car_model\ VALUE=\$car_model\
INPUT TYPE=\hidden\ NAME=\car_year\ VALUE=\$car_year\
INPUT TYPE=\hidden\ NAME=\car_price\ VALUE=\$car_price\
INPUT TYPE=\hidden\ NAME=\car_vin\ VALUE=\$car_vin\
  tr
td align=\center\ colspan=\3\font size=\4\BConfirm Record
Deletion/B/fonthr color=\33\/td
  /tr
  tr
td width=\30%\BType Of Car: /B/td
 td$car_type/td
  /tr
  tr
td width=\30%\BModel Of Car: /B/td
 td$car_model/td
  /tr
  tr
td width=\30%\BYear Of Car: /B/td
 td$car_year/td
  /tr
  tr
td width=\30%\BPrice Of Car: /B/td
 td$car_price/td
  /tr
  tr
td width=\30%\BVIN Of Car: /B/td
 td$car_vin/td
  /tr
  tr
td colspan=\3\hr color=\33\/td
  /tr
  tr
tdinput type=\submit\ name=\delete\ value=\delete\/td
  /tr
/form
/table);
?

[Page 3 - Connects to DB and deletes selected records]
?php
require '../path/to/db.php';
$table_name = cur_inv;
$sql = DELETE FROM $table_name WHERE id = '$id';
echo($sql);
$result = mysql_query($sql,$dbh) or die(mysql_error());
print(body bgcolor=\ff9900\p class=\done\You have successfully
removed your items from the database.);
?

If anyone has the time to finish it or give me some pointers on what the
hell I am doing wrong please let me know, I would be very glad to hear your
opinion and the correct way to accomplish this.  (And, yes I went through
just about every tutorial I could find on how to delete records, which by
the way did nothing for putting the results of a select statement into an
array or variable for futher processing.) Have a good weekend everyone!!!
Pissed and frustrated...
Jas



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




RE: [PHP-DB] Array HELL!!!!

2002-02-22 Thread SpyProductions Support Team


That's not Array Hell, this is Array Hell:

$Hell = array(satan,fire,brimstone);

-Mike


 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Friday, February 22, 2002 4:37 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Array HELL


 I don't know what it is but I am having a hell of a time trying
 to get some
 results of a query setup into an array or variable (too much of a
 newbie to
 know which) that can be passed to a confirmation page before deleting the
 record from a table.  I have given up working on this but for those of you
 that want to finish it here is the code and the table structure...

 [Table Structure]
 id int(30) DEFAULT '0' NOT NULL auto_increment,
car_type varchar(30),
car_model varchar(30),
car_year varchar(15),
car_price varchar(15),
car_vin varchar(25),
dlr_num varchar(25),
PRIMARY KEY (id)

 [Page 1 - Queries DB table for records]
 ?php
 require '../path/to/db.php';
 $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
 execute query, please try again later);
 echo table border=\0\ class=\table-body\ width=\100%\form
 name=\rem_inv\ method=\post\ action=\rem_conf.php3\
 trtd align=\center\ colspan=\3\font size=\4\BCurrent
 Inventory/B/fonthr color=\33\/td/tr;
 $count = -1;
 while ($myrow = mysql_fetch_array($result)) {
  $id = $row[id];
  $car_type = $row[car_type];
  $car_model = $row[car_model];
  $car_year = $row[car_year];
  $car_price = $row[car_price];
  $car_vin = $row[car_vin];
  $count ++;
 echo trtd width=\30%\BType Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_type));
 echo /tdtdinput type=\checkbox\ name=\id[]\
 value=\.$myrow[id].\remove/td/tr\n;
 echo trtd width=\30%\BModel Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_model));
 echo /td/tr\n;
 echo trtd width=\30%\BYear Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_year));
 echo /td/tr\n;
 echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
 printf(mysql_result($result,$count,car_price));
 echo /td/tr\n;
 echo trtd width=\30%\BVIN Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_vin));
 echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
 }
 echo trtdinput type=\submit\ name=\delete\
 value=\delete\/td/tr/form/table;
 ?

 [Page 2 - Takes records and confirms which ones to be deleted]
 ?php
 print(
 table border=\0\ class=\table-body\ width=\100%\
 form name=\rem_inv\ method=\post\ action=\done2.php3\
 INPUT TYPE=\hidden\ NAME=\id\ VALUE=\$id\
 INPUT TYPE=\hidden\ NAME=\car_type\ VALUE=\$car_type\
 INPUT TYPE=\hidden\ NAME=\car_model\ VALUE=\$car_model\
 INPUT TYPE=\hidden\ NAME=\car_year\ VALUE=\$car_year\
 INPUT TYPE=\hidden\ NAME=\car_price\ VALUE=\$car_price\
 INPUT TYPE=\hidden\ NAME=\car_vin\ VALUE=\$car_vin\
   tr
 td align=\center\ colspan=\3\font size=\4\BConfirm Record
 Deletion/B/fonthr color=\33\/td
   /tr
   tr
 td width=\30%\BType Of Car: /B/td
  td$car_type/td
   /tr
   tr
 td width=\30%\BModel Of Car: /B/td
  td$car_model/td
   /tr
   tr
 td width=\30%\BYear Of Car: /B/td
  td$car_year/td
   /tr
   tr
 td width=\30%\BPrice Of Car: /B/td
  td$car_price/td
   /tr
   tr
 td width=\30%\BVIN Of Car: /B/td
  td$car_vin/td
   /tr
   tr
 td colspan=\3\hr color=\33\/td
   /tr
   tr
 tdinput type=\submit\ name=\delete\ value=\delete\/td
   /tr
 /form
 /table);
 ?

 [Page 3 - Connects to DB and deletes selected records]
 ?php
 require '../path/to/db.php';
 $table_name = cur_inv;
 $sql = DELETE FROM $table_name WHERE id = '$id';
 echo($sql);
 $result = mysql_query($sql,$dbh) or die(mysql_error());
 print(body bgcolor=\ff9900\p class=\done\You have successfully
 removed your items from the database.);
 ?

 If anyone has the time to finish it or give me some pointers on what the
 hell I am doing wrong please let me know, I would be very glad to
 hear your
 opinion and the correct way to accomplish this.  (And, yes I went through
 just about every tutorial I could find on how to delete records, which by
 the way did nothing for putting the results of a select statement into an
 array or variable for futher processing.) Have a good weekend everyone!!!
 Pissed and frustrated...
 Jas



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




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




Re: [PHP-DB] Array HELL!!!!

2002-02-22 Thread jas

Well ok now that I know it isn't an array I am having problems with, how
exactly am I supposed to create a variable (that can be passed to another
page) from a selected set of records?
Thanks again for the politeness,
Jas
Spyproductions Support Team [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 That's not Array Hell, this is Array Hell:

 $Hell = array(satan,fire,brimstone);

 -Mike


  -Original Message-
  From: jas [mailto:[EMAIL PROTECTED]]
  Sent: Friday, February 22, 2002 4:37 AM
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] Array HELL
 
 
  I don't know what it is but I am having a hell of a time trying
  to get some
  results of a query setup into an array or variable (too much of a
  newbie to
  know which) that can be passed to a confirmation page before deleting
the
  record from a table.  I have given up working on this but for those of
you
  that want to finish it here is the code and the table structure...
 
  [Table Structure]
  id int(30) DEFAULT '0' NOT NULL auto_increment,
 car_type varchar(30),
 car_model varchar(30),
 car_year varchar(15),
 car_price varchar(15),
 car_vin varchar(25),
 dlr_num varchar(25),
 PRIMARY KEY (id)
 
  [Page 1 - Queries DB table for records]
  ?php
  require '../path/to/db.php';
  $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
  execute query, please try again later);
  echo table border=\0\ class=\table-body\ width=\100%\form
  name=\rem_inv\ method=\post\ action=\rem_conf.php3\
  trtd align=\center\ colspan=\3\font size=\4\BCurrent
  Inventory/B/fonthr color=\33\/td/tr;
  $count = -1;
  while ($myrow = mysql_fetch_array($result)) {
   $id = $row[id];
   $car_type = $row[car_type];
   $car_model = $row[car_model];
   $car_year = $row[car_year];
   $car_price = $row[car_price];
   $car_vin = $row[car_vin];
   $count ++;
  echo trtd width=\30%\BType Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_type));
  echo /tdtdinput type=\checkbox\ name=\id[]\
  value=\.$myrow[id].\remove/td/tr\n;
  echo trtd width=\30%\BModel Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_model));
  echo /td/tr\n;
  echo trtd width=\30%\BYear Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_year));
  echo /td/tr\n;
  echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
  printf(mysql_result($result,$count,car_price));
  echo /td/tr\n;
  echo trtd width=\30%\BVIN Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_vin));
  echo /td/trtrtd colspan=\3\hr
color=\33\/td/tr\n;
  }
  echo trtdinput type=\submit\ name=\delete\
  value=\delete\/td/tr/form/table;
  ?
 
  [Page 2 - Takes records and confirms which ones to be deleted]
  ?php
  print(
  table border=\0\ class=\table-body\ width=\100%\
  form name=\rem_inv\ method=\post\ action=\done2.php3\
  INPUT TYPE=\hidden\ NAME=\id\ VALUE=\$id\
  INPUT TYPE=\hidden\ NAME=\car_type\ VALUE=\$car_type\
  INPUT TYPE=\hidden\ NAME=\car_model\ VALUE=\$car_model\
  INPUT TYPE=\hidden\ NAME=\car_year\ VALUE=\$car_year\
  INPUT TYPE=\hidden\ NAME=\car_price\ VALUE=\$car_price\
  INPUT TYPE=\hidden\ NAME=\car_vin\ VALUE=\$car_vin\
tr
  td align=\center\ colspan=\3\font size=\4\BConfirm
Record
  Deletion/B/fonthr color=\33\/td
/tr
tr
  td width=\30%\BType Of Car: /B/td
   td$car_type/td
/tr
tr
  td width=\30%\BModel Of Car: /B/td
   td$car_model/td
/tr
tr
  td width=\30%\BYear Of Car: /B/td
   td$car_year/td
/tr
tr
  td width=\30%\BPrice Of Car: /B/td
   td$car_price/td
/tr
tr
  td width=\30%\BVIN Of Car: /B/td
   td$car_vin/td
/tr
tr
  td colspan=\3\hr color=\33\/td
/tr
tr
  tdinput type=\submit\ name=\delete\ value=\delete\/td
/tr
  /form
  /table);
  ?
 
  [Page 3 - Connects to DB and deletes selected records]
  ?php
  require '../path/to/db.php';
  $table_name = cur_inv;
  $sql = DELETE FROM $table_name WHERE id = '$id';
  echo($sql);
  $result = mysql_query($sql,$dbh) or die(mysql_error());
  print(body bgcolor=\ff9900\p class=\done\You have successfully
  removed your items from the database.);
  ?
 
  If anyone has the time to finish it or give me some pointers on what the
  hell I am doing wrong please let me know, I would be very glad to
  hear your
  opinion and the correct way to accomplish this.  (And, yes I went
through
  just about every tutorial I could find on how to delete records, which
by
  the way did nothing for putting the results of a select statement into
an
  array or variable for futher processing.) Have a good weekend
everyone!!!
  Pissed and frustrated...
  Jas
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 





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




Re: [PHP-DB] Array HELL!!!!

2002-02-22 Thread biorn

Ok, you have almost got it.  I have made little remarks further down in your 
code which should just about do it for you.


jas [EMAIL PROTECTED] said:

 I don't know what it is but I am having a hell of a time trying to get some
 results of a query setup into an array or variable (too much of a newbie to
 know which) that can be passed to a confirmation page before deleting the
 record from a table.  I have given up working on this but for those of you
 that want to finish it here is the code and the table structure...
 
 [Table Structure]
 id int(30) DEFAULT '0' NOT NULL auto_increment,
car_type varchar(30),
car_model varchar(30),
car_year varchar(15),
car_price varchar(15),
car_vin varchar(25),
dlr_num varchar(25),
PRIMARY KEY (id)
 
 [Page 1 - Queries DB table for records]
 ?php
 require '../path/to/db.php';
 $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
 execute query, please try again later);
 echo table border=\0\ class=\table-body\ width=\100%\form
 name=\rem_inv\ method=\post\ action=\rem_conf.php3\
 trtd align=\center\ colspan=\3\font size=\4\BCurrent
 Inventory/B/fonthr color=\33\/td/tr;
 $count = -1;

$count should start at 0 and then increment at the bottom of the while loop

 while ($myrow = mysql_fetch_array($result)) {
  $id = $row[id]; 

$row should be $myrow since that is what it is called above (or change $myrow 
above to $row)


  $car_type = $row[car_type];
  $car_model = $row[car_model];
  $car_year = $row[car_year];
  $car_price = $row[car_price];
  $car_vin = $row[car_vin];
  $count ++;

$count ++; should be moved to the bottom of the loop just before it is closed

 echo trtd width=\30%\BType Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_type));

mysql_result is not needed here, you have defined the variable $car_type to 
be this here as well as the rows below, so replace mysql_result($result, 
$count, car_type) with just $car_type

 echo /tdtdinput type=\checkbox\ name=\id[]\
 value=\.$myrow[id].\remove/td/tr\n;

replace $myrow[id] with $id since it is already defined above
when id[] is passed to page 2, it will contain an array of the id numbers 
that got checked


 echo trtd width=\30%\BModel Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_model));

same as above, replace mysql_result($result,$count,car_model) with 
$car_model

 echo /td/tr\n;
 echo trtd width=\30%\BYear Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_year));

same as above replace with $car_year

 echo /td/tr\n;
 echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
 printf(mysql_result($result,$count,car_price));

same as above replace with $care_price

 echo /td/tr\n;
 echo trtd width=\30%\BVIN Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_vin));

same as above replace with $car_vin

 echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;

$count ++; should go here

 }
 echo trtdinput type=\submit\ name=\delete\
 value=\delete\/td/tr/form/table;
 ?
 
 [Page 2 - Takes records and confirms which ones to be deleted]
 ?php
 print(
 table border=\0\ class=\table-body\ width=\100%\
 form name=\rem_inv\ method=\post\ action=\done2.php3\

send id[] array passed from previous page to the next page:
INPUT TYPE=\hidden\ NAME=\id[]\ VALUE=\$id[]\

If you are planning on deleting multiple items at a time, you won't need the 
following hidden elements at all, just make a database call at this point 
using the id[] array passed to this page from the first page.  The only value 
it needs for the 3rd page is the id value since that is what it uses to 
determine what to delete.

Here is an example of the database call to make:

$i=0;
while ($id[$i]) {
$result = @mysql_query(SELECT * FROM cur_inv where id=$id[$i],$dbh) or die
(Could not execute query, please try again later);
$row=mysql_fetch_array($result);
$car_type=$row['car_type'];
$car_model=$row['car_model'];
$car_year=$row['car_year'];
$car_price=$row['car_price'];
$car_vin=$row['car_vin'];


 INPUT TYPE=\hidden\ NAME=\id\ VALUE=\$id\
 INPUT TYPE=\hidden\ NAME=\car_type\ VALUE=\$car_type\
 INPUT TYPE=\hidden\ NAME=\car_model\ VALUE=\$car_model\
 INPUT TYPE=\hidden\ NAME=\car_year\ VALUE=\$car_year\
 INPUT TYPE=\hidden\ NAME=\car_price\ VALUE=\$car_price\
 INPUT TYPE=\hidden\ NAME=\car_vin\ VALUE=\$car_vin\
   tr
 td align=\center\ colspan=\3\font size=\4\BConfirm Record
 Deletion/B/fonthr color=\33\/td
   /tr
   tr
 td width=\30%\BType Of Car: /B/td
  td$car_type/td
   /tr
   tr
 td width=\30%\BModel Of Car: /B/td
  td$car_model/td
   /tr
   tr
 td width=\30%\BYear Of Car: /B/td
  td$car_year/td
   /tr
   tr
 td width=\30%\BPrice Of Car: /B/td
  td$car_price/td
   /tr
   tr
 td width=\30%\BVIN Of Car: /B/td
  td$car_vin/td
   /tr


$i++;

end loop here or after hr (wherever you prefer if you want hr between each 
item end after hr)

?}?


   tr
 td colspan=\3\hr color=\33\/td
   /tr
   tr
 tdinput type=\submit\ name=\delete\ value=\delete\/td
   

[PHP-DB] Array not supported for strings???

2002-01-04 Thread Andy

Hi there,

I have a problem with an array:

This code:
$country[] = $row-country;

Creates following error msg:
  Fatal error: [] operator not supported for strings

  The wired thing is, that the same procedure works through my whole
application, but not in this case.

  Did anybody make the same experience?

  Thanx for any help buddys.

  Regards Andy



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Array/List Session Variables

2001-12-22 Thread Matthew Tedder


Does anyone know if there is a way to include Arrays and/or Lists as session 
variables?  I'd really like to be able to add variable lists of variables to 
a session.

--Matthew


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] array-problems

2001-10-24 Thread Bruno Gimenes Pereti

It looks like you need only one array, $date[begin] = $date[end].
Let's see, I think it'll work. I'll write it in your code then you try:

$i=0;
$result = mysql_query (SELECT DISTINCT date FROM linktracker WHERE name
LIKE '$PHP_AUTH_USER' ORDER BY date);
if ($row = mysql_fetch_array($result)) {
  do {
$date[$i] = $row[date]);
$i++;
  } while ($row = mysql_fetch_array($result));
} else {print (Sorry, no record were found.);
} file://end else $result

print(tabletrtdBegindate/tdtdEnddate/td/tr\n.
trtdform method=\post\ action=\index.php\
name=\date_select\.
input type=\hidden\ name=\action\ value=\date_select\.
select name=\date_begin\);

$i = 0;
while ($date[$i]) {
  echo option value=\.$date_begin  .\ . $date_begin .
  /option\n;
  $i++;
}

print(/select/tdtdselect name=\date_end\);

$i--;
while ($date[$i]) {
  echo option value=\.$date_end  .\ . $date_end .
  /option\n;
  $i--;
}

print(/select/td/tr\ntrtd colspan=\2\.
input type=\submit\ name=\Submit\ value=\Submit\.
/form/td/tr/table);

mysql_free_result ($result);
mysql_close();


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] array-problems

2001-10-24 Thread Jim Lucas


- Original Message -
From: Jim Lucas [EMAIL PROTECTED]
To: Bart Verbeek [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, October 24, 2001 12:42 PM
Subject: Re: [PHP-DB] array-problems


 Try this:

  BEGIN:PHP-CODE 

 $result = mysql_query (SELECT DISTINCT date FROM linktracker WHERE name
 LIKE '$PHP_AUTH_USER' GROUP BY date ORDER BY date);
 if (mysql_num_rows($result))
 {
   for($i=0;$icount($row);$i++)
   {
 $date = array(
   begin = array($i = $row[date]),
   end = array($i = $row[date])
   );
   }
 } else {
   print (Sorry, no record were found.);
 }

 function drawSelect($which)
 {
   global $date;
   foreach($date[$which] AS $date_begin)
   {
 ?
 option value=?=$date_begin??=$date_begin?/option
 ?
   }

 }

 ?
 table
   tr
 tdBegindate/td
 tdEnddate/td
   /tr
   tr
 tdform method=post action=index.php name=date_select
 input type=hidden name=action value=date_select
 select name=date_begin
 ?
 drawSelect(begin);
 ?
 /select
 /td
 tdselect name=date_end
 ?
 rsort($date[end]);

 drawSelect(end);
 ?
 /select
 /td
   /tr
   tr
 td colspan=2input type=submit name=Submit
 value=Submit/form/td
   /tr/table

  END:PHP-CODE 

 btw - you need to watch your closing ''  you are missing a few.  Plus to
 get distince to work right you need to use the GROUP BY clause.

 Jim

 - Original Message -
 From: Bart Verbeek [EMAIL PROTECTED]
 To: Php-General-list [EMAIL PROTECTED]; PHP-DB mailinglist
 [EMAIL PROTECTED]
 Sent: Wednesday, October 24, 2001 12:23 PM
 Subject: [PHP-DB] array-problems


  Hello,
  Can anyone help me with this script I'm using?
 
  I've saved dates in a database and want to make two select-lists of
these
  dates in a html-form.
  I want to select each unique date one time (no doubles).
  List 1 is used to set the begin-date of the query for the report, List 2
  will
  set the end-date and must be reversed.
  When the form is processed the data selected between the begin-date and
 the
  end-date has to be show.
 
  I can't seem to get my code to work: the select-lists stay empty after
  processing the code below.
 
  Can anyone help? Tips...
 
  regards,
 
  Bart
 
 
   BEGIN:PHP-CODE 
  $i=0;
   $result = mysql_query (SELECT DISTINCT date FROM linktracker WHERE
name
  LIKE '$PHP_AUTH_USER' ORDER BY date);
   if ($row = mysql_fetch_array($result)) {
  do {
$date = array(
  begin = array($i = $row[date]),
  end = array($i = $row[date])
  );
  $i++;
  } while ($row = mysql_fetch_array($result));
   } else {print (Sorry, no record were found.);
   } //end else $result
 
  print(tabletrtdBegindate/tdtdEnddate/td/tr\n.
  trtdform method=\post\ action=\index.php\
  name=\date_select\.
  input type=\hidden\ name=\action\
  value=\date_select\.
  select name=\date_begin\);
 
  while (list($key, $date_begin) = each($date[begin])) {
  echo option value=\.$date_begin  .\ . $date_begin .
  /option\n;
  }
 
  print(/select/tdtdselect name=\date_end\);
 
  rsort($date[end]);
 
  while (list($key, $date_end) = each($date[end])) {
echo option value=\.$date_end  .\ . $date_end .
  /option\n;
  }
 
  print(/select/td/tr\ntrtd colspan=\2\.
input type=\submit\ name=\Submit\
value=\Submit\.
/form/td/tr/table);
 
  mysql_free_result ($result);
  mysql_close();
   END:PHP-CODE 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] array-problems

2001-10-24 Thread Bart Verbeek

Hello,
Can anyone help me with this script I'm using?

I've saved dates in a database and want to make two select-lists of these
dates in a html-form.
I want to select each unique date one time (no doubles).
List 1 is used to set the begin-date of the query for the report, List 2
will
set the end-date and must be reversed.
When the form is processed the data selected between the begin-date and the
end-date has to be show.

I can't seem to get my code to work: the select-lists stay empty after
processing the code below.

Can anyone help? Tips...

regards,

Bart


 BEGIN:PHP-CODE 
$i=0;
 $result = mysql_query (SELECT DISTINCT date FROM linktracker WHERE name
LIKE '$PHP_AUTH_USER' ORDER BY date);
 if ($row = mysql_fetch_array($result)) {
do {
  $date = array(
begin = array($i = $row[date]),
end = array($i = $row[date])
);
$i++;
} while ($row = mysql_fetch_array($result));
 } else {print (Sorry, no record were found.);
 } //end else $result

print(tabletrtdBegindate/tdtdEnddate/td/tr\n.
trtdform method=\post\ action=\index.php\
name=\date_select\.
input type=\hidden\ name=\action\
value=\date_select\.
select name=\date_begin\);

while (list($key, $date_begin) = each($date[begin])) {
echo option value=\.$date_begin  .\ . $date_begin .
/option\n;
}

print(/select/tdtdselect name=\date_end\);

rsort($date[end]);

while (list($key, $date_end) = each($date[end])) {
  echo option value=\.$date_end  .\ . $date_end .
/option\n;
}

print(/select/td/tr\ntrtd colspan=\2\.
  input type=\submit\ name=\Submit\ value=\Submit\.
  /form/td/tr/table);

mysql_free_result ($result);
mysql_close();
 END:PHP-CODE 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] array from html form

2001-10-05 Thread Larry Linthicum

Hi
I'm just a PHP hobbiest trying to build a points calculating system for
another hobby, please bear with me.

I need to build a multidimensional array from a html form,
the array  would look like:

$needed_data = array (
array (id = $member_id,
points = $position ),
array ( id = $member_id,
points =$position),
array (id=$member_id,
points = $position);

$member_id  will be used to dynamically build the html form,  $position will
be an integer entered into a text field in that form
similar to this:

Fred($member_id=?)   .. [ enter position=? ]
John)$member_id=?) ..[enter position=?]
etc
etc
[SUBMIT]

IF ( I can get the data into an array like above) {
I can make the rest of the script work }

but that is a big if G ... how can I stucture the form
and get that multidimen array from the single name/value pairs passed from
an html form?


OR
Maybe I can make a normal array work?
I know that enclosing form field names in [] makes them available as an
array


if the form were dynamically built like

PERSONS NAME (from database via $member_id )
 input type = hidden  name = [data] value = $member_id input type = text
name = [data] 
next PERSONS NAME (from database via $member_id )
 input type = hidden  name = [data] value = $member_id input type = text
name = [data] 
next PERSONS NAME (from database via $member_id )
 input type = hidden  name = [data] value = $member_id input type = text
name = [data] 
etc
etc


I think I would then send an array containing all the $member_id (s) and
all the entries into the txt fields

first... am I correct in that?

second  ... is the indexing order known and guaranteed?  in other words is
$data[0] and $data[1]   OR  $data[12] and $data[13]
ALWAYS going to represent a matched pair?   ( from one line of the
form } or is the indexing of the array subject to variation and may NOT be
in the same order as the [data] fields in the html ?

What if nothing is entered into the txt field?I know that enclosing form
field names in [] makes them available as an
array


if the form were dynamically built like

PERSONS NAME (from database via $member_id )
 input type = hidden  name = [data] value = $member_id input type = text
name = [data] 
next PERSONS NAME (from database via $member_id )
 input type = hidden  name = [data] value = $member_id input type = text
name = [data] 
next PERSONS NAME (from database via $member_id )
 input type = hidden  name = [data] value = $member_id input type = text
name = [data] 
etc
etc


I think I would then send an array containing all the $member_id (s) and
all the entries into the txt fields

first... am I correct in that?

second  ... is the indexing order known and guaranteed?  in other words is
$data[0] and $data[1]   OR  $data[12] and $data[13]
ALWAYS going to represent a matched pair?   ( from one line of the
form } or is the indexing of the array subject to variation and may NOT be
in the same order as the [data] fields in the html ?

What if nothing is entered into the txt field?




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] array from html form

2001-10-05 Thread Charles Butler

For one, why are you redefining the array 3 times in that script? ...
I'm trying to follow here... and its not making sense.

-Original Message-
From: Larry Linthicum [mailto:[EMAIL PROTECTED]] 
Sent: Friday, October 05, 2001 12:14 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] array from html form


Hi
I'm just a PHP hobbiest trying to build a points calculating system
for another hobby, please bear with me.

I need to build a multidimensional array from a html form,
the array  would look like:

$needed_data = array (
array (id = $member_id,
points = $position ),
array ( id = $member_id,
points =$position),
array (id=$member_id,
points = $position);

$member_id  will be used to dynamically build the html form,  $position
will be an integer entered into a text field in that form similar to
this:

Fred($member_id=?)   .. [ enter position=? ]
John)$member_id=?) ..[enter position=?]
etc
etc
[SUBMIT]

IF ( I can get the data into an array like above) {
I can make the rest of the script work }

but that is a big if G ... how can I stucture the form and get
that multidimen array from the single name/value pairs passed from an
html form?


OR
Maybe I can make a normal array work?
I know that enclosing form field names in [] makes them available as an
array


if the form were dynamically built like

PERSONS NAME (from database via $member_id )
 input type = hidden  name = [data] value = $member_id input type =
text name = [data]  next PERSONS NAME (from database via $member_id )
input type = hidden  name = [data] value = $member_id input type =
text name = [data]  next PERSONS NAME (from database via $member_id )
input type = hidden  name = [data] value = $member_id input type =
text name = [data]  etc etc


I think I would then send an array containing all the $member_id (s)
and all the entries into the txt fields

first... am I correct in that?

second  ... is the indexing order known and guaranteed?  in other words
is
$data[0] and $data[1]   OR  $data[12] and $data[13]
ALWAYS going to represent a matched pair?   ( from one line of the
form } or is the indexing of the array subject to variation and may NOT
be in the same order as the [data] fields in the html ?

What if nothing is entered into the txt field?I know that enclosing form
field names in [] makes them available as an array


if the form were dynamically built like

PERSONS NAME (from database via $member_id )
 input type = hidden  name = [data] value = $member_id input type =
text name = [data]  next PERSONS NAME (from database via $member_id )
input type = hidden  name = [data] value = $member_id input type =
text name = [data]  next PERSONS NAME (from database via $member_id )
input type = hidden  name = [data] value = $member_id input type =
text name = [data]  etc etc


I think I would then send an array containing all the $member_id (s)
and all the entries into the txt fields

first... am I correct in that?

second  ... is the indexing order known and guaranteed?  in other words
is
$data[0] and $data[1]   OR  $data[12] and $data[13]
ALWAYS going to represent a matched pair?   ( from one line of the
form } or is the indexing of the array subject to variation and may NOT
be in the same order as the [data] fields in the html ?

What if nothing is entered into the txt field?




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] array from html form

2001-10-05 Thread Larry Linthicum

the subarrays contain variable data and I tried to express that by showing
the array structure that way

if I access $needed_data[0]

it would be an array of two pieces of data ( both variable)

$needed_data[1] would also be an array of two variable pieces of data, etc

if I loop through them all I can use each member_id / positionpair to
update a database

but I have no way to know how many such pairs there will be, and the actual
values of $member_id

and of $position will be different in each case

I hope that helps, sorry I'm not more skilled at expressing this



 For one, why are you redefining the array 3 times in that script? ...
 I'm trying to follow here... and its not making sense.

 I need to build a multidimensional array from a html form,
 the array  would look like:

 $needed_data = array (
 array (id = $member_id,
 points = $position ),
 array ( id = $member_id,
 points =$position),
 array (id=$member_id,
 points = $position);

 $member_id  will be used to dynamically build the html form,  $position
 will be an integer entered into a text field in that form similar to
 this:

 Fred($member_id=?)   .. [ enter position=? ]
 John)$member_id=?) ..[enter position=?]
 etc
 etc
 [SUBMIT]

 IF ( I can get the data into an array like above) {
 I can make the rest of the script work }





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] array in db field - actual array

2001-09-13 Thread brendan

hi,
i am currently scouring the web for a solution to this but thought i 
would try here as well ..

i have a text field in a mysql database
the textfield contains an array written out as
//
$array[0][1]=one;
$array[0][2]=two;
$array[0][3]=thre;
$array[1][1]=four;
$array[2][1]=five;
//

now i need to extract this from the db .. simple
and use it as an array for a function .. not as simple as i thought it 
would be


ie

$newarray =mysqlquery('etc','etc','etc')
and $newarray should be
$newarray[0][1]=one;
$newarray[0][2]=two;
$newarray[0][3]=thre;
$newarray[1][1]=four;
$newarray[2][1]=five;

elp?

cheers
brendan


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] array in db field - actual array

2001-09-13 Thread Dobromir Velev

Hi,
I think you can use the eval() function to execute the stored info. The code
will look something like this
$res=mysql_query(...)
eval($row_from_query);

If you want to change the name of the array you could use
eval(str_replace($array,$newarray,$row_from_query));

HTH
Dobromir Velev

-Original Message-
From: brendan [EMAIL PROTECTED]
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
Date: Thursday, September 13, 2001 2:20 PM
Subject: [PHP-DB] array in db field - actual array


hi,
i am currently scouring the web for a solution to this but thought i
would try here as well ..

i have a text field in a mysql database
the textfield contains an array written out as
//
$array[0][1]=one;
$array[0][2]=two;
$array[0][3]=thre;
$array[1][1]=four;
$array[2][1]=five;
//

now i need to extract this from the db .. simple
and use it as an array for a function .. not as simple as i thought it
would be


ie

$newarray =mysqlquery('etc','etc','etc')
and $newarray should be
$newarray[0][1]=one;
$newarray[0][2]=two;
$newarray[0][3]=thre;
$newarray[1][1]=four;
$newarray[2][1]=five;

elp?

cheers
brendan


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re:[PHP-DB] array in db field - actual array

2001-09-13 Thread brendan

thanks dobromir,
unfortunately that doesnt seem to work  ...
although looking at the php manual you seem to be on the right track..
could the way the textfield is parsed  passed back affect the array?

cheers!
brendan

Dobromir Velev wrote:

 Hi,
 I think you can use the eval() function to execute the stored info. The code
 will look something like this
 $res=mysql_query(...)
 eval($row_from_query);
 
 If you want to change the name of the array you could use
 eval(str_replace($array,$newarray,$row_from_query));
 
 HTH
 Dobromir Velev
 
 -Original Message-
 From: brendan [EMAIL PROTECTED]
 To: [EMAIL PROTECTED] [EMAIL PROTECTED]
 Date: Thursday, September 13, 2001 2:20 PM
 Subject: [PHP-DB] array in db field - actual array
 
 
 
hi,
i am currently scouring the web for a solution to this but thought i
would try here as well ..

i have a text field in a mysql database
the textfield contains an array written out as
//
$array[0][1]=one;
$array[0][2]=two;
$array[0][3]=thre;
$array[1][1]=four;
$array[2][1]=five;
//

now i need to extract this from the db .. simple
and use it as an array for a function .. not as simple as i thought it
would be


ie

$newarray =mysqlquery('etc','etc','etc')
and $newarray should be
$newarray[0][1]=one;
$newarray[0][2]=two;
$newarray[0][3]=thre;
$newarray[1][1]=four;
$newarray[2][1]=five;

elp?

cheers
brendan


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




  1   2   >