[PHP-DB] foreach

2012-04-05 Thread Ethan Rosenberg

Dear Lists -

I know I am missing something fundamental - but I have no idea where 
to start to look.


Here are code snippets:

I have truncated the allowed_fields to make it easier to debug.

 $allowed_fields = array(  'Site' ='POST[Site]', 'MedRec' = 
'$_POST[MedRec]', 'Fname' = '$_POST[Fname]'   );

 echo post #1\n;
 print_r($_POST);

RESPONSE:

 post #1
Array
(
[Site] = AA
[MedRec] = 10002
[Fname] =
[Lname] =
[Phone] =
[Height] =
[welcome_already_seen] = already_seen
[next_step] = step10
)



//  $allowed_fields = array(Site, MedRec, 
Fname, Lname, // previous statement of $allowed_fields

  //  Phone, Sex, Height);



Key Site, Value POST[Site]
Key MedRec, Value $_POST[MedRec]
Key Fname, Value $_POST[Fname]



foreach ($allowed_fields as $key = $val) {
print Key $key, Value $val\n;
}


if(isset($_Request['Sex']) trim($_POST['Sex']) != '' )
{
if ($_REQUEST['Sex'] === 0)
{
$sex = 'Male';
}
else
{
$sex = 'Female';
}
}
 }
echo Post#2;
print_r($_POST);
   if(empty($allowed_fields))
//RESPONSE

Post#2Array
(
[Site] = AA
[MedRec] = 10002
[Fname] =
[Lname] =
[Phone] =
[Height] =
[welcome_already_seen] = already_seen
[next_step] = step10
)



   {
 echo ouch;
   }

foreach ( $allowed_fields as $key = $val ) //This is line 198
{
if ( ! empty( $_POST['val'] ) )
{
print Key $key, Value $val\n;
$cxn = mysqli_connect($host,$user,$password,$db);
$value = mysql_real_escape_string( $_POST[$fld] );
$query .=  AND $fld = '$_POST[value]' ;
   echo #1 $query; //never echos the query
}
}

These are the messages I receive on execution of the script:

Notice: Undefined variable: allowed_fields in 
/var/www/srchrhsptl5.php on line 198
Warning: Invalid argument supplied for foreach() in 
/var/www/srchrhsptl5.php on line 198


Advice and help, please.

Thank you.

Ethan Rosenberg




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



[PHP-DB] foreach()

2005-01-31 Thread Yemi Obembe


Hi folks.
wat can be done to dis:

 $z = array('foo' = array('bar')), 'dis' = array('dat'));
foreach(//???) {
echo //??? br //?? /p;
}

to output dis: 

foo
bar

dis
dat

 



-

A passion till tomorrow,
Opeyemi Obembe | ng.clawz.com






-
Do you Yahoo!?
 The all-new My Yahoo! – What will yours do?

Re: [PHP-DB] foreach()

2005-01-31 Thread Han
Try this : --
$z = array('foo' = array('bar')), 'dis' = array('dat'));
while (list($key, $val) = each($z)) {
echo BR$key $val;
}

- Original Message - 
From: Yemi Obembe [EMAIL PROTECTED]
To: php-db@lists.php.net
Sent: Monday, January 31, 2005 9:47 AM
Subject: [PHP-DB] foreach()



Hi folks.
wat can be done to dis:
$z = array('foo' = array('bar')), 'dis' = array('dat'));
foreach(//???) {
echo //??? br //?? /p;
}
to output dis: 

foo
bar
dis
dat


-
A passion till tomorrow,
Opeyemi Obembe | ng.clawz.com


-
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] foreach()

2005-01-31 Thread graeme
try...
$z = array('foo' = array('bar'), 'dis' = array('dat'));
foreach($z as $key = $value)
{
echo $key br $value[0] /p;
}
graeme.
Yemi Obembe wrote:
Hi folks.
wat can be done to dis:
$z = array('foo' = array('bar')), 'dis' = array('dat'));
foreach(//???) {
echo //??? br //?? /p;
}
to output dis: 

foo
bar
dis
dat


-
A passion till tomorrow,
Opeyemi Obembe | ng.clawz.com


		
-
Do you Yahoo!?
The all-new My Yahoo!  What will yours do?
 

--
Experience is a good teacher, but she sends in terrific bills.
Minna Antrim
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] foreach()

2005-01-31 Thread graeme
or even...
$z = array('foo' = array('bar'), 'dis' = array('dat'));
while (list($key, $val) = each($z)) {
echo $keyBR $val[0]p;
}
You need to remove the superfluous close bracket on after bar, and the 
val is an array hence $val[0] to get the element displayed.

graeme.
Han wrote:
Try this : --
$z = array('foo' = array('bar')), 'dis' = array('dat'));
while (list($key, $val) = each($z)) {
echo BR$key $val;
}

- Original Message - From: Yemi Obembe [EMAIL PROTECTED]
To: php-db@lists.php.net
Sent: Monday, January 31, 2005 9:47 AM
Subject: [PHP-DB] foreach()


Hi folks.
wat can be done to dis:
$z = array('foo' = array('bar')), 'dis' = array('dat'));
foreach(//???) {
echo //??? br //?? /p;
}
to output dis:
foo
bar
dis
dat


-
A passion till tomorrow,
Opeyemi Obembe | ng.clawz.com


-
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?

--
Experience is a good teacher, but she sends in terrific bills.
Minna Antrim
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] foreach() db brainiacs please help?

2003-09-09 Thread Peter Sharpe
I have a database full of names. each name could be linked to any number of
sub-names, each sub-name could be linked to any number of sub-sub-names, to
infinity (unlikely but possible).

I need to iterate through this nest of names starting with a main name; lets
call the main name Peter. Peter could have John, Tim  Mike working for him.
Tim could have Greg working for him.

function select_names($current_top_name){
global $dbh;

$sql = 
SELECT
 name_id_fk
FROM
 name_relation
WHERE
 top_name_id_fk = '.$current_top_name.'
;
$rs = pg_query($dbh, $sql);

if(($num_rows = pg_num_rows($rs))  0){

for($i=0;$i$num_rows;$i++){
$row = pg_fetch_row($rs, $i, PGSQL_ASSOC);
$associated_names[] = $row['name_id_fk'];
}

pg_free_result($rs);

} // end if(($num_rows = pg_num_rows($rs))  0)

return $associated_names;

} // end function select_names()

$current_top_name = 'Peter';

while(!$stop){

$assoc_names = select_names($current_top_name);

foreach($assoc_names as $key = $val){
print($val);
$more_assoc_names = select_names($val);
if($more_assoc_names){
ARG HELP IM NOT SMART ENOUGH
}

} // end while(!$stop)

} // end foreach($assoc_names as $key = $val)

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



Re: [PHP-DB] foreach() db brainiacs please help?

2003-09-09 Thread jeffrey_n_Dyke

couldn't this be accomplished with a Left Join? Depending on how your
tables are arranged you should be able to get all (sub)sub-names out and in
the same result set using the top_name with a Left Join.  any key that
relates to the parent key would be returned.

it looks like you have them all in the same table thoughwhich may
furuther complicate things, if so, how is the relatoinship maintained in
the table(s)?

Jeff


   
 
  Peter Sharpe   
 
  [EMAIL PROTECTED]To:   [EMAIL PROTECTED]
   
  .comcc: 
 
   Subject:  [PHP-DB] foreach()  db 
brainiacs please help? 
  09/09/2003 03:17 
 
  PM   
 
  Please respond to
 
  Peter Sharpe   
 
   
 
   
 




I have a database full of names. each name could be linked to any number of
sub-names, each sub-name could be linked to any number of sub-sub-names, to
infinity (unlikely but possible).

I need to iterate through this nest of names starting with a main name;
lets
call the main name Peter. Peter could have John, Tim  Mike working for
him.
Tim could have Greg working for him.

function select_names($current_top_name){
global $dbh;

$sql = 
SELECT
 name_id_fk
FROM
 name_relation
WHERE
 top_name_id_fk = '.$current_top_name.'
;
$rs = pg_query($dbh, $sql);

if(($num_rows = pg_num_rows($rs))  0){

for($i=0;$i$num_rows;$i++){
$row = pg_fetch_row($rs, $i, PGSQL_ASSOC);
$associated_names[] = $row['name_id_fk'];
}

pg_free_result($rs);

} // end if(($num_rows = pg_num_rows($rs))  0)

return $associated_names;

} // end function select_names()

$current_top_name = 'Peter';

while(!$stop){

$assoc_names = select_names($current_top_name);

foreach($assoc_names as $key = $val){
print($val);
$more_assoc_names = select_names($val);
if($more_assoc_names){
ARG HELP IM NOT SMART ENOUGH
}

} // end while(!$stop)

} // end foreach($assoc_names as $key = $val)

--
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] foreach problem

2003-02-07 Thread Sam Folk-Williams
Hi,

I can't figure out why this won't work:

foreach($event_date as $val) {

$sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES (\$entry_id\,
\$val\);
$result = @mysql_query($sql2,$connection) or die
 (Problem executing foreach database query.);
 }

$event_date is an array with several dates separated by commas. (2003-10-02,
2003-10-03). The code above successfuly inserts the first dae in the array,
but none of the others... am I missing something?

Thank you.

Sam



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




Re: [PHP-DB] foreach problem

2003-02-07 Thread Jason Wong
On Friday 07 February 2003 11:22, Sam Folk-Williams wrote:
 Hi,

 I can't figure out why this won't work:

 foreach($event_date as $val) {

 $sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES (\$entry_id\,
 \$val\);
 $result = @mysql_query($sql2,$connection) or die
  (Problem executing foreach database query.);
  }

 $event_date is an array with several dates separated by commas.
 (2003-10-02, 2003-10-03). The code above successfuly inserts the first dae
 in the array, but none of the others... am I missing something?

Any error messages? If so what does mysql_error() say?

-- 
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
--
/*
WHERE CAN THE MATTER BE
Oh, dear, where can the matter be
When it's converted to energy?
There is a slight loss of parity.
Johnny's so long at the fair.
*/


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




Re: [PHP-DB] foreach problem

2003-02-07 Thread Sam Folk-Williams
I don't get any MySQL error... It adds the first entry_id and date exactly
as it should... it seems to be acting like entry_date is not an array, but
when I use the same foreach loop to echo the contents of entry_date it
echoes the multiple values (2003-05-01, 2003-05-02, etc)... I use the same
code to insert checkbox data in a different form, so... I'm kinda stumped.

Sam
Jason Wong [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Friday 07 February 2003 11:22, Sam Folk-Williams wrote:
  Hi,
 
  I can't figure out why this won't work:
 
  foreach($event_date as $val) {
 
  $sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES
(\$entry_id\,
  \$val\);
  $result = @mysql_query($sql2,$connection) or die
   (Problem executing foreach database query.);
   }
 
  $event_date is an array with several dates separated by commas.
  (2003-10-02, 2003-10-03). The code above successfuly inserts the first
dae
  in the array, but none of the others... am I missing something?

 Any error messages? If so what does mysql_error() say?

 --
 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
 --
 /*
 WHERE CAN THE MATTER BE
 Oh, dear, where can the matter be
 When it's converted to energy?
 There is a slight loss of parity.
 Johnny's so long at the fair.
 */




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




Re: [PHP-DB] foreach problem

2003-02-07 Thread Jason Wong
On Saturday 08 February 2003 06:16, Sam Folk-Williams wrote:
 I don't get any MySQL error... It adds the first entry_id and date exactly
 as it should... it seems to be acting like entry_date is not an array, but
 when I use the same foreach loop to echo the contents of entry_date it
 echoes the multiple values (2003-05-01, 2003-05-02, etc)... I use the same
 code to insert checkbox data in a different form, so... I'm kinda stumped.

   $sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES

echo $sql2 and plug each of them into the mysql commandline to see what 
happens.

   $event_date is an array with several dates separated by commas.
   (2003-10-02, 2003-10-03). The code above successfuly inserts the first

Could you explain what exactly $event_date contains? The output of 
print_r($event_date) would suffice. 

-- 
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
--
/*
Art is anything you can get away with.
-- Marshall McLuhan.
*/


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




Re: [PHP-DB] foreach($HTTP_POST_VARS as $key = $value)

2003-01-22 Thread Andrey Hristov
 Long time ago I built a class for these needs. In fact the half of the code
is *stolen* from implemenation of my colleague. I just made it OOP.

 The class in pi-validate.class.php.txt, the definitions of the checked
fields is in pi-validate.defs.php

Sample use :
  $validate_result = CValidate::validate_validate_data(VALIDATE_NEW_USER,
$user_data);
  if ($validate_result[0] != GENERAL_OPERATION_SUCCESSFUL){
   return array(VALIDATE_FAIL, VALIDATE_FAIL_MESSAGE, $validate_result[2]);
  }/* if */

It is kindly complicated example but hope you get it. For every new page
just define the variables you expect to come and rules for them and nothing
more is needed except to place a code like that above to check the validity.
In case of error $validate_result will contain information for the error.


Regards,
Andrey


- Original Message -
From: Addison Ellis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, January 22, 2003 9:24 AM
Subject: [PHP-DB] foreach($HTTP_POST_VARS as $key = $value)


 hello,
 i do appreciate your time...
 below the code following i don't know where to go. do i need
 to list each value individually or can i do something with
 $HTTP_POST_VARS  or am i even headed in the right direction? i am
 trying to point all my forms to this .php file to check for errors,
 and if they are ok, insert the submitted form values into a table in
 a database. thank you. addison ellis
 foreach($HTTP_POST_VARS as $key = $value)
{
  if ($key != )
  {
if ($value == )
{
  $message_new = font face=verdana size=1
 color=redRequired information missing.\n
  Please try again./font;
}
  }
  if (ereg({name),$key))
  {
   if (!ereg(^[A-Za-z' -]{1,50}$,$key))
   {
 $message_new = font face=verdana size=1 color=redSome
 information not processing.\n
  Please try again./font;
   }
  }
  $$key = strip_tags(trim($value));
}
if (!ereg(^[0-9)(xX -]{7,20}$,$phone))
{
  $message_new = font face=verdana size=1 color=redNot a
 valid phone number.\n
  Please try again./font;
}
if (!ereg(^.+@.+\\..+$,$email))
{
  $message_new = font face=verdana size=1 color=redNot a
 valid email address.\n
   Please try again./font;
 }
else
 if ($message == )
 {
 $query = insert into ad_columns  set
 --
 Addison Ellis
 small independent publishing co.
 114 B 29th Avenue North
 Nashville, TN 37203
 (615) 321-1791
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 subsidiaries of small independent publishing co.
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]

?php
/**
Definition file - defintions of various data.

This module is part from PHPIntra system and is licensed under GPL.

@author Andrey Hristov [EMAIL PROTECTED]
@version$Id: pi-validate.defs.php,v 1.3 2002/07/09 07:30:22 nobody Exp $
@packagePHPIntra
@module pi_validate_defs
*/

/**
@const  VALIDATE_NEW_RULE   .
*/
define('VALIDATE_NEW_RULE', 'new_rule_defs');

/**
@const  VALIDATE_UPDATE_RULE.
*/
define('VALIDATE_UPDATE_RULE', 'update_rule_defs');

/**
@const  VALIDATE_NEW_USER   .
*/
define('VALIDATE_NEW_USER', 'new_user_defs');

/**
@const  VALIDATE_CHANGE_USER_DATA   .
*/
define('VALIDATE_CHANGE_USER_DATA', 'change_user_defs');

/**
@const  VALIDATE_CREATE_TASK_DATA   .
*/
define('VALIDATE_CREATE_TASK_DATA', 'create_task');

/**
@const  VALIDATE_UPDATE_TASK_DATA   .
*/
define('VALIDATE_UPDATE_TASK_DATA', 'update_task');

/**
@const  VALIDATE_CREATE_WSESSION_DATA   .
*/
define('VALIDATE_CREATE_WSESSION_DATA', 'create_wsession');

/*
T - Text
H - Hidden
P - Password
A - text Area
F - File upload
L - List (select)
M - Multiple Selection
C - Checkbox
*/
define('VALIDATE_TYPE_INT',1);
define('VALIDATE_TYPE_FLOAT',2);
define('VALIDATE_TYPE_ARRAY',3);
define('VALIDATE_TYPE_STRING',4);

define('VALIDATE_SELECT_NONE','none');

$VALIDATE_DEFINITIONS = array(
VALIDATE_UPDATE_RULE = array(
'old_schedule_id'   = array(
'type'  = 'T',
'pattern'   = '/^\d+$/',
'optional'  = 0,
'maxlen'= 10,
'allowtags' = 0,
'lang_type' = VALIDATE_TYPE_INT,
),
'old_start_time'= array(
'type'  = 'T',
'pattern'   = 
'/^(?:(?:(?:0|1|)[\d]{1})|(?:2[0-3]{1}))(?:\:[\d]{0,2}){0,2}$/',
'optional'  = 0,
'maxlen'= 8,
'allowtags' = 0,
'lang_type' = VALIDATE_TYPE_STRING,
),
'schedule_id

[PHP-DB] foreach($HTTP_POST_VARS as $key = $value)

2003-01-21 Thread Addison Ellis
hello,
	i do appreciate your time...
	below the code following i don't know where to go. do i need 
to list each value individually or can i do something with 
$HTTP_POST_VARS  or am i even headed in the right direction? i am 
trying to point all my forms to this .php file to check for errors, 
and if they are ok, insert the submitted form values into a table in 
a database. thank you. addison ellis
foreach($HTTP_POST_VARS as $key = $value)   
  {
if ($key != )
{
  if ($value == )
  {
$message_new = font face=verdana size=1 
color=redRequired information missing.\n
Please try again./font;
  }
} 
if (ereg({name),$key))   
{
 if (!ereg(^[A-Za-z' -]{1,50}$,$key))
 {
   $message_new = font face=verdana size=1 color=redSome 
information not processing.\n
Please try again./font;
 } 
}
$$key = strip_tags(trim($value));  
  }
  if (!ereg(^[0-9)(xX -]{7,20}$,$phone)) 
  {
$message_new = font face=verdana size=1 color=redNot a 
valid phone number.\n
Please try again./font; 
  }
  if (!ereg(^.+@.+\\..+$,$email)) 
  {
$message_new = font face=verdana size=1 color=redNot a 
valid email address.\n
 Please try again./font;
}
  else
if ($message == )
	{
	$query = insert into ad_columns  set
--
Addison Ellis
small independent publishing co.
114 B 29th Avenue North
Nashville, TN 37203
(615) 321-1791
[EMAIL PROTECTED]
[EMAIL PROTECTED]
subsidiaries of small independent publishing co.
[EMAIL PROTECTED]
[EMAIL PROTECTED]

RE: [PHP-DB] foreach loop from MySQL select query to HTML select list

2002-11-28 Thread John W. Holmes
 i've looked around the web a bit more  it would appear you can't just
use
 a
 foreach function, apparently you need to use a while{foreach{}}
structure.
 i
 was hoping you could just use the foreach function?
 
 so this is the code now:
 
 select name=deptsub_select
   option-select-/option
 ?PHP
 while ($row = mysql_fetch_array($result_deptsub)){
   foreach ($row as $value) {
 echo option value=\$value\$value/option\n;

Where did you get the idea to use foreach? Your select statement is only
selecting one column, so $row is only going to have one column in it for
each mysql_fetch_*. 

Use something like this:

while($row = mysql_fetch_array($result_deptsub))
{ echo option
value=\{$row['deptsub']}\{$row['deptsub']}/option\n; }

---John Holmes...



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




RE: [PHP-DB] foreach loop from MySQL select query to HTML select list

2002-11-28 Thread Gavin Amm
hmm, interesting to know the mysql_fetch_array() by default returns an array
that's associative AND numeric - very useful to know  something i'll have
to look into more, thanks Jason.

Thanks also John, puting curley braces around the variables is a valuable
lesson - works wonderfully - cheers.

i do have one more problem though, i need to run the loop a 2nd time later
in the page in exactly the same way, but nothing is returned.
i just copied  pasted the code from one section of the page to the next.
do i need to reset one of the vaiables? 


select name=dept
  option-select-/option
  ?PHP
  while($row = mysql_fetch_array($result_dept)){
echo option value=\{$row['dept']}\{$row['dept']}/option\n;
  }
  ?
/select


cheers, Gav



-Original Message-
From: John W. Holmes [mailto:[EMAIL PROTECTED]]
Sent: Friday, 29 November 2002 2:59 AM
To: 'Gavin Amm'; 'Php-Db (E-mail)'
Subject: RE: [PHP-DB] foreach loop from MySQL select query to HTML
select list


 i've looked around the web a bit more  it would appear you can't just
use
 a
 foreach function, apparently you need to use a while{foreach{}}
structure.
 i
 was hoping you could just use the foreach function?
 
 so this is the code now:
 
 select name=deptsub_select
   option-select-/option
 ?PHP
 while ($row = mysql_fetch_array($result_deptsub)){
   foreach ($row as $value) {
 echo option value=\$value\$value/option\n;

Where did you get the idea to use foreach? Your select statement is only
selecting one column, so $row is only going to have one column in it for
each mysql_fetch_*. 

Use something like this:

while($row = mysql_fetch_array($result_deptsub))
{ echo option
value=\{$row['deptsub']}\{$row['deptsub']}/option\n; }

---John Holmes...



This e-mail and any attachments are intended solely for the named addressee,
are confidential and may contain legally privileged information. 

The copying or distribution of them or of any information they contain, by
anyone other than the addressee, is prohibited. If you received this e-mail
in error, please notify us immediately by return e-mail or telephone +61 2
9413 2944 and destroy the original message. Thank you. 

As Email is subject to viruses we advise that all Emails and any attachments
should be scanned by an up to-date Anti Virus programme automatically by
your system. It is the responsibility of the recipient to ensure that all
Emails and any attachments are cleared of Viruses before opening. KSG can
not accept any responsibility for viruses that maybe contained here in.
Please advise KSG by return Email if you believe any Email sent by our
system may contain a virus. It should be noted that most Anti Virus
programmes can not scan encrypted file attachments (example - documents
saved with a password). Thus extra care should be taken when opening these
files. 

Liability limited by the Accountants Scheme, approved under the Professional
Standards Act 1994 (NSW). 



Level 4 
54 Neridah StreetPO Box 1290 
CHATSWOOD   NSW   2067   CHATSWOOD   NSW   2057 


Ph: +61 2 9413 2944  Fax: +61 2 9413 9901

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




RE: [PHP-DB] foreach loop from MySQL select query to HTML select list

2002-11-28 Thread John W. Holmes
 hmm, interesting to know the mysql_fetch_array() by default returns an
 array
 that's associative AND numeric - very useful to know  something i'll
have
 to look into more, thanks Jason.
 
 Thanks also John, puting curley braces around the variables is a
valuable
 lesson - works wonderfully - cheers.
 
 i do have one more problem though, i need to run the loop a 2nd time
later
 in the page in exactly the same way, but nothing is returned.
 i just copied  pasted the code from one section of the page to the
next.
 do i need to reset one of the vaiables?
 
 
 select name=dept
   option-select-/option
   ?PHP
   while($row = mysql_fetch_array($result_dept)){
 echo option value=\{$row['dept']}\{$row['dept']}/option\n;
   }
   ?
 /select

Put the options into a variable and just echo it out where you need it.

$options = option-select-/option\n;
while($row = mysql_fetch_row($result))
{ $options .= option value=\{$row[0]}\{$row[0]}/option\n; }

And wherever you need a select statement, just 

select name=dept
?=$options?

---John Holmes...



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




RE: [PHP-DB] foreach loop from MySQL select query to HTML select list

2002-11-28 Thread Gavin Amm
thanks John,
i was thinking along similar lines.
that should work well.
cheers,
Gav


-Original Message-
From: John W. Holmes [mailto:[EMAIL PROTECTED]]
Sent: Friday, 29 November 2002 4:08 PM
To: 'Gavin Amm'; 'Php-Db (E-mail)'
Subject: RE: [PHP-DB] foreach loop from MySQL select query to HTML
select list


 hmm, interesting to know the mysql_fetch_array() by default returns an
 array
 that's associative AND numeric - very useful to know  something i'll
have
 to look into more, thanks Jason.
 
 Thanks also John, puting curley braces around the variables is a
valuable
 lesson - works wonderfully - cheers.
 
 i do have one more problem though, i need to run the loop a 2nd time
later
 in the page in exactly the same way, but nothing is returned.
 i just copied  pasted the code from one section of the page to the
next.
 do i need to reset one of the vaiables?
 
 
 select name=dept
   option-select-/option
   ?PHP
   while($row = mysql_fetch_array($result_dept)){
 echo option value=\{$row['dept']}\{$row['dept']}/option\n;
   }
   ?
 /select

Put the options into a variable and just echo it out where you need it.

$options = option-select-/option\n;
while($row = mysql_fetch_row($result))
{ $options .= option value=\{$row[0]}\{$row[0]}/option\n; }

And wherever you need a select statement, just 

select name=dept
?=$options?

---John Holmes...



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


This e-mail and any attachments are intended solely for the named addressee,
are confidential and may contain legally privileged information. 

The copying or distribution of them or of any information they contain, by
anyone other than the addressee, is prohibited. If you received this e-mail
in error, please notify us immediately by return e-mail or telephone +61 2
9413 2944 and destroy the original message. Thank you. 

As Email is subject to viruses we advise that all Emails and any attachments
should be scanned by an up to-date Anti Virus programme automatically by
your system. It is the responsibility of the recipient to ensure that all
Emails and any attachments are cleared of Viruses before opening. KSG can
not accept any responsibility for viruses that maybe contained here in.
Please advise KSG by return Email if you believe any Email sent by our
system may contain a virus. It should be noted that most Anti Virus
programmes can not scan encrypted file attachments (example - documents
saved with a password). Thus extra care should be taken when opening these
files. 

Liability limited by the Accountants Scheme, approved under the Professional
Standards Act 1994 (NSW). 



Level 4 
54 Neridah StreetPO Box 1290 
CHATSWOOD   NSW   2067   CHATSWOOD   NSW   2057 


Ph: +61 2 9413 2944  Fax: +61 2 9413 9901

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




RE: [PHP-DB] foreach loop from MySQL select query to HTML select list

2002-11-28 Thread Rick Widmer
At 10:40 AM 11/29/02 +1100, Gavin Amm wrote:

hmm, interesting to know the mysql_fetch_array() by default returns an array
that's associative AND numeric - very useful to know  something i'll have
to look into more, thanks Jason.


Using PHP's built in template system...

$result_dept = mysql_query( SELECT DepartmentID, Department
 FROM Departments
 ORDER BY Department );
...

select name=dept
  option-select-/option
  ? while( extract( mysql_fetch_array($result_dept, MYSQL_ASSOC))) : ?
  option value=?=$DepartmentID??=$Department?/option
  ? endwhile ?
/select

i do have one more problem though, i need to run the loop a 2nd time later

in the page in exactly the same way, but nothing is returned.
i just copied  pasted the code from one section of the page to the next.
do i need to reset one of the vaiables?



mysql_data_seek()

http://www.php.net/manual/en/function.mysql-data-seek.php

Rick


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




[PHP-DB] foreach loop from MySQL select query to HTML select list

2002-11-27 Thread Gavin Amm
Hi,

I'm trying to pick up data from my MySQL database, use a foreach loop to
extact the data from the result  put that data into a select list.

I have tried the following code with  without the $row = ... line, both
unsucessfully:

?PHP
$db = mysql_connect(myhost, username, );
mysql_select_db(mydatabase, $db);

## FETCH INFO
$sql_dept = SELECT dept FROM content GROUP BY dept;
$sql_deptsub = SELECT deptsub FROM content GROUP BY deptsub;

mysql_close($db);
?


select name=dept
  option-select-/option
?PHP
$result = mysql_query($sql_dept, $db);
$row = mysql_fetch_array($result);
foreach ($row as $value) {echo option
value=\$value\$value/option\n;}
?
/select


I get the following error message in my HTML output code:

bWarning/b:  1 is not a valid MySQL-Link resource in
b/home/.../public_html/content.php/b on line b48/bbr
br
bWarning/b:  Invalid argument supplied for foreach() in
b/home/.../public_html/content.php/b on line b49/bbr

Line 48 is the line begining with: foreach...


Any help would be appreciated.
Thanks,
Gav


This e-mail and any attachments are intended solely for the named addressee,
are confidential and may contain legally privileged information. 

The copying or distribution of them or of any information they contain, by
anyone other than the addressee, is prohibited. If you received this e-mail
in error, please notify us immediately by return e-mail or telephone +61 2
9413 2944 and destroy the original message. Thank you. 

As Email is subject to viruses we advise that all Emails and any attachments
should be scanned by an up to-date Anti Virus programme automatically by
your system. It is the responsibility of the recipient to ensure that all
Emails and any attachments are cleared of Viruses before opening. KSG can
not accept any responsibility for viruses that maybe contained here in.
Please advise KSG by return Email if you believe any Email sent by our
system may contain a virus. It should be noted that most Anti Virus
programmes can not scan encrypted file attachments (example - documents
saved with a password). Thus extra care should be taken when opening these
files. 

Liability limited by the Accountants Scheme, approved under the Professional
Standards Act 1994 (NSW). 



Level 4 
54 Neridah StreetPO Box 1290 
CHATSWOOD   NSW   2067   CHATSWOOD   NSW   2057 


Ph: +61 2 9413 2944  Fax: +61 2 9413 9901

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




Re: [PHP-DB] foreach loop from MySQL select query to HTML selectlist

2002-11-27 Thread John Coder
On Wed, 2002-11-27 at 23:33, Gavin Amm wrote:
 Hi,
 
 I'm trying to pick up data from my MySQL database, use a foreach loop to
 extact the data from the result  put that data into a select list.
 
 I have tried the following code with  without the $row = ... line, both
 unsucessfully:
 
 ?PHP
 $db = mysql_connect(myhost, username, );
 mysql_select_db(mydatabase, $db);
 
 ## FETCH INFO
 $sql_dept = SELECT dept FROM content GROUP BY dept;
 $sql_deptsub = SELECT deptsub FROM content GROUP BY deptsub;
 
 mysql_close($db);

How can run a query when it's closed? move this to after the select and
see if it works.
 ?
 
 
 select name=dept
   option-select-/option
 ?PHP
   $result = mysql_query($sql_dept, $db);
   $row = mysql_fetch_array($result);
   foreach ($row as $value) {echo option
 value=\$value\$value/option\n;}
 ?
 /select

Put your mysql_close here if you want to close it.

John Coder


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




RE: [PHP-DB] foreach loop from MySQL select query to HTML select list

2002-11-27 Thread Gavin Amm
good point! whoops.
ok, i've moved the $result_dept  $result_deptsub queries,
now i'm getting 2 of the same entries in my html code:

select name=dept
  option-select-/option
  option value=auditaudit/option
  option value=auditaudit/option
/select

any thoughts?
Gav

-Original Message-
From: John Coder [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 28 November 2002 3:44 PM
To: Gavin Amm
Cc: Php-Db (E-mail)
Subject: Re: [PHP-DB] foreach loop from MySQL select query to HTML
select list


On Wed, 2002-11-27 at 23:33, Gavin Amm wrote:
 Hi,
 
 I'm trying to pick up data from my MySQL database, use a foreach loop to
 extact the data from the result  put that data into a select list.
 
 I have tried the following code with  without the $row = ... line, both
 unsucessfully:
 
 ?PHP
 $db = mysql_connect(myhost, username, );
 mysql_select_db(mydatabase, $db);
 
 ## FETCH INFO
 $sql_dept = SELECT dept FROM content GROUP BY dept;
 $sql_deptsub = SELECT deptsub FROM content GROUP BY deptsub;
 
 mysql_close($db);

How can run a query when it's closed? move this to after the select and
see if it works.
 ?
 
 
 select name=dept
   option-select-/option
 ?PHP
   $result = mysql_query($sql_dept, $db);
   $row = mysql_fetch_array($result);
   foreach ($row as $value) {echo option
 value=\$value\$value/option\n;}
 ?
 /select

Put your mysql_close here if you want to close it.

John Coder


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


This e-mail and any attachments are intended solely for the named addressee,
are confidential and may contain legally privileged information. 

The copying or distribution of them or of any information they contain, by
anyone other than the addressee, is prohibited. If you received this e-mail
in error, please notify us immediately by return e-mail or telephone +61 2
9413 2944 and destroy the original message. Thank you. 

As Email is subject to viruses we advise that all Emails and any attachments
should be scanned by an up to-date Anti Virus programme automatically by
your system. It is the responsibility of the recipient to ensure that all
Emails and any attachments are cleared of Viruses before opening. KSG can
not accept any responsibility for viruses that maybe contained here in.
Please advise KSG by return Email if you believe any Email sent by our
system may contain a virus. It should be noted that most Anti Virus
programmes can not scan encrypted file attachments (example - documents
saved with a password). Thus extra care should be taken when opening these
files. 

Liability limited by the Accountants Scheme, approved under the Professional
Standards Act 1994 (NSW). 



Level 4 
54 Neridah StreetPO Box 1290 
CHATSWOOD   NSW   2067   CHATSWOOD   NSW   2057 


Ph: +61 2 9413 2944  Fax: +61 2 9413 9901

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




RE: [PHP-DB] foreach loop from MySQL select query to HTML select list

2002-11-27 Thread Gavin Amm
ok,

i've looked around the web a bit more  it would appear you can't just use a
foreach function, apparently you need to use a while{foreach{}} structure. i
was hoping you could just use the foreach function?

so this is the code now:

select name=deptsub_select
  option-select-/option
?PHP
while ($row = mysql_fetch_array($result_deptsub)){
  foreach ($row as $value) {
echo option value=\$value\$value/option\n;
  }
}
?
/select


but now the output HTML code is doubling up:

select name=dept
option-select-/option
option value=auditaudit/option
option value=auditaudit/option
option value=consultingconsulting/option
option value=consultingconsulting/option
...
/select


cheers,
Gav


This e-mail and any attachments are intended solely for the named addressee,
are confidential and may contain legally privileged information. 

The copying or distribution of them or of any information they contain, by
anyone other than the addressee, is prohibited. If you received this e-mail
in error, please notify us immediately by return e-mail or telephone +61 2
9413 2944 and destroy the original message. Thank you. 

As Email is subject to viruses we advise that all Emails and any attachments
should be scanned by an up to-date Anti Virus programme automatically by
your system. It is the responsibility of the recipient to ensure that all
Emails and any attachments are cleared of Viruses before opening. KSG can
not accept any responsibility for viruses that maybe contained here in.
Please advise KSG by return Email if you believe any Email sent by our
system may contain a virus. It should be noted that most Anti Virus
programmes can not scan encrypted file attachments (example - documents
saved with a password). Thus extra care should be taken when opening these
files. 

Liability limited by the Accountants Scheme, approved under the Professional
Standards Act 1994 (NSW). 



Level 4 
54 Neridah StreetPO Box 1290 
CHATSWOOD   NSW   2067   CHATSWOOD   NSW   2057 


Ph: +61 2 9413 2944  Fax: +61 2 9413 9901

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




Re: [PHP-DB] foreach loop from MySQL select query to HTML select list

2002-11-27 Thread Jason Wong
On Thursday 28 November 2002 14:21, Gavin Amm wrote:
 ok,

 i've looked around the web a bit more  it would appear you can't just use
 a foreach function, apparently you need to use a while{foreach{}}
 structure. i was hoping you could just use the foreach function?

 so this is the code now:

 select name=deptsub_select
   option-select-/option
 ?PHP
 while ($row = mysql_fetch_array($result_deptsub)){
   foreach ($row as $value) {
 echo option value=\$value\$value/option\n;
   }
 }
 ?
 /select


 but now the output HTML code is doubling up:

 select name=dept
 option-select-/option
 option value=auditaudit/option
 option value=auditaudit/option
 option value=consultingconsulting/option
 option value=consultingconsulting/option
 ...
 /select

mysql_fetch_array() by default returns an array that's associative AND numeric 
(print_r($row) to see what it looks like).

Use mysql_fetch_assoc() instead.

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


/*
There are things that are so serious that you can only joke about them
- Heisenberg
*/


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




Re: [PHP-DB] foreach

2002-06-04 Thread James Kupernik

found my problem .. thank you for your help! You guy put me in the right
direction to solve this problem.

Thanks!!


Jason Wong [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tuesday 04 June 2002 00:52, James Kupernik wrote:
  yes because I'm using it in another foreach, but this one doesn't want
to
  work.
 
 
  Pierre-Alain Joye [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 
   On Mon, 3 Jun 2002 12:48:47 -0400
  
   James Kupernik [EMAIL PROTECTED] wrote:
and I'm getting this:
Warning: Invalid argument supplied for foreach()
   
Why is that?
  
   are you sure $cart is an array ?

 Try:

  print $cart; // would show 'Array' if array

 Are you trying to use this in a function? If so have you declared it
global?

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


 /*
 The first 90% of a project takes 90% of the time, the last 10% takes the
 other 90% of the time.
 */




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




[PHP-DB] foreach

2002-06-03 Thread James Kupernik

I'm using this:

if($save)
{
 foreach ($cart as $record = $qty)
 {
if($$record==0)
 unset($cart[$record]);
else
$cart[$record] = $$record;
 }
 $totalPrice = calculate_price($cart);
 $items = calculate_items($cart);
}



and I'm getting this:
Warning: Invalid argument supplied for foreach()

Why is that?

Any help is greatly appriciated!

Thanks



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




Re: [PHP-DB] foreach

2002-06-03 Thread Pierre-Alain Joye

On Mon, 3 Jun 2002 12:48:47 -0400
James Kupernik [EMAIL PROTECTED] wrote:

 
 and I'm getting this:
 Warning: Invalid argument supplied for foreach()
 
 Why is that?
are you sure $cart is an array ?

pa

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




Re: [PHP-DB] foreach

2002-06-03 Thread James Kupernik

yes because I'm using it in another foreach, but this one doesn't want to
work.


Pierre-Alain Joye [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Mon, 3 Jun 2002 12:48:47 -0400
 James Kupernik [EMAIL PROTECTED] wrote:

 
  and I'm getting this:
  Warning: Invalid argument supplied for foreach()
 
  Why is that?
 are you sure $cart is an array ?

 pa



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




Re: [PHP-DB] foreach

2002-06-03 Thread Jason Wong

On Tuesday 04 June 2002 00:52, James Kupernik wrote:
 yes because I'm using it in another foreach, but this one doesn't want to
 work.


 Pierre-Alain Joye [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

  On Mon, 3 Jun 2002 12:48:47 -0400
 
  James Kupernik [EMAIL PROTECTED] wrote:
   and I'm getting this:
   Warning: Invalid argument supplied for foreach()
  
   Why is that?
 
  are you sure $cart is an array ?

Try:

 print $cart; // would show 'Array' if array

Are you trying to use this in a function? If so have you declared it global?

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


/*
The first 90% of a project takes 90% of the time, the last 10% takes the
other 90% of the time.
*/


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