Re: [PHP] always last

2001-08-24 Thread Chris Hayes

Hi Jeremy,
it's always easier for us if you tab/organize the code a bit so we get the 
overview. like this:


$result = @mysql_query($sql,$connection) or die(Couldn't execute query.);
 while ($row = mysql_fetch_array($result)) 
{
$uid = $row['uid']
$team = $row['team'];
$option_block .= option value=\$uid\$team/option;
}

$display_block = FORM METHOD=\post\ ACTION=\show_makeapick.php\
PstrongTeam:/strong
select name=\uid\
$option_block
/select
INPUT TYPE=\SUBMIT\ NAME=\submit\ 
VALUE=\Select this Team\/P
/form
;


I find the way you use the uid in various ways confusing. 

You use it as the name of the select object, and in the query and it is 
possible that this also is unclear when you use the $uid in the next page. 
Maybe it is the right choice at first but maybe if you print the form again 
in the result page, or for some other reason do a query like the above 
before you read the result, the $uid may be overridden and obviously the 
value is then set to the last team.

Please have a look at that. 
Also, could you please give us an example of the select part in the HTML 
page? just the part between select name=uid and /select.


Sidestep
I don't remember why but in a code page i made recently i named every 
option. No idea if that is proper coding but it's worth a try:

$option_block .= option name=\uid\ value=\$uid\$team/option;

(note that the name is a fixed name uid and is independent from the variable 
uid, and again, i would like you to rename it!)



hope this helps,

Chris








Antwoord naar:  [EMAIL PROTECTED]
Van:Jeremy Morano [EMAIL PROTECTED]
Aan:[EMAIL PROTECTED]
Datum verz. Thu, 23 Aug 2001 11:10:25 -0400
Onderwerp:  [PHP] always last

 Hi,  I need a little bit of help.
 My variable $team in the option block is always set to the last variable that
 is readI would like it to contain the option that the user
 clicks.Please help me!
 
 
 
 My Select works properly
 
 ...
 
 
 $result = @mysql_query($sql,$connection) or die(Couldn't execute query.);
 
 
 while ($row = mysql_fetch_array($result)) {
 $uid = $row['uid']
 $team = $row['team'];
 
 
  $option_block .= option value=\$uid\$team/option;
 }
 
 $display_block = 
 
 FORM METHOD=\post\ ACTION=\show_makeapick.php\
 
 PstrongTeam:/strong
 select name=\uid\
 $option_block
 /select
 
 INPUT TYPE=\SUBMIT\ NAME=\submit\ VALUE=\Select this Team\/P
 /form
 
 ;
 
 ?
 
 HTML
 HEAD
 TITLEUser Management: Modify a User/TITLE
 /HEAD
 BODY
 h1User Management/h1
 h2emModify a User/em/h2
 PSelect a contact from the list below, to modify the user's record./p
 
 ? echo $display_block; ?
 
 pa href=contact_menu3.phpReturn to Main Menu/a/p
 
 /BODY
 /HTML
 
 
 
 -- 
 PHP General 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]
 




--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --


 

-- 
PHP General 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] always last

2001-08-24 Thread Chris Hayes



Van:Andrey Hristov [EMAIL PROTECTED]
Aan:[EMAIL PROTECTED]
Datum verz. Thu, 23 Aug 2001 18:33:53 +0300
Onderwerp:  Re: [PHP] always last

 Use a counter when fetching from the DB
 if you use while the
 $counter=0;
 while(list(...)=mysql_fetch_array($res)){
 $option_block .= 'option '.(($counter==0)? '
 selected':'').''.$option.'/option';
 }

How then would he find the team back?


--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --


 

-- 
PHP General 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] always last

2001-08-23 Thread Jeremy Morano

Hi,  I need a little bit of help.
My variable $team in the option block is always set to the last variable
that is readI would like it to contain the option that the user
clicks.Please help me!



My Select works properly

...


$result = @mysql_query($sql,$connection) or die(Couldn't execute query.);


while ($row = mysql_fetch_array($result)) {
$uid = $row['uid']
$team = $row['team'];


$option_block .= option value=\$uid\$team/option;
}

$display_block = 

FORM METHOD=\post\ ACTION=\show_makeapick.php\

PstrongTeam:/strong
select name=\uid\
$option_block
/select

INPUT TYPE=\SUBMIT\ NAME=\submit\ VALUE=\Select this Team\/P
/form

;

?

HTML
HEAD
TITLEUser Management: Modify a User/TITLE
/HEAD
BODY
h1User Management/h1
h2emModify a User/em/h2
PSelect a contact from the list below, to modify the user's record./p

? echo $display_block; ?

pa href=contact_menu3.phpReturn to Main Menu/a/p

/BODY
/HTML



-- 
PHP General 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] always last

2001-08-23 Thread Dave Freeman

On 23 Aug 01, at 11:10, Jeremy Morano wrote:

 $result = @mysql_query($sql,$connection) or die(Couldn't execute query.);
 
 
 while ($row = mysql_fetch_array($result)) {
 $uid = $row['uid']
 $team = $row['team'];

if ($uid == $row['uid'])
{

$option_block .= option value=\$uid\ selected$team/option;

} else {

   $option_block .= option value=\$uid\$team/option;

}

   $option_block .= option value=\$uid\$team/option;
 }

[etc]

Basically, you need to see if the value they selected is the one you're 
currently working with and add the 'selected' attribute to your option 
tag.  If it's not then just keep on going through.

CYA, Dave


---
Outback Queensland Internet - Longreach, Outback Queensland - Australia
http://www.outbackqld.net.au  mailto:[EMAIL PROTECTED]
---

-- 
PHP General 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]