Re: [PHP] Getting the data for MySQL and then putting it back withPHP - at a loss!

2002-02-22 Thread george Pitcher

Michael,

Been there recently!

You want to use variable variables:

$index=0;
for (index=0; $index  $rowcount; $index++){
$formvar='formvar'.$index;
$formvar=$$formvar;

Do the last two lines for each piece of data you want to handle.

Think about how you are isolating the formvars on the submitted page to
make sure that you are sure you are reading the right stuff.

Hope this helps.

George in Edinburgh



On Fri, 2002-02-22 at 12:24, Michael Romagnoli wrote:
 
 I have a special set of information retrieved from a while loop that I would
 like a person to be able to edit and send back into a MySQL table.
 
 I know all of the basic MySQL commands for doing such, but the PHP side to
 get the input from the form to go in is really stumping me.
 
 This is what I have:
 
 -
 
 $or = 0;
 
 while($or  $orderidrows) {
 
 $orderinfo = mysql_fetch_row($orderidinfo);
 $domain[$or] = $orderinfo[2];
 $cancel[$or] = $orderinfo[3];
 
 print trtdfont size=2 face=Arial $domain[$or]/font/tdtdfont
 size=2 face=ArialCancel This Domain?/font/tdtdfont size=2
 face=Arialinput type=text name=confirm value='$cancel[$or]'
 size=3/font/td;
 
 $or++;
 }
 
 --
 
 The values/data I would normally insert into the MySQL from the form would be
 $confirm, based on $domain - however, in this case, I have a number of rows
 with the same
 name. I've received help as far as distinguishing one row from another -
 thanks.  :)
 
 The problem I am really having is trying to insert the data back into one
 particular table.  You see, when I select the data, I get multiple
 orderid's with multiple domains attached to them.  When I try to UPDATE the
 MySQL with the data, only the last orderid seems to be the one getting
 updated.  And, to boot, I want to update based on the domain name (since
 that is unique) and ignore the orderids.  I only used the orderids to pull
 the data out.
 
 So, I've been using a query like this in a loop;
 
 $update = UPDATE table2 SET cancel='$cancel[$a]' WHERE domain = $domain[$a]
 
 Any suggestions?  I'm getting pretty desparate here!  :\
 
 Thanks,
 
 -Mike
 
 



_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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




Re: [PHP] Getting the data for MySQL and then putting it back withPHP - at a loss!

2002-02-22 Thread Andrey Hristov

Better is:
 $index=0;
 for (index=0; $index  $rowcount; $index++){
 $formvar=${'formvar'.$index};
}
 
- Original Message - 
From: george Pitcher [EMAIL PROTECTED]
To: Michael Romagnoli [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, February 22, 2002 2:40 PM
Subject: Re: [PHP] Getting the data for MySQL and then putting it back withPHP - at a 
loss!


 Michael,
 
 Been there recently!
 
 You want to use variable variables:
 
 $index=0;
 for (index=0; $index  $rowcount; $index++){
 $formvar='formvar'.$index;
 $formvar=$$formvar;
 
 Do the last two lines for each piece of data you want to handle.
 
 Think about how you are isolating the formvars on the submitted page to
 make sure that you are sure you are reading the right stuff.
 
 Hope this helps.
 
 George in Edinburgh
 
 
 
 On Fri, 2002-02-22 at 12:24, Michael Romagnoli wrote:
  
  I have a special set of information retrieved from a while loop that I would
  like a person to be able to edit and send back into a MySQL table.
  
  I know all of the basic MySQL commands for doing such, but the PHP side to
  get the input from the form to go in is really stumping me.
  
  This is what I have:
  
  -
  
  $or = 0;
  
  while($or  $orderidrows) {
  
  $orderinfo = mysql_fetch_row($orderidinfo);
  $domain[$or] = $orderinfo[2];
  $cancel[$or] = $orderinfo[3];
  
  print trtdfont size=2 face=Arial $domain[$or]/font/tdtdfont
  size=2 face=ArialCancel This Domain?/font/tdtdfont size=2
  face=Arialinput type=text name=confirm value='$cancel[$or]'
  size=3/font/td;
  
  $or++;
  }
  
  --
  
  The values/data I would normally insert into the MySQL from the form would be
  $confirm, based on $domain - however, in this case, I have a number of rows
  with the same
  name. I've received help as far as distinguishing one row from another -
  thanks.  :)
  
  The problem I am really having is trying to insert the data back into one
  particular table.  You see, when I select the data, I get multiple
  orderid's with multiple domains attached to them.  When I try to UPDATE the
  MySQL with the data, only the last orderid seems to be the one getting
  updated.  And, to boot, I want to update based on the domain name (since
  that is unique) and ignore the orderids.  I only used the orderids to pull
  the data out.
  
  So, I've been using a query like this in a loop;
  
  $update = UPDATE table2 SET cancel='$cancel[$a]' WHERE domain = $domain[$a]
  
  Any suggestions?  I'm getting pretty desparate here!  :\
  
  Thanks,
  
  -Mike
  
  
 
 
 
 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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




RE: [PHP] Getting the data for MySQL and then putting it back withPHP - at a loss!

2002-02-22 Thread Michael R @ Spy



Yeah, but, where does $rowcount come from, $or?  Are you just renaming the
variable?

Thanks for your help!

-Mike


 -Original Message-
 From: george Pitcher [mailto:[EMAIL PROTECTED]]
 Sent: Friday, February 22, 2002 7:40 AM
 To: Michael Romagnoli
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Getting the data for MySQL and then putting it back
 withPHP - at a loss!


 Michael,

 Been there recently!

 You want to use variable variables:

 $index=0;
 for (index=0; $index  $rowcount; $index++){
 $formvar='formvar'.$index;
 $formvar=$$formvar;

 Do the last two lines for each piece of data you want to handle.

 Think about how you are isolating the formvars on the submitted page to
 make sure that you are sure you are reading the right stuff.

 Hope this helps.

 George in Edinburgh



 On Fri, 2002-02-22 at 12:24, Michael Romagnoli wrote:
 
  I have a special set of information retrieved from a while loop
 that I would
  like a person to be able to edit and send back into a MySQL table.
 
  I know all of the basic MySQL commands for doing such, but the
 PHP side to
  get the input from the form to go in is really stumping me.
 
  This is what I have:
 
  -
 
  $or = 0;
 
  while($or  $orderidrows) {
 
  $orderinfo = mysql_fetch_row($orderidinfo);
  $domain[$or] = $orderinfo[2];
  $cancel[$or] = $orderinfo[3];
 
  print trtdfont size=2 face=Arial
 $domain[$or]/font/tdtdfont
  size=2 face=ArialCancel This Domain?/font/tdtdfont size=2
  face=Arialinput type=text name=confirm value='$cancel[$or]'
  size=3/font/td;
 
  $or++;
  }
 
  --
 
  The values/data I would normally insert into the MySQL from the
 form would be
  $confirm, based on $domain - however, in this case, I have a
 number of rows
  with the same
  name. I've received help as far as distinguishing one row from another -
  thanks.  :)
 
  The problem I am really having is trying to insert the data
 back into one
  particular table.  You see, when I select the data, I get multiple
  orderid's with multiple domains attached to them.  When I try
 to UPDATE the
  MySQL with the data, only the last orderid seems to be the one getting
  updated.  And, to boot, I want to update based on the domain name (since
  that is unique) and ignore the orderids.  I only used the
 orderids to pull
  the data out.
 
  So, I've been using a query like this in a loop;
 
  $update = UPDATE table2 SET cancel='$cancel[$a]' WHERE domain
 = $domain[$a]
 
  Any suggestions?  I'm getting pretty desparate here!  :\
 
  Thanks,
 
  -Mike
 
 



 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com





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




RE: [PHP] Getting the data for MySQL and then putting it back withPHP - at a loss!

2002-02-22 Thread Michael R @ Spy


So, then I have a sql command for updating the data with $formvar?  I would
work $domain into this because $domain is the unique identifier?

Like this:

$index=0;
  for (index=0; $index  $rowcount; $index++){
  $formvar=${'formvar'.$index};
  $sql = UPDATE table2 SET domain = '.$domain[$index].' cancel =
'.$formvar';
 }

?

-Mike




 Better is:
  $index=0;
  for (index=0; $index  $rowcount; $index++){
  $formvar=${'formvar'.$index};
 }

 - Original Message -
 From: george Pitcher [EMAIL PROTECTED]
 To: Michael Romagnoli [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Friday, February 22, 2002 2:40 PM
 Subject: Re: [PHP] Getting the data for MySQL and then putting it
 back withPHP - at a loss!


  Michael,
 
  Been there recently!
 
  You want to use variable variables:
 
  $index=0;
  for (index=0; $index  $rowcount; $index++){
  $formvar='formvar'.$index;
  $formvar=$$formvar;
 
  Do the last two lines for each piece of data you want to handle.
 
  Think about how you are isolating the formvars on the submitted page to
  make sure that you are sure you are reading the right stuff.
 
  Hope this helps.
 
  George in Edinburgh
 
 
 
  On Fri, 2002-02-22 at 12:24, Michael Romagnoli wrote:
  
   I have a special set of information retrieved from a while
 loop that I would
   like a person to be able to edit and send back into a MySQL table.
  
   I know all of the basic MySQL commands for doing such, but
 the PHP side to
   get the input from the form to go in is really stumping me.
  
   This is what I have:
  
   -
  
   $or = 0;
  
   while($or  $orderidrows) {
  
   $orderinfo = mysql_fetch_row($orderidinfo);
   $domain[$or] = $orderinfo[2];
   $cancel[$or] = $orderinfo[3];
  
   print trtdfont size=2 face=Arial
 $domain[$or]/font/tdtdfont
   size=2 face=ArialCancel This Domain?/font/tdtdfont size=2
   face=Arialinput type=text name=confirm value='$cancel[$or]'
   size=3/font/td;
  
   $or++;
   }
  
   --
  
   The values/data I would normally insert into the MySQL from
 the form would be
   $confirm, based on $domain - however, in this case, I have a
 number of rows
   with the same
   name. I've received help as far as distinguishing one row
 from another -
   thanks.  :)
  
   The problem I am really having is trying to insert the data
 back into one
   particular table.  You see, when I select the data, I get multiple
   orderid's with multiple domains attached to them.  When I try
 to UPDATE the
   MySQL with the data, only the last orderid seems to be the one getting
   updated.  And, to boot, I want to update based on the domain
 name (since
   that is unique) and ignore the orderids.  I only used the
 orderids to pull
   the data out.
  
   So, I've been using a query like this in a loop;
  
   $update = UPDATE table2 SET cancel='$cancel[$a]' WHERE
 domain = $domain[$a]
  
   Any suggestions?  I'm getting pretty desparate here!  :\
  
   Thanks,
  
   -Mike
  
  
 
 
 
  _
  Do You Yahoo!?
  Get your free @yahoo.com address at http://mail.yahoo.com
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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





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