RE: [PHP-DB] Selection problem

2003-09-26 Thread Hutchins, Richard
If I understand your problem correctly, it sounds like you need to get all
of the values for the two select objects (which you can do with PHP, of
course) then use JavaScript to handle the CLIENT SIDE update process between
the two objects.

If that sounds like what you're looking for, you can find numerous tutorials
and code samples on the web. Just search for javascript on google and you
should find a number of sites with script repositories. Pick a site and look
to see what they have to satisfy your requirements.

Hope that helps.
Rich

 -Original Message-
 From: Stiphane RIVEZ [mailto:[EMAIL PROTECTED]
 Sent: Friday, September 26, 2003 2:12 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: [PHP-DB] Selection problem
 
 
 Hello,
 
 I'm novice in php and mysql utilization so...
 Here is my problem:
 I have a form with some fields (for example, 2: field1 and field2)
 My mysql database contains for example 1 table (named for 
 example SQLTABLE)
 with 3 fields: ID (auto_increment), AA, BB.
 On my form, field1 is represented in HTML by a SELECT 
 SIZE=1... and
 returns values of  AA in selected in SQLTABLE.
 I want when I choose a value with the selection menu in 
 field1 of the form,
 that the BB corresponding value of the selected AA 
 automatically appears in
 field2 of my form without submitting my page, without loosing 
 informations
 already encoded in the page. (An application could be a 
 customer subsciption
 form, where you have to enter your name, adress, ZIP, town, for a
 determinated country... and you can choose the zip code in a 
 selection menu
 and automatically the corresponding town is shown next to it before
 subitting the form...)
 
 I suppose that a lot of people can help me
 
 Thanks...
 
 Stephane, Belgium
 
 -- 
 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] Selection problem

2003-09-08 Thread Gary . Every
Try unset after the if statement

if ($nameb == ){
 
  $query = SELECT * FROM recipes WHERE points $pointsb;
 
 } else {
 
  $query = SELECT * FROM recipes WHERE name = '$nameb';
$new_nameb = $nameb;
unset($nameb);

}

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


 -Original Message-
 From: Chris Payne [mailto:[EMAIL PROTECTED]
 Sent: Sunday, September 07, 2003 5:43 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Selection problem
 
 
 Hi there everyone,
 
 I'm having a strange problem, I have a form with 2 fields, 1 
 is for points
 (Weightwatcher points) and one is for recipe names.  If you 
 select points
 (IE: 1-3, 3-6,6-9,9 and above) it works perfectly, displays 
 the recipes and
 allows you to select a new points range from the dropdown.
 
 Next to it, on the same form, you can also select by recipe 
 name and ignore
 the points instead selecting by the recipe name - this works 
 fine, you can
 select 1, view it and then select another.
 
 The problem comes when you select a recipe from the dropdown 
 and view it,
 then decide you want to select points instead - the points 
 won't work once
 you have selected a recipe.  Can anyone see anything below 
 that is wrong?  I
 am sure it's the if statement, i'm not sure how to handle it 
 as you can
 select either option to get the result.
 
 Any help would really be appreciated, if I haven't confused 
 you all to death
 :-)
 
 Regards
 
 Chris
 
 ?
 
 if ($nameb == ){
 
  $query = SELECT * FROM recipes WHERE points $pointsb;
 
 } else {
 
  $query = SELECT * FROM recipes WHERE name = '$nameb';
 
 };
 
  $sql_result = mysql_query($query,$connection)
  or die(Couldn't execute query.);
 
  while ($row = mysql_fetch_array($sql_result)) {
  $id = $row[id];
  $name = $row[name];
  $points = $row[points];
  $ingredients = $row[ingredients];
  $instructions = $row[instructions];
 
 };
 
 ?
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


Re: [PHP-DB] Selection problem

2003-09-07 Thread Micah Stevens
Since you didn't include the form, I'm going to have to make a couple of 
assumptions:

$nameb is the recipe field.
$pointsb is the points field. 

You want to use SQL statement 1 if they select points, 2 if they select 
recipies, but those aren't the only possibilities with the form. It sounds to 
me like you're running into an issue when they select BOTH points and 
recipies. So, you will need a 3 way if statement:

if ($nameb ==   $pointsb != ){ // if just points

 $query = SELECT * FROM recipes WHERE points $pointsb;

} elseif ($pointsb ==   $nameb != ) { // if just recipe

 $query = SELECT * FROM recipes WHERE name = '$nameb';

} else { // if both or neither, use the query you choose. 
$query = ??

}

I may be wrong about what you intend here. You may want to add a if statement 
that corresponds to both fields being empty if you don't validate with 
Javascript or something. Sometimes I do it in the PHP anyways since there's 
no guaruntee that the user will have Javascript capabilities. 

-Micah

On Sun September 7 2003 3:43 pm, Chris Payne wrote:
 Hi there everyone,

 I'm having a strange problem, I have a form with 2 fields, 1 is for points
 (Weightwatcher points) and one is for recipe names.  If you select points
 (IE: 1-3, 3-6,6-9,9 and above) it works perfectly, displays the recipes and
 allows you to select a new points range from the dropdown.

 Next to it, on the same form, you can also select by recipe name and ignore
 the points instead selecting by the recipe name - this works fine, you can
 select 1, view it and then select another.

 The problem comes when you select a recipe from the dropdown and view it,
 then decide you want to select points instead - the points won't work once
 you have selected a recipe.  Can anyone see anything below that is wrong? 
 I am sure it's the if statement, i'm not sure how to handle it as you can
 select either option to get the result.

 Any help would really be appreciated, if I haven't confused you all to
 death

 :-)

 Regards

 Chris

 ?

 if ($nameb == ){

  $query = SELECT * FROM recipes WHERE points $pointsb;

 } else {

  $query = SELECT * FROM recipes WHERE name = '$nameb';

 };

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

  while ($row = mysql_fetch_array($sql_result)) {
  $id = $row[id];
  $name = $row[name];
  $points = $row[points];
  $ingredients = $row[ingredients];
  $instructions = $row[instructions];

 };

 ?

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