RE: RE: [PHP-DB] question on select

2004-05-13 Thread hengameh
; 
} 
} 
? 
/select 
/td 
/tr


tr 
td id=leftSelect your City: 
/td 

td id=right 
select name=ctSelect 
option value=please, select your city/option 
 
?php 
// City Select Box Populated with Values from 'city' table. 

// If and ELSE IF are if you have citys inside countrys (no states) Just
Delete it if its not needed. 
if ($dSel) { 
 // This is the SQL you should keep if you're gonna delete the IF, ELSE
IF. 
$city_sql = SELECT city,cityid, did FROM city WHERE did=$dSel ORDER BY
city; 
} 
//else if ($cSel  ($ctNoState == none)) { 
//$city_sql = SELECT city,cityid, did FROM city WHERE countryid=$cSel
ORDER BY city_name; 
//} 
if ($city_sql != ) { 
$city_qu = mysql_query($city_sql); 
while ($city_array = mysql_fetch_array($city_qu)) { 
$ctNa = $city_array[city]; 
$ctId = $city_array[cityid]; 
echo option value=$ctId$ctNa/option; 
} 
} 
? 
/select 
/td 
/tr 
tr 
td id=left/td 
td id=right/td 
/tr 
/table 
/form 
/body 
/html

-Original Message-
From: Neil Smith [MVP, Digital media] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 13, 2004 4:16 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re:RE: [PHP-DB] question on select

That *should* read :

document.fcountry.newcountry.value = 
document.fcountry.country[document.fcountry.country.selectedIndex].value;

Skip the 'options' object - I'm surprised you're not getting a javascript 
error, maybe you have error reporting turned off in your browser ? In any 
case, always 'alert' that value when you create it, so you know what you're 
actually submitting during testing.

At 04:06 13/05/2004 +, you wrote:
From: hengameh [EMAIL PROTECTED]
To: [EMAIL PROTECTED],
 [EMAIL PROTECTED]
Date: Wed, 12 May 2004 12:22:20 -0400
MIME-Version: 1.0
Content-Type: text/plain;
 charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] question on select

!--
function changeMenu()
   {
   document.fcountry.newcountry.value =
document.fcountry.country.options[document.fcountry.country.selectedIndex].
v
alue;
  }
--
/script



CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.

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



[PHP-DB] Re:RE: [PHP-DB] question on select

2004-05-13 Thread Neil Smith [MVP, Digital media]
That *should* read :

document.fcountry.newcountry.value = 
document.fcountry.country[document.fcountry.country.selectedIndex].value;

Skip the 'options' object - I'm surprised you're not getting a javascript 
error, maybe you have error reporting turned off in your browser ? In any 
case, always 'alert' that value when you create it, so you know what you're 
actually submitting during testing.

At 04:06 13/05/2004 +, you wrote:
From: hengameh [EMAIL PROTECTED]
To: [EMAIL PROTECTED],
[EMAIL PROTECTED]
Date: Wed, 12 May 2004 12:22:20 -0400
MIME-Version: 1.0
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] question on select
!--
function changeMenu()
  {
  document.fcountry.newcountry.value =
document.fcountry.country.options[document.fcountry.country.selectedIndex].v
alue;
 }
--
/script



CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.
VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] question on select

2004-05-13 Thread Michael Forbes
Interesting idea.  Since I'm convinced that javascript is the bastard 
offspring of Bill Gates, Larry Ellison, and Baalzebub, can I sue too? :)

Hengameh wrote:

Well I am suing Java script to capture the selected item and make it the
value of my input box. But my problem is how to access this information from
this point on. Can someone please tell me how I can use the selected item in
my next SQL query?
-Original Message-
From: Tony S. Wu [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 11:07 AM
To: hengameh
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] question on select

sounds like a job for JavaScript.

Tony S. Wu
[EMAIL PROTECTED]
Look into the right places, you can find some good offerings.
http://homepage.mac.com/tonyswu/stw- The perfect business.
http://homepage.mac.com/tonyswu/tonyswu- My web page.
 
---



On May 12, 2004, at 7:02 AM, hengameh wrote:


Hello,

I am very new to php and mysql so please be patient with me. I don't  
even
know if I am using the right listing, but I hope someone can help me!



I need to create a select and the possible options are from my mysql
database ( so far so good, I was able to find code to do that).
Now I need to use the user selected option to drive the options of me  
next
select.  I need to know how to capture what user selected and how to  
pass
that around? I have used onchange attribute of the select to  
capture the
selected line but now how can I pass that to other php scripts?  ( I  
need to
get the name of the country so that I can show a list of possible
state/province. I setting the value of the newcountry input to the
selected country but when I do echo $newcountry in quicksearch.php,  
its
blank!!)

Please help!!



Thanks so much



Here is what I have so far:



Quicksearch.php file has the following code

br

table class='form'

 tr

   thSteps 1-4/th

 /tr



 trtd

   form name=fcountry method=post

 ?php  require(country_build.php);?

 input type=text name=newcountry value=



 /form



/td/tr

/table

!-- quicksearch.php   end --



script language=JavaScript

!--

function changeMenu()

 {

 document.fcountry.newcountry.value =
document.fcountry.country.options[document.fcountry.country.selectedInd 
ex].v
alue;

}

--

/script



Countrty_buil.php has the following



?php

require_once(util.php);



echo SELECT name=\country\ class=\input\   
onchange=\changeMenu()\;

//

// initialize or capture the country variable

$country = !isset($_REQUEST['country'])? Select a country:
$_REQUEST['country'];
$countrySQL = !isset($_REQUEST['country'])? *: $_REQUEST['country'];

echo option value='$countrySQL' SELECTED$country/option;

$query = SELECT country FROM . TABLECOUNTRY .  ORDER BY country  
ASC;

// pconnect, select and query

if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME,  
DBPASSWORD))
{

 if ( mysql_select_db(DBNAME, $link_identifier)) {

   // run the query

$queryResultHandle = mysql_query($query, $link_identifier) or  
die(
mysql_error() );

$ctrRows = mysql_num_rows($queryResultHandle); // row counter

   // if data exists then $rows will be 1 or greater

   if( $ctrRows == 0 ) {

 echooption value='*'No data  
found/option/select;

   }else{

 // build the select list

 while($row = mysql_fetch_object($queryResultHandle))  
{ //
grab a row

   echo option
value=\$row-country\$row-country/option;
 }

 echo /SELECTbrbr;



   }

 }else{ // select

   echo mysql_error();

 }

}else{ //pconnect

 echo mysql_error();

}

?









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


[PHP-DB] question on select

2004-05-12 Thread hengameh
 

Hello,

I am very new to php and mysql so please be patient with me. I don't even
know if I am using the right listing, but I hope someone can help me!

 

I need to create a select and the possible options are from my mysql
database ( so far so good, I was able to find code to do that).

Now I need to use the user selected option to drive the options of me next
select.  I need to know how to capture what user selected and how to pass
that around? I have used onchange attribute of the select to capture the
selected line but now how can I pass that to other php scripts?  ( I need to
get the name of the country so that I can show a list of possible
state/province. I setting the value of the newcountry input to the
selected country but when I do echo $newcountry in quicksearch.php, its
blank!!) 

Please help!!

 

Thanks so much

 

Here is what I have so far:

 

Quicksearch.php file has the following code

br

table class='form'

  tr

thSteps 1-4/th

  /tr

 

  trtd

form name=fcountry method=post

  ?php  require(country_build.php);?

  input type=text name=newcountry value=

  

  /form

 

/td/tr

/table

!-- quicksearch.php   end --

 

script language=JavaScript

!--

function changeMenu()

  {

  document.fcountry.newcountry.value =
document.fcountry.country.options[document.fcountry.country.selectedIndex].v
alue;

 } 

-- 

/script

 

Countrty_buil.php has the following

 

?php

require_once(util.php);

 

echo SELECT name=\country\ class=\input\  onchange=\changeMenu()\;

//

// initialize or capture the country variable

$country = !isset($_REQUEST['country'])? Select a country:
$_REQUEST['country'];

$countrySQL = !isset($_REQUEST['country'])? *: $_REQUEST['country'];

echo option value='$countrySQL' SELECTED$country/option;

$query = SELECT country FROM . TABLECOUNTRY .  ORDER BY country ASC;

// pconnect, select and query

if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME, DBPASSWORD))
{

  if ( mysql_select_db(DBNAME, $link_identifier)) {

// run the query

 $queryResultHandle = mysql_query($query, $link_identifier) or die(
mysql_error() );

 $ctrRows = mysql_num_rows($queryResultHandle); // row counter

// if data exists then $rows will be 1 or greater

if( $ctrRows == 0 ) {

  echooption value='*'No data found/option/select;

}else{

  // build the select list

  while($row = mysql_fetch_object($queryResultHandle)) { //
grab a row

echo option
value=\$row-country\$row-country/option;

  }

  echo /SELECTbrbr;



}

  }else{ // select

echo mysql_error();

  }

}else{ //pconnect

  echo mysql_error();

}

?

 

 

 

 



Re: [PHP-DB] question on select

2004-05-12 Thread Tony S . Wu
sounds like a job for JavaScript.

Tony S. Wu
[EMAIL PROTECTED]
Look into the right places, you can find some good offerings.
http://homepage.mac.com/tonyswu/stw- The perfect business.
http://homepage.mac.com/tonyswu/tonyswu- My web page.
 
---



On May 12, 2004, at 7:02 AM, hengameh wrote:



Hello,

I am very new to php and mysql so please be patient with me. I don't  
even
know if I am using the right listing, but I hope someone can help me!



I need to create a select and the possible options are from my mysql
database ( so far so good, I was able to find code to do that).
Now I need to use the user selected option to drive the options of me  
next
select.  I need to know how to capture what user selected and how to  
pass
that around? I have used onchange attribute of the select to  
capture the
selected line but now how can I pass that to other php scripts?  ( I  
need to
get the name of the country so that I can show a list of possible
state/province. I setting the value of the newcountry input to the
selected country but when I do echo $newcountry in quicksearch.php,  
its
blank!!)

Please help!!



Thanks so much



Here is what I have so far:



Quicksearch.php file has the following code

br

table class='form'

  tr

thSteps 1-4/th

  /tr



  trtd

form name=fcountry method=post

  ?php  require(country_build.php);?

  input type=text name=newcountry value=



  /form



/td/tr

/table

!-- quicksearch.php   end --



script language=JavaScript

!--

function changeMenu()

  {

  document.fcountry.newcountry.value =
document.fcountry.country.options[document.fcountry.country.selectedInd 
ex].v
alue;

 }

--

/script



Countrty_buil.php has the following



?php

require_once(util.php);



echo SELECT name=\country\ class=\input\   
onchange=\changeMenu()\;

//

// initialize or capture the country variable

$country = !isset($_REQUEST['country'])? Select a country:
$_REQUEST['country'];
$countrySQL = !isset($_REQUEST['country'])? *: $_REQUEST['country'];

echo option value='$countrySQL' SELECTED$country/option;

$query = SELECT country FROM . TABLECOUNTRY .  ORDER BY country  
ASC;

// pconnect, select and query

if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME,  
DBPASSWORD))
{

  if ( mysql_select_db(DBNAME, $link_identifier)) {

// run the query

 $queryResultHandle = mysql_query($query, $link_identifier) or  
die(
mysql_error() );

 $ctrRows = mysql_num_rows($queryResultHandle); // row counter

// if data exists then $rows will be 1 or greater

if( $ctrRows == 0 ) {

  echooption value='*'No data  
found/option/select;

}else{

  // build the select list

  while($row = mysql_fetch_object($queryResultHandle))  
{ //
grab a row

echo option
value=\$row-country\$row-country/option;
  }

  echo /SELECTbrbr;



}

  }else{ // select

echo mysql_error();

  }

}else{ //pconnect

  echo mysql_error();

}

?











RE: [PHP-DB] question on select

2004-05-12 Thread hengameh
Well I am suing Java script to capture the selected item and make it the
value of my input box. But my problem is how to access this information from
this point on. Can someone please tell me how I can use the selected item in
my next SQL query?

-Original Message-
From: Tony S. Wu [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 11:07 AM
To: hengameh
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] question on select

sounds like a job for JavaScript.

Tony S. Wu
[EMAIL PROTECTED]

Look into the right places, you can find some good offerings.
http://homepage.mac.com/tonyswu/stw- The perfect business.
http://homepage.mac.com/tonyswu/tonyswu- My web page.
 
---



On May 12, 2004, at 7:02 AM, hengameh wrote:



 Hello,

 I am very new to php and mysql so please be patient with me. I don't  
 even
 know if I am using the right listing, but I hope someone can help me!



 I need to create a select and the possible options are from my mysql
 database ( so far so good, I was able to find code to do that).

 Now I need to use the user selected option to drive the options of me  
 next
 select.  I need to know how to capture what user selected and how to  
 pass
 that around? I have used onchange attribute of the select to  
 capture the
 selected line but now how can I pass that to other php scripts?  ( I  
 need to
 get the name of the country so that I can show a list of possible
 state/province. I setting the value of the newcountry input to the
 selected country but when I do echo $newcountry in quicksearch.php,  
 its
 blank!!)

 Please help!!



 Thanks so much



 Here is what I have so far:



 Quicksearch.php file has the following code

 br

 table class='form'

   tr

 thSteps 1-4/th

   /tr



   trtd

 form name=fcountry method=post

   ?php  require(country_build.php);?

   input type=text name=newcountry value=



   /form



 /td/tr

 /table

 !-- quicksearch.php   end --



 script language=JavaScript

 !--

 function changeMenu()

   {

   document.fcountry.newcountry.value =
 document.fcountry.country.options[document.fcountry.country.selectedInd 
 ex].v
 alue;

  }

 --

 /script



 Countrty_buil.php has the following



 ?php

 require_once(util.php);



 echo SELECT name=\country\ class=\input\   
 onchange=\changeMenu()\;

 //

 // initialize or capture the country variable

 $country = !isset($_REQUEST['country'])? Select a country:
 $_REQUEST['country'];

 $countrySQL = !isset($_REQUEST['country'])? *: $_REQUEST['country'];

 echo option value='$countrySQL' SELECTED$country/option;

 $query = SELECT country FROM . TABLECOUNTRY .  ORDER BY country  
 ASC;

 // pconnect, select and query

 if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME,  
 DBPASSWORD))
 {

   if ( mysql_select_db(DBNAME, $link_identifier)) {

 // run the query

  $queryResultHandle = mysql_query($query, $link_identifier) or  
 die(
 mysql_error() );

  $ctrRows = mysql_num_rows($queryResultHandle); // row counter

 // if data exists then $rows will be 1 or greater

 if( $ctrRows == 0 ) {

   echooption value='*'No data  
 found/option/select;

 }else{

   // build the select list

   while($row = mysql_fetch_object($queryResultHandle))  
 { //
 grab a row

 echo option
 value=\$row-country\$row-country/option;

   }

   echo /SELECTbrbr;



 }

   }else{ // select

 echo mysql_error();

   }

 }else{ //pconnect

   echo mysql_error();

 }

 ?










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



RE: [PHP-DB] question on select

2004-05-12 Thread Hutchins, Richard
You'd have to take the value of the first select box in your form and pass
it to another script. You can do that by setting the form's ACTION property
to either GET or POST. Personally, I prefer POST.

In the script to which you submit your form, you can access the value of the
select object thusly: $_POST[varname] and insert it into your query
however you want (using the appropriate input sanitization methods).

The important concept to understand here is that you cannot use PHP to drive
the contents of your second select object without a round-trip to the
server. Since PHP is a server-side technology, it HAS to work that way.

To make a client-side solution possible, you'd have to send ALL POSSIBLE
data to the page all at the same time then manipulate it with JavaScript.

You can make it LOOK like a dynamic solution by repeatedly resubmitting the
page to itself and using a combo platter of JS and PHP functions on the page
to handle data as it is progressively requested/sent, but you're still doing
a round-trip each time. It only looks like a client-side solution because
you submit to the same page all the time until certain conditions are
satisfied or your user clicks on a specific link or button.

If you're truly in search of a completely client-side solution using
JavaScript, I suggest checking the Javascript Boutique or Javascript Source
or any one of the hundreds of JS repositories you'll find in a google
search. There are many great examples of this problem such as selecting a
State in one select box then having the major cities in that State show up
in a second select object.

Hope this helped.

Rich



 -Original Message-
 From: hengameh [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, May 12, 2004 11:34 AM
 To: 'Tony S. Wu'
 Cc: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] question on select
 
 
 Well I am suing Java script to capture the selected item and 
 make it the
 value of my input box. But my problem is how to access this 
 information from
 this point on. Can someone please tell me how I can use the 
 selected item in
 my next SQL query?
 
 -Original Message-
 From: Tony S. Wu [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, May 12, 2004 11:07 AM
 To: hengameh
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] question on select
 
 sounds like a job for JavaScript.
 
 Tony S. Wu
 [EMAIL PROTECTED]
 
 Look into the right places, you can find some good offerings.
 http://homepage.mac.com/tonyswu/stw- The perfect business.
 http://homepage.mac.com/tonyswu/tonyswu- My web page.
 --
 -- 
 ---
 
 
 
 On May 12, 2004, at 7:02 AM, hengameh wrote:
 
 
 
  Hello,
 
  I am very new to php and mysql so please be patient with 
 me. I don't  
  even
  know if I am using the right listing, but I hope someone 
 can help me!
 
 
 
  I need to create a select and the possible options are 
 from my mysql
  database ( so far so good, I was able to find code to do that).
 
  Now I need to use the user selected option to drive the 
 options of me  
  next
  select.  I need to know how to capture what user selected 
 and how to  
  pass
  that around? I have used onchange attribute of the select to  
  capture the
  selected line but now how can I pass that to other php 
 scripts?  ( I  
  need to
  get the name of the country so that I can show a list of possible
  state/province. I setting the value of the newcountry input to the
  selected country but when I do echo $newcountry in 
 quicksearch.php,  
  its
  blank!!)
 
  Please help!!
 
 
 
  Thanks so much
 
 
 
  Here is what I have so far:
 
 
 
  Quicksearch.php file has the following code
 
  br
 
  table class='form'
 
tr
 
  thSteps 1-4/th
 
/tr
 
 
 
trtd
 
  form name=fcountry method=post
 
?php  require(country_build.php);?
 
input type=text name=newcountry value=
 
 
 
/form
 
 
 
  /td/tr
 
  /table
 
  !-- quicksearch.php   end --
 
 
 
  script language=JavaScript
 
  !--
 
  function changeMenu()
 
{
 
document.fcountry.newcountry.value =
  
 document.fcountry.country.options[document.fcountry.country.se
 lectedInd 
  ex].v
  alue;
 
   }
 
  --
 
  /script
 
 
 
  Countrty_buil.php has the following
 
 
 
  ?php
 
  require_once(util.php);
 
 
 
  echo SELECT name=\country\ class=\input\   
  onchange=\changeMenu()\;
 
  //
 
  // initialize or capture the country variable
 
  $country = !isset($_REQUEST['country'])? Select a country:
  $_REQUEST['country'];
 
  $countrySQL = !isset($_REQUEST['country'])? *: 
 $_REQUEST['country'];
 
  echo option value='$countrySQL' SELECTED$country/option;
 
  $query = SELECT country FROM . TABLECOUNTRY .  ORDER BY country  
  ASC;
 
  // pconnect, select and query
 
  if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME,  
  DBPASSWORD))
  {
 
if ( mysql_select_db(DBNAME, $link_identifier

RE: [PHP-DB] question on select

2004-05-12 Thread hengameh
Thanks so much but I am so new to all this so need more explanation please.
I think at this point I don't mind the round trip to the server side till I
find a better way. But for now I think I have what you are suggesting but
then why my echo is not retuning anything :
form name=fcountry method=post action=$PHP_SELF
?php  require(country_build.php);?
input type=text name=newcountry value=
?php echo $_POST['newcountry'];?
/form
(country_build.php creates the select and its options)


-Original Message-
From: Hutchins, Richard [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 11:45 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] question on select

You'd have to take the value of the first select box in your form and pass
it to another script. You can do that by setting the form's ACTION property
to either GET or POST. Personally, I prefer POST.

In the script to which you submit your form, you can access the value of the
select object thusly: $_POST[varname] and insert it into your query
however you want (using the appropriate input sanitization methods).

The important concept to understand here is that you cannot use PHP to drive
the contents of your second select object without a round-trip to the
server. Since PHP is a server-side technology, it HAS to work that way.

To make a client-side solution possible, you'd have to send ALL POSSIBLE
data to the page all at the same time then manipulate it with JavaScript.

You can make it LOOK like a dynamic solution by repeatedly resubmitting the
page to itself and using a combo platter of JS and PHP functions on the page
to handle data as it is progressively requested/sent, but you're still doing
a round-trip each time. It only looks like a client-side solution because
you submit to the same page all the time until certain conditions are
satisfied or your user clicks on a specific link or button.

If you're truly in search of a completely client-side solution using
JavaScript, I suggest checking the Javascript Boutique or Javascript Source
or any one of the hundreds of JS repositories you'll find in a google
search. There are many great examples of this problem such as selecting a
State in one select box then having the major cities in that State show up
in a second select object.

Hope this helped.

Rich



 -Original Message-
 From: hengameh [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, May 12, 2004 11:34 AM
 To: 'Tony S. Wu'
 Cc: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] question on select
 
 
 Well I am suing Java script to capture the selected item and 
 make it the
 value of my input box. But my problem is how to access this 
 information from
 this point on. Can someone please tell me how I can use the 
 selected item in
 my next SQL query?
 
 -Original Message-
 From: Tony S. Wu [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, May 12, 2004 11:07 AM
 To: hengameh
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] question on select
 
 sounds like a job for JavaScript.
 
 Tony S. Wu
 [EMAIL PROTECTED]
 
 Look into the right places, you can find some good offerings.
 http://homepage.mac.com/tonyswu/stw- The perfect business.
 http://homepage.mac.com/tonyswu/tonyswu- My web page.
 --
 -- 
 ---
 
 
 
 On May 12, 2004, at 7:02 AM, hengameh wrote:
 
 
 
  Hello,
 
  I am very new to php and mysql so please be patient with 
 me. I don't  
  even
  know if I am using the right listing, but I hope someone 
 can help me!
 
 
 
  I need to create a select and the possible options are 
 from my mysql
  database ( so far so good, I was able to find code to do that).
 
  Now I need to use the user selected option to drive the 
 options of me  
  next
  select.  I need to know how to capture what user selected 
 and how to  
  pass
  that around? I have used onchange attribute of the select to  
  capture the
  selected line but now how can I pass that to other php 
 scripts?  ( I  
  need to
  get the name of the country so that I can show a list of possible
  state/province. I setting the value of the newcountry input to the
  selected country but when I do echo $newcountry in 
 quicksearch.php,  
  its
  blank!!)
 
  Please help!!
 
 
 
  Thanks so much
 
 
 
  Here is what I have so far:
 
 
 
  Quicksearch.php file has the following code
 
  br
 
  table class='form'
 
tr
 
  thSteps 1-4/th
 
/tr
 
 
 
trtd
 
  form name=fcountry method=post
 
?php  require(country_build.php);?
 
input type=text name=newcountry value=
 
 
 
/form
 
 
 
  /td/tr
 
  /table
 
  !-- quicksearch.php   end --
 
 
 
  script language=JavaScript
 
  !--
 
  function changeMenu()
 
{
 
document.fcountry.newcountry.value =
  
 document.fcountry.country.options[document.fcountry.country.se
 lectedInd 
  ex].v

RE: [PHP-DB] question on select

2004-05-12 Thread dpgirago
 Thanks so much but I am so new to all this so need more explanation 
please.
 I think at this point I don't mind the round trip to the server side 
till I
 find a better way. But for now I think I have what you are suggesting 
but
 then why my echo is not retuning anything :
 form name=fcountry method=post action=$PHP_SELF
?php 
require(country_build.php);?
input type=text 
name=newcountry value=
?php echo 
$_POST['newcountry'];?
/form


Well, there is no value assgined to $_POST['newcountry'] in your example. 
How are you getting a value to that form field?

dave

RE: [PHP-DB] question on select

2004-05-12 Thread hengameh
Sorry that. I was trying to be modular! I also understand that everyone is
busy and I highly appreciate any help.
Anyway I cleaned it up a bit I hope its clear now ( all I am trying to do is
to show a list of countries from my database and then according to the
selected country make another select for the state/province and then pass
all that for further search):


script language=JavaScript
!--
function changeMenu(pulldown,input)
  {
input.value = pulldown.options[pulldown.selectedIndex].value;
 } 
-- 
/script

?php require_once(util.php);?

br
table class='form'
trthSteps 1-4/th/tr
trtd
form name=fcountry method=post action=$PHP_SELF
?php  getcountry();?
input type=text name=newcountry value=
?php echo $_POST['newcountry'];?
  /form
  /td/tr
/table
!-- quicksearch.php   end --

?php
function getcountry()
{
$sretval = SELECT name=\country\ class=\input\
onchange=\changeMenu(document.fcountry.country,document.fcountry.newcountry
)\;
//
// initialize or capture the country variable
$country = !isset($_REQUEST['country'])? Select a country:
$_REQUEST['country'];
$countrySQL = !isset($_REQUEST['country'])? *: $_REQUEST['country'];
$sretval .= option value='$countrySQL' SELECTED$country/option;
$query = SELECT * FROM . TABLECOUNTRY .  ORDER BY country ASC;
// pconnect, select and query
if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME, DBPASSWORD))
{
if ( mysql_select_db(DBNAME, $link_identifier)) {
// run the query
   $queryResultHandle = mysql_query($query, $link_identifier) or
die( mysql_error() );
   $ctrRows = mysql_num_rows($queryResultHandle); // row counter
// if data exists then $rows will be 1 or greater
if( $ctrRows == 0 ) {
$sretval .=option value='*'No data
found/option/select;
}else{
// build the select list
while($row = mysql_fetch_object($queryResultHandle))
{ // grab a row
$sretval .=option
value=\$row-country\$row-country/option;
}
$sretval .= /SELECTbrbr;
echo $sretval;  
}
}else{ // select
echo mysql_error();
}
}else{ //pconnect
echo mysql_error();
}
}
?


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 12:41 PM
To: hengameh; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] question on select

 Here is the complete code. In the one line Java script that I have I am
 setting the value. So what am I missing?

For the sake of the listers trying to help you, and for your own clarity 
of concept, I'd suggest starting out by putting all your code into one 
file. It's quite hard to follow as you've presented it. 

Also, it may make it easier if you try concatenating all your output to 
one $variable, then print/echoing it out.

Don't mean to be difficult, but we all have our own projects to work on. 

dave 

-- 
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]Question on select..for update

2001-02-12 Thread Richard Halford

Hi, just started on the list, and the didn't seem to get through the first
time, so I'll give it another whirl.

I'm trying the following code based on a modded db_oci8.inc (the mod is so
that the call to OCIExecute always passes OCI_DEFAULT rater than
OCI_COMMIT_ON_SUCCESS.

This is a snippet of the relevant code:

The variable $PartNumber contains the part number to query on:

  $db-Query("select part_nbr "
 ." from psns "
 ." where part_nbr = '".$PartNumber."' "
 ." for update ");
  $db-next_record();
?SCRIPTalert ("Waiting with record lock")/SCRIPT?
   $db-Query("lock table psns in exclusive mode");
?SCRIPTalert ("Waiting with table lock")/SCRIPT?
  $db-Query("update psns set user_id = '' where part_nbr =
'".$PartNumber."' ");
  $db-Query("commit");

The problem is that between the firt select query and lock table there
should be a record lock on the requested record. Now opening up a SQLPlus
session I can perform an update on that record. If, from SQLPlus, I try and
lock the table or do a select for update, then this the locking works fine
and there is no problem, so I know it is not an oracle related problem
becuase of this.

I've tried this also with the OCI8 libraries and the same problem occurs.
What I don't understand is why this should occur, after all its just passing
SQL queries through and not doing anything else flash.

Between the table lock and the update the lock should also be placed at
table level, yet there is still no lock applied.


The results in debug mode are :

Obtained the Link_ID: Resource id #3
Debug: commit mode = 0 COMMIT On success = 32 Default = 0 (this is just to
check that the mode is OCI_DEFAULT)
Debug: query = select part_nbr from psns where part_nbr = 'XX' for
update
[PART_NBR]:XX
Debug: commit mode = 0 COMMIT On success = 32 Default = 0
Debug: query = lock table psns in exclusive mode
returned Debug: commit mode = 32 COMMIT On success = 32 Default = 0 (this is
just to check that the mode is OCI_DEFAULT)
Debug: query = update psns set user_id = '' where part_nbr = 'XX'

Regards,
  Richard Halford


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