RE: [PHP] select function

2012-10-25 Thread Ford, Mike
> -Original Message-
> From: Stuart Dallas [mailto:stu...@3ft9.com]
> Sent: 25 October 2012 22:48

Aw, nuts! Stuart, you just beat me to it! I was half way through writing an 
almost identical post when yours popped into my Inbox

Cheers!

Mike

-- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS,  LS1 3HE,  United Kingdom 
E: m.f...@leedsmet.ac.uk T: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] select function

2012-10-25 Thread Stuart Dallas
On 25 Oct 2012, at 22:35, "Jeff Burcher"  wrote:
> I can't remember if this is the PHP list for RPG programmers or not, so
> apologize if this is the wrong one.

Not an RPG list, but your question is PHP-related more than it's RPG-related.

> Is there an equivalent command in PHP for the SELECT statement in RPG? I see
> switch, which is a little similar, but far from how it actually functions.
> 
> For those not familiar with the SELECT statement here is how I envision it
> working in a PHP format similar to switch:
> 
> SELECT {
> WHEN $Auth = 0:
>   WHEN $A = 1:
> echo('$Aprint_list');
>   WHEN $B = 1:
> echo('$Bprint_list');
>   WHEN $A = 2:
> echo('$Aprint_list');
>   echo('$Aprint_list');
> WHEN $B = 2:
>   echo('$Bprint_list');
> echo('$Bprint_list');
>   DEFAULT:
> }
> 
> The syntax may be a little off, but you get the picture. No breaks are
> needed because it only performs the first match it comes to, then exits the
> SELECT statement when finished the commands under that match. Putting a WHEN
> statement with nothing to perform means exactly that, if this matches, do
> nothing, then exit the SELECT statement. I hope that makes sense. The big
> difference is you can put anything behind each WHEN statement as opposed to
> looking at only the one variable like with switch. I am thinking I just need
> to get creative with the switch or elseif commands, but thought I would ask
> the list first if they had any better suggestions.

You don't need to "get creative" with anything as that's exactly how switch 
works if you have a break at the end of each case. So your example would look 
like so:

switch (true) {
  case $Auth == 0:
break;
  case $A == 1:
echo('$Aprint_list');
break;
  case $B == 1:
echo('$Bprint_list');
break;
  case $A == 2:
echo('$Aprint_list');
echo('$Aprint_list');
break;
  case $B == 2:
echo('$Bprint_list');
echo('$Bprint_list');
break;
  default:
break;
}

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] select function

2012-10-25 Thread Daniel Brown
On Thu, Oct 25, 2012 at 5:35 PM, Jeff Burcher  wrote:
> Hi,
>
>
>
> I can't remember if this is the PHP list for RPG programmers or not, so
> apologize if this is the wrong one.

This is just a general PHP mailing list.  Guessing you need the other one.

-- 

Network Infrastructure Manager
http://www.php.net/

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



RE: [PHP] SELECT AVG(rating)

2010-07-02 Thread Ben Miller


-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Friday, July 02, 2010 2:43 PM
To: b...@tottd.com
Cc: php-general@lists.php.net
Subject: Re: [PHP] SELECT AVG(rating)

On Fri, 2010-07-02 at 14:32 -0600, Ben Miller wrote:

> Hi - I have a MySQL table full of product reviews and I'm trying to select
> info for only the top 5 rated products.  The only way I can figure out how
> to do it so far is something like:
> 
> $query1 = mysql_query("SELECT * FROM products");
> for($i=1;$i<=mysql_num_rows($query1);$i++) {
>   $row1 = mysql_fetch_array($query1,MYSQL_ASSOC);
>   $query2 = mysql_query("SELECT AVG(rating) as rating FROM reviews
> WHERE product_id='" . $row1['product_id'] . "'");
>   ...
>   $product[$i]['name'] = $row1['product_name'];
>   $product[$i]['rating'] = $row2['rating'];
> }
> 
> And then use array functions to sort and display only the first 5.
> 
> Is there any easier way to get this done with a single query - something
> like "SELECT AVG(rating) WHERE product_id=DISTINCT(product_id)"? <<= I
tried
> that - it didn't work.  Would greatly appreciate any advice.  Thanks,
> 
> Ben 
> 
> 
> 


How about something like this (untested)

SELECT products.product_id, AVG(reviews.rating) AS rating
FROM products
LEFT JOIN reviews ON (reviews.product_id = products.product_id)
GROUP BY products.product_id
ORDER BY rating
LIMIT 1,5

I'm unsure about that order and limit there, so you might have to wrap
that inside of a temporary table query and take your 5 out of that. A
join is the right way to go with this though I reckon.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Adding a DESC after ORDER BY rating did it perfectly.  I had tried a few
JOIN queries, but was building them incorrectly.  Thank you so much for your
help.

Ben



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



Re: [PHP] SELECT AVG(rating)

2010-07-02 Thread Ashley Sheridan
On Fri, 2010-07-02 at 14:32 -0600, Ben Miller wrote:

> Hi - I have a MySQL table full of product reviews and I'm trying to select
> info for only the top 5 rated products.  The only way I can figure out how
> to do it so far is something like:
> 
> $query1 = mysql_query("SELECT * FROM products");
> for($i=1;$i<=mysql_num_rows($query1);$i++) {
>   $row1 = mysql_fetch_array($query1,MYSQL_ASSOC);
>   $query2 = mysql_query("SELECT AVG(rating) as rating FROM reviews
> WHERE product_id='" . $row1['product_id'] . "'");
>   ...
>   $product[$i]['name'] = $row1['product_name'];
>   $product[$i]['rating'] = $row2['rating'];
> }
> 
> And then use array functions to sort and display only the first 5.
> 
> Is there any easier way to get this done with a single query - something
> like "SELECT AVG(rating) WHERE product_id=DISTINCT(product_id)"? <<= I tried
> that - it didn't work.  Would greatly appreciate any advice.  Thanks,
> 
> Ben 
> 
> 
> 


How about something like this (untested)

SELECT products.product_id, AVG(reviews.rating) AS rating
FROM products
LEFT JOIN reviews ON (reviews.product_id = products.product_id)
GROUP BY products.product_id
ORDER BY rating
LIMIT 1,5

I'm unsure about that order and limit there, so you might have to wrap
that inside of a temporary table query and take your 5 out of that. A
join is the right way to go with this though I reckon.

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-31 Thread Alice Wei


> Date: Mon, 31 May 2010 11:56:38 -0400
> To: php-general@lists.php.net; aj...@alumni.iu.edu
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different 
> Forms
> 
> At 7:23 PM -0400 5/30/10, Alice Wei wrote:
> >Tedd,
> >
> >   Looks like I finally found the answer to my question, and the key 
> >is the term, dependent drop down menu. There is an example that I 
> >found here, 
> >http://www.huanix.com/files/dependent_select/dependent_select.txt, 
> >and after editing everything, looks like what I want is not so far 
> >to reach. As I am writing now, I got the code I desired to work 
> >after studying what went on in the code from the above link.
> >
> >Thanks for your help, and looks like I solved the problem, I may be 
> >able to close the thread now.
> >
> >Alice
> 
> 
> Alice:
> 
> An interesting solution.
> 
> I tested it here:
> 
> http://php1.net/a/ajax-select-db
> 
> The database needs a little work -- I wasn't aware that Virginia was 
> a State in Germany. :-)
> 
> It also needs a little work when someone changes an intermediate 
> selection to null the ones further down the chain -- it only goes one 
> deep.
> 
> The control also uses GET when I think POST would work better -- at 
> least it would hide the inner-workings of the control from the user.
> 
> However, if that was what you were looking for then great.
   
About the get and post, yes, I did change that to post in my sample, but thanks 
for pointing it out. 

Alice

> 
> Good luck and thread closed.
> 
> Cheers,
> 
> tedd
> 
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
  
_
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-31 Thread tedd

At 7:23 PM -0400 5/30/10, Alice Wei wrote:

Tedd,

  Looks like I finally found the answer to my question, and the key 
is the term, dependent drop down menu. There is an example that I 
found here, 
http://www.huanix.com/files/dependent_select/dependent_select.txt, 
and after editing everything, looks like what I want is not so far 
to reach. As I am writing now, I got the code I desired to work 
after studying what went on in the code from the above link.


Thanks for your help, and looks like I solved the problem, I may be 
able to close the thread now.


Alice



Alice:

An interesting solution.

I tested it here:

http://php1.net/a/ajax-select-db

The database needs a little work -- I wasn't aware that Virginia was 
a State in Germany. :-)


It also needs a little work when someone changes an intermediate 
selection to null the ones further down the chain -- it only goes one 
deep.


The control also uses GET when I think POST would work better -- at 
least it would hide the inner-workings of the control from the user.


However, if that was what you were looking for then great.

Good luck and thread closed.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-30 Thread Alice Wei

> Date: Sun, 30 May 2010 11:53:44 -0400
> To: php-general@lists.php.net; aj...@alumni.iu.edu
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different
> Forms
> 
> At 12:08 PM -0400 5/29/10, Alice Wei wrote:
> >
> >At the time of writing this, I got all the functionality I wanted, 
> >only that it takes 3 submits, which is 4 pages in total, which 
> >includes two dependent select menus based on user input by clicking 
> >on the radio button and some other static drop downs and text inputs.
> >
> >I am not sure if it is possible to cut it down two only two submits, 
> >I just went online and found this, 
> >http://www.w3schools.com/dhtml/tryit.asp?filename=trydhtml_event_onchange. 
> >If I could change this function to using the radio button, and 
> >process the other searching for the dependent drop downs using case 
> >statements with PHP , do you think this is a good idea?
> >
> >Anyway, I found this method is kind of ugly for the time being, but 
> >less daunting with what I was doing before. Thanks.
> >
> >Alice
> 
> Alice:
> 
> The example you provided above is very basic and I think what you 
> want is far more complex.
> 
> I realize that it's hard to convey what it is that you actually want 
> because you don't know all that can be done -- and the number of 
> possibilities of how to organize controls is far too vast for me to 
> guess.
> 
> For example, here's another example of what can be done:
> 
> http://www.webbytedd.com/a/ajax-select/index.php
> 
> But I know this doesn't fully solve your problem but it comes closer 
> than the example you provided above.
> 
> Sometimes it's best to "story-board" what you want so that both you 
> and to whom you're asking questions can have a better idea of the 
> problem.
> 
> For example, let's say you want to gather data from a user -- in 
> option A, the user is asked Y/N. If the user answers N, then the user 
> is sent to option B. If the user answers Y, then the user is sent to 
> option C. In option B the user is presented with... and Option C the 
> user is presented with... and so on. -- I'm sure you get the idea.
> 
> So, if you want to continue with this, please prepare a "story-board" 
> and present your problem again.
> 
> Cheers,
> 
> tedd
> 
> -- 

Tedd, 

  Looks like I finally found the answer to my question, and the key is the 
term, dependent drop down menu. There is an example that I found here, 
http://www.huanix.com/files/dependent_select/dependent_select.txt, and after 
editing everything, looks like what I want is not so far to reach. As I am 
writing now, I got the code I desired to work after studying what went on in 
the code from the above link. 

Thanks for your help, and looks like I solved the problem, I may be able to 
close the thread now. 

Alice

> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
  
_
Hotmail is redefining busy with tools for the New Busy. Get more from your 
inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-30 Thread tedd

At 12:08 PM -0400 5/29/10, Alice Wei wrote:


At the time of writing this, I got all the functionality I wanted, 
only that it takes 3 submits, which is 4 pages in total, which 
includes two dependent select menus based on user input by clicking 
on the radio button and some other static drop downs and text inputs.


I am not sure if it is possible to cut it down two only two submits, 
I just went online and found this, 
http://www.w3schools.com/dhtml/tryit.asp?filename=trydhtml_event_onchange. 
If I could change this function to using the radio button, and 
process the other searching for the dependent drop downs using case 
statements with PHP , do you think this is a good idea?


Anyway, I found this method is kind of ugly for the time being, but 
less daunting with what I was doing before. Thanks.


Alice


Alice:

The example you provided above is very basic and I think what you 
want is far more complex.


I realize that it's hard to convey what it is that you actually want 
because you don't know all that can be done -- and the number of 
possibilities of how to organize controls is far too vast for me to 
guess.


For example, here's another example of what can be done:

http://www.webbytedd.com/a/ajax-select/index.php

But I know this doesn't fully solve your problem but it comes closer 
than the example you provided above.


Sometimes it's best to "story-board" what you want so that both you 
and to whom you're asking questions can have a better idea of the 
problem.


For example, let's say you want to gather data from a user -- in 
option A, the user is asked Y/N. If the user answers N, then the user 
is sent to option B. If the user answers Y, then the user is sent to 
option C. In option B the user is presented with... and Option C the 
user is presented with... and so on. -- I'm sure you get the idea.


So, if you want to continue with this, please prepare a "story-board" 
and present your problem again.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-29 Thread Alice Wei


> Date: Sat, 29 May 2010 11:50:50 -0400
> To: php-general@lists.php.net; aj...@alumni.iu.edu
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different   
> Forms
> 
> At 7:31 PM -0400 5/28/10, Alice Wei wrote:
> >
> >Anything I want?
> >
> >Seriously, I do know how to pass a "non-dynamic" element from one 
> >page to another page, but when I started researching on how to 
> >utilize dynamic menus based on user input, I found Ajax, until this 
> >problem that I am running into hits me.
> >
> >Is there some way that I could generate dynamic select menus without 
> >using Ajax? Or, is that asking too much?
> >
> >Thanks for your help.
> >
> >Alice
> 
> Alice:
> 
> No offense, but considering what you posted when you started this 
> exchange, it did not appear that you knew how to use forms. But on 
> the other hand, I don't know what "non-dynamic" elements are.
> 
> Now on to your problem -- you want to "generate dynamic select menu" 
> -- I'm not sure what those are either. I think you need to start 
> using the terminology used in html, controls, and such. You can't 
> just throw terms together hoping that the person at the other end 
> knows what you're talking about.
> 
> In any event, here's something for you to consider:
> 
> http://www.webbytedd.com/a/ajax-controls/
> 
> It shows how to use javascript to detect user's actions in input 
> elements (i.e., text, radio, checkboxes, etc.) and select elements. 
>  From those routines, you should be able to construct whatever 
> "dynamic select menus" you want. All the code is there -- just review 
> it.
> 
> It would be a trivial matter to add a Submit button to the form to 
> pass these values to the server via traditional means and thus the 
> Submit was omitted to show how Ajax Controls work.
> 
> However, it is important to note that the example provided above is 
> not unobtrusive -- it is an early example of how all of this was 
> done. There are more appropriate ways to accomplish this, but they 
> require more abstraction, which would probably lead to more confusion 
> on your part -- no offense meant.
> 
> I suggest you read "DOM Scripting" and "Advance DOM Scripting" both 
> published by Friends of ED. They are well worth the cost/effort to 
> read and would give you a better understanding of the processes 
> involved.
> 
> Cheers,
> 
> tedd
> 


At the time of writing this, I got all the functionality I wanted, only that it 
takes 3 submits, which is 4 pages in total, which includes two dependent select 
menus based on user input by clicking on the radio button and some other static 
drop downs and text inputs. 

I am not sure if it is possible to cut it down two only two submits, I just 
went online and found this, 
http://www.w3schools.com/dhtml/tryit.asp?filename=trydhtml_event_onchange. If I 
could change this function to using the radio button, and process the other 
searching for the dependent drop downs using case statements with PHP , do you 
think this is a good idea?

Anyway, I found this method is kind of ugly for the time being, but less 
daunting with what I was doing before. Thanks. 

Alice


> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
  
_
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-29 Thread tedd

At 7:31 PM -0400 5/28/10, Alice Wei wrote:


Anything I want?

Seriously, I do know how to pass a "non-dynamic" element from one 
page to another page, but when I started researching on how to 
utilize dynamic menus based on user input, I found Ajax, until this 
problem that I am running into hits me.


Is there some way that I could generate dynamic select menus without 
using Ajax? Or, is that asking too much?


Thanks for your help.

Alice


Alice:

No offense, but considering what you posted when you started this 
exchange, it did not appear that you knew how to use forms. But on 
the other hand, I don't know what "non-dynamic" elements are.


Now on to your problem -- you want to "generate dynamic select menu" 
-- I'm not sure what those are either. I think you need to start 
using the terminology used in html, controls, and such. You can't 
just throw terms together hoping that the person at the other end 
knows what you're talking about.


In any event, here's something for you to consider:

http://www.webbytedd.com/a/ajax-controls/

It shows how to use javascript to detect user's actions in input 
elements (i.e., text, radio, checkboxes, etc.) and select elements. 
From those routines, you should be able to construct whatever 
"dynamic select menus" you want. All the code is there -- just review 
it.


It would be a trivial matter to add a Submit button to the form to 
pass these values to the server via traditional means and thus the 
Submit was omitted to show how Ajax Controls work.


However, it is important to note that the example provided above is 
not unobtrusive -- it is an early example of how all of this was 
done. There are more appropriate ways to accomplish this, but they 
require more abstraction, which would probably lead to more confusion 
on your part -- no offense meant.


I suggest you read "DOM Scripting" and "Advance DOM Scripting" both 
published by Friends of ED. They are well worth the cost/effort to 
read and would give you a better understanding of the processes 
involved.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-28 Thread Adam Richardson
On Fri, May 28, 2010 at 8:01 PM, Alice Wei  wrote:

>
>
> From: aj...@alumni.iu.edu
> To: tedd.sperl...@gmail.com
> CC: php-general@lists.php.net
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different
>  Forms
> Date: Fri, 28 May 2010 19:31:10 -0400
>
>
>
>
>
>
>
>
>
> > Date: Fri, 28 May 2010 17:18:21 -0400
> > To: aj...@alumni.iu.edu
> > From: tedd.sperl...@gmail.com
> > Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different
>  Forms
> > CC: php-general@lists.php.net
> >
> > >On Fri, 2010-05-28 at 15:12 -0400, Alice Wei wrote:
> > >   What I am trying to find out is, when I have my form with a
> > >dependent select menu, how can I pass the value of the select menu
> > >to another page? I have mentioned in the initial email that if I
> > >just allow users to type stuff, it passes the form back to itself
> > >and works. However, what I want
> > >  to do is to allow users click one radio button/checkbox, and use
> > >that value to determine which "select menu" to bring up. However,
> > >the information I am only interested in storing, is the value of the
> > >select menu and not the radio  button/checkbox.
> > >
> > >Am I making sense here?
> >
> > and
> >
> > >>Maybe that is why I cannot pass the information on in the "hidden"
> > >>value, but what have I missed here? Ajax? PHP? I am getting
> > >>confused.
> > >>
> > >>Alice
> >
> > Alice:
> >
> > That's the reason why I am taking this in steps instead of hitting
> > you with all the buzz-words you were throwing around when we started.
> >
> > If you don't know how to pass variables from one page to another,
> > then why require ajax? That only complicates the process. There are
> > several methods to pass variables from one page to another. You could
> > have everything contained in a single page, but let's just solve your
> > problem.
> >
> > To pass things from one page to another has been demonstrated to you
> > in the examples I provided, namely:
> >
> > http://webbytedd.com//alice
> >
> > and
> >
> > http://webbytedd.com//alice1/
> >
> > Those forms are passing data as the user clicks submit.
> >
> > Now, you want the user to pick a value and then pass that value to a
> > different page to bring up a different select control, right?
> >
> > Please review this:
> >
> > http://www.webbytedd.com//alice2/index.php
> >
> > That does everything you ask and it does it simply without ajax. From
> > these examples you should be able to create just about anything you
> > want.
> >
> > Cheers,
> >
> > tedd
> >
> Anything I want?
>
> On a second note, after looking at your example again, is it possible to
> generate what is on form 4 without having to push submit button on form 3?
> Or, is that another topic in Javascript or something else?
>
> Alice
>
>
> > --
> > ---
> > http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> The New Busy is not the old busy. Search, chat and e-mail from your inbox.
> Get started.
> _
> Hotmail is redefining busy with tools for the New Busy. Get more from your
> inbox.
>
> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2


Alice,

I'm not really sure what you're looking for, but this page has examples of
forms that are dynamically generated using AJAX.  Perhaps sifting through
the code (and using tools like the Web Developer plugin) will give you some
ideas:
http://nephtaliproject.com/nedit/

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-28 Thread Alice Wei


From: aj...@alumni.iu.edu
To: tedd.sperl...@gmail.com
CC: php-general@lists.php.net
Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different  Forms
Date: Fri, 28 May 2010 19:31:10 -0400









> Date: Fri, 28 May 2010 17:18:21 -0400
> To: aj...@alumni.iu.edu
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different  
> Forms
> CC: php-general@lists.php.net
> 
> >On Fri, 2010-05-28 at 15:12 -0400, Alice Wei wrote:
> >   What I am trying to find out is, when I have my form with a 
> >dependent select menu, how can I pass the value of the select menu 
> >to another page? I have mentioned in the initial email that if I 
> >just allow users to type stuff, it passes the form back to itself 
> >and works. However, what I want
> >  to do is to allow users click one radio button/checkbox, and use 
> >that value to determine which "select menu" to bring up. However, 
> >the information I am only interested in storing, is the value of the 
> >select menu and not the radio  button/checkbox.
> >
> >Am I making sense here?
> 
> and
> 
> >>Maybe that is why I cannot pass the information on in the "hidden" 
> >>value, but what have I missed here? Ajax? PHP? I am getting 
> >>confused.
> >>
> >>Alice
> 
> Alice:
> 
> That's the reason why I am taking this in steps instead of hitting 
> you with all the buzz-words you were throwing around when we started.
> 
> If you don't know how to pass variables from one page to another, 
> then why require ajax? That only complicates the process. There are 
> several methods to pass variables from one page to another. You could 
> have everything contained in a single page, but let's just solve your 
> problem.
> 
> To pass things from one page to another has been demonstrated to you 
> in the examples I provided, namely:
> 
> http://webbytedd.com//alice
> 
> and
> 
> http://webbytedd.com//alice1/ 
> 
> Those forms are passing data as the user clicks submit.
> 
> Now, you want the user to pick a value and then pass that value to a 
> different page to bring up a different select control, right?
> 
> Please review this:
> 
> http://www.webbytedd.com//alice2/index.php
> 
> That does everything you ask and it does it simply without ajax. From 
> these examples you should be able to create just about anything you 
> want.
> 
> Cheers,
> 
> tedd
> 
Anything I want? 

On a second note, after looking at your example again, is it possible to 
generate what is on form 4 without having to push submit button on form 3? Or, 
is that another topic in Javascript or something else?

Alice


> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
  
The New Busy is not the old busy. Search, chat and e-mail from your inbox. Get 
started.   
_
Hotmail is redefining busy with tools for the New Busy. Get more from your 
inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-28 Thread Alice Wei


> Date: Fri, 28 May 2010 17:18:21 -0400
> To: aj...@alumni.iu.edu
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different  
> Forms
> CC: php-general@lists.php.net
> 
> >On Fri, 2010-05-28 at 15:12 -0400, Alice Wei wrote:
> >   What I am trying to find out is, when I have my form with a 
> >dependent select menu, how can I pass the value of the select menu 
> >to another page? I have mentioned in the initial email that if I 
> >just allow users to type stuff, it passes the form back to itself 
> >and works. However, what I want
> >  to do is to allow users click one radio button/checkbox, and use 
> >that value to determine which "select menu" to bring up. However, 
> >the information I am only interested in storing, is the value of the 
> >select menu and not the radio  button/checkbox.
> >
> >Am I making sense here?
> 
> and
> 
> >>Maybe that is why I cannot pass the information on in the "hidden" 
> >>value, but what have I missed here? Ajax? PHP? I am getting 
> >>confused.
> >>
> >>Alice
> 
> Alice:
> 
> That's the reason why I am taking this in steps instead of hitting 
> you with all the buzz-words you were throwing around when we started.
> 
> If you don't know how to pass variables from one page to another, 
> then why require ajax? That only complicates the process. There are 
> several methods to pass variables from one page to another. You could 
> have everything contained in a single page, but let's just solve your 
> problem.
> 
> To pass things from one page to another has been demonstrated to you 
> in the examples I provided, namely:
> 
> http://webbytedd.com//alice
> 
> and
> 
> http://webbytedd.com//alice1/ 
> 
> Those forms are passing data as the user clicks submit.
> 
> Now, you want the user to pick a value and then pass that value to a 
> different page to bring up a different select control, right?
> 
> Please review this:
> 
> http://www.webbytedd.com//alice2/index.php
> 
> That does everything you ask and it does it simply without ajax. From 
> these examples you should be able to create just about anything you 
> want.
> 
> Cheers,
> 
> tedd
> 
Anything I want? 

Seriously, I do know how to pass a "non-dynamic" element from one page to 
another page, but when I started researching on how to utilize dynamic menus 
based on user input, I found Ajax, until this problem that I am running into 
hits me. 

Is there some way that I could generate dynamic select menus without 
using Ajax? Or, is that asking too much?

Thanks for your help.

Alice


> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
  
_
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-28 Thread tedd

On Fri, 2010-05-28 at 15:12 -0400, Alice Wei wrote:
  What I am trying to find out is, when I have my form with a 
dependent select menu, how can I pass the value of the select menu 
to another page? I have mentioned in the initial email that if I 
just allow users to type stuff, it passes the form back to itself 
and works. However, what I want
 to do is to allow users click one radio button/checkbox, and use 
that value to determine which "select menu" to bring up. However, 
the information I am only interested in storing, is the value of the 
select menu and not the radio  button/checkbox.


Am I making sense here?


and

Maybe that is why I cannot pass the information on in the "hidden" 
value, but what have I missed here? Ajax? PHP? I am getting 
confused.


Alice


Alice:

That's the reason why I am taking this in steps instead of hitting 
you with all the buzz-words you were throwing around when we started.


If you don't know how to pass variables from one page to another, 
then why require ajax? That only complicates the process. There are 
several methods to pass variables from one page to another. You could 
have everything contained in a single page, but let's just solve your 
problem.


To pass things from one page to another has been demonstrated to you 
in the examples I provided, namely:


http://webbytedd.com//alice

and

http://webbytedd.com//alice1

Those forms are passing data as the user clicks submit.

Now, you want the user to pick a value and then pass that value to a 
different page to bring up a different select control, right?


Please review this:

http://www.webbytedd.com//alice2/index.php

That does everything you ask and it does it simply without ajax. From 
these examples you should be able to create just about anything you 
want.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-28 Thread Alice Wei


Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms
From: a...@ashleysheridan.co.uk
To: aj...@alumni.iu.edu
CC: tedd.sperl...@gmail.com; php-general@lists.php.net
Date: Fri, 28 May 2010 20:14:06 +0100






  
  


On Fri, 2010-05-28 at 15:12 -0400, Alice Wei wrote:


Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different 
Forms

From: a...@ashleysheridan.co.uk

To: aj...@alumni.iu.edu

CC: tedd.sperl...@gmail.com; php-general@lists.php.net

Date: Fri, 28 May 2010 20:05:29 +0100



On Fri, 2010-05-28 at 15:00 -0400, Alice Wei wrote: 


 Date: Fri, 28 May 2010 12:34:55 -0400
> To: aj...@alumni.iu.edu; php-general@lists.php.net
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different 
> Forms
> 
> At 9:19 PM -0400 5/27/10, Alice Wei wrote:
> >
> >I am not sure how to add to the page you have set up, but here is 
> >the code with ther portion you have set up:
> >
> >
> > >   $start = isset($_POST['start']) ? $_POST['start'] : null;
> >?>
> > 
> >   
> > Select the type of your starting point of interest:
> > 
> > Which Semster is this: 
> > Fall
> > Spring
> > Summer
> > 
> > 
> >   
> > 
> >
> >  Note, what I provided here does not include anything on the ajax.
> >
> >Hope this answers your question.
> 
> Alice :
> 
> I didn't have a question, but here's my revision of your code:
> 
> http://www.webbytedd.com//alice1/
> 
> Please review the code and see how: 1) I captured the select value; 
> 2) and how I used that value to focus the selected option.
> 
> You say:
> 
> >  Note, what I provided here does not include anything on the ajax.
> 
> I've never put anything "on the ajax" -- that doesn't make sense.
> 
> Ajax is simply a way to communicate from the browser to the server 
> and back again without requiring a browser refresh. As the user 
> triggers a client-side event (i.e., click, select, enter text, move a 
> mouse, whatever), a javascript routine then sends data to the server 
> to activate a server-side script, which may, or may not, return data.
> 
> For example -- with javascript turned ON please review:
> 
> http://www.webbytedd.com/a/ajax-site/
> 
> This is simply a one page template that uses an ajax routine to 
> retrieve data from the server to populate the page based upon what 
> the user triggers (i.e., the visitor clicks a navigational link).
> 
> If you will review the HTML source code, you will find a very basic 
> HTML template that will remain static for all three "apparent" pages. 
> If you use the FireFox browser you can review the generated HTML.
> 
> Now where did the generated HTML come from, you might ask? It came 
> from the server after a request was made from the client to the 
> server and the server responded with the correct data -- all without 
> requiring a browser refresh. That's an example of how ajax works.
> 
> Keep in mind that using "best practices" requires you to *first* 
> design forms to collect data WITHOUT requiring javascript and then 
> you can enhance the form to provide additional functionality to those 
> who have javascript turned on. Also keep in mind that you may not 
> need ajax to alter the form. You only need ajax if there is data on 
> the server that needs to be retrieved.
> 
> Now, please turn javascript OFF in your browser and review my page again:
> 
> http://www.webbytedd.com/a/ajax-site/
> 
> That's an example of NOT following "best practices". The visitor is 
> provided nothing if they have javascript turned OFF.
> 
> Now considering such, what additional functionality do you want your 
> form to do that can't be done already?
> 
> Cheers,
> 
> tedd
> 
> -- 

Tedd,  

  What I am trying to find out is, when I have my form with a dependent select 
menu, how can I pass the value of the select menu to another page? I have 
mentioned in the initial email that if I just allow users to type stuff, it 
passes the form back to itself and works. However, what I want
 to do is to allow users click one radio button/checkbox, and use that value to 
determine which "select menu" to bring up. However, the information I am only 
interested in storing, is the value of the select menu and not the radio  
button/checkbox. 

Am I making sense here? 

Alice
> ---
> http://sperling.com  http://ancientstones.com  http:

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-28 Thread Ashley Sheridan
On Fri, 2010-05-28 at 15:12 -0400, Alice Wei wrote:

> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two
> Different Forms
> From: a...@ashleysheridan.co.uk
> To: aj...@alumni.iu.edu
> CC: tedd.sperl...@gmail.com; php-general@lists.php.net
> Date: Fri, 28 May 2010 20:05:29 +0100
> 
> On Fri, 2010-05-28 at 15:00 -0400, Alice Wei wrote: 
> 
> 
>  Date: Fri, 28 May 2010 12:34:55 -0400
> > To: aj...@alumni.iu.edu; php-general@lists.php.net
> > From: tedd.sperl...@gmail.com
> > Subject: RE: [PHP] Select Values Didn't Get Passed in From Two 
> Different Forms
> > 
> > At 9:19 PM -0400 5/27/10, Alice Wei wrote:
> > >
> > >I am not sure how to add to the page you have set up, but here is 
> > >the code with ther portion you have set up:
> > >
> > >
> > > > >   $start = isset($_POST['start']) ? $_POST['start'] : null;
> > >?>
> > > 
> > >   
> > > Select the type of your starting point of interest:
> > > 
> > > Which Semster is this: 
> > > Fall
> > > Spring
> > > Summer
> > > 
> > > 
> > >   
> > > 
> > >
> > >  Note, what I provided here does not include anything on the ajax.
> > >
> > >Hope this answers your question.
> > 
> > Alice :
> > 
> > I didn't have a question, but here's my revision of your code:
> > 
> > http://www.webbytedd.com//alice1/
> > 
> > Please review the code and see how: 1) I captured the select value; 
> > 2) and how I used that value to focus the selected option.
> > 
> > You say:
> > 
> > >  Note, what I provided here does not include anything on the ajax.
> > 
> > I've never put anything "on the ajax" -- that doesn't make sense.
> > 
> > Ajax is simply a way to communicate from the browser to the server 
> > and back again without requiring a browser refresh. As the user 
> > triggers a client-side event (i.e., click, select, enter text, move 
> a 
> > mouse, whatever), a javascript routine then sends data to the 
> server 
> > to activate a server-side script, which may, or may not, return 
> data.
> > 
> > For example -- with javascript turned ON please review:
> > 
> > http://www.webbytedd.com/a/ajax-site/
> > 
> > This is simply a one page template that uses an ajax routine to 
> > retrieve data from the server to populate the page based upon what 
> > the user triggers (i.e., the visitor clicks a navigational link).
> > 
> > If you will review the HTML source code, you will find a very basic 
> > HTML template that will remain static for all three "apparent" 
> pages. 
> > If you use the FireFox browser you can review the generated HTML.
> > 
> > Now where did the generated HTML come from, you might ask? It came 
> > from the server after a request was made from the client to the 
> > server and the server responded with the correct data -- all 
> without 
> > requiring a browser refresh. That's an example of how ajax works.
> > 
> > Keep in mind that using "best practices" requires you to *first* 
> > design forms to collect data WITHOUT requiring javascript and then 
> > you can enhance the form to provide additional functionality to 
> those 
> > who have javascript turned on. Also keep in mind that you may not 
> > need ajax to alter the form. You only need ajax if there is data on 
> > the server that needs to be retrieved.
> > 
> > Now, please turn javascript OFF in your browser and review my page 
> again:
> > 
> > http://www.webbytedd.com/a/ajax-site/
> > 
> > That's an example of NOT following "best practices". The visitor is 
> > provided nothing if they have

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-28 Thread Alice Wei

Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms
From: a...@ashleysheridan.co.uk
To: aj...@alumni.iu.edu
CC: tedd.sperl...@gmail.com; php-general@lists.php.net
Date: Fri, 28 May 2010 20:05:29 +0100






  
  


On Fri, 2010-05-28 at 15:00 -0400, Alice Wei wrote:


 Date: Fri, 28 May 2010 12:34:55 -0400
> To: aj...@alumni.iu.edu; php-general@lists.php.net
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different 
> Forms
> 
> At 9:19 PM -0400 5/27/10, Alice Wei wrote:
> >
> >I am not sure how to add to the page you have set up, but here is 
> >the code with ther portion you have set up:
> >
> >
> > >   $start = isset($_POST['start']) ? $_POST['start'] : null;
> >?>
> > 
> >   
> > Select the type of your starting point of interest:
> > 
> > Which Semster is this: 
> > Fall
> > Spring
> > Summer
> > 
> > 
> >   
> > 
> >
> >  Note, what I provided here does not include anything on the ajax.
> >
> >Hope this answers your question.
> 
> Alice :
> 
> I didn't have a question, but here's my revision of your code:
> 
> http://www.webbytedd.com//alice1/
> 
> Please review the code and see how: 1) I captured the select value; 
> 2) and how I used that value to focus the selected option.
> 
> You say:
> 
> >  Note, what I provided here does not include anything on the ajax.
> 
> I've never put anything "on the ajax" -- that doesn't make sense.
> 
> Ajax is simply a way to communicate from the browser to the server 
> and back again without requiring a browser refresh. As the user 
> triggers a client-side event (i.e., click, select, enter text, move a 
> mouse, whatever), a javascript routine then sends data to the server 
> to activate a server-side script, which may, or may not, return data.
> 
> For example -- with javascript turned ON please review:
> 
> http://www.webbytedd.com/a/ajax-site/
> 
> This is simply a one page template that uses an ajax routine to 
> retrieve data from the server to populate the page based upon what 
> the user triggers (i.e., the visitor clicks a navigational link).
> 
> If you will review the HTML source code, you will find a very basic 
> HTML template that will remain static for all three "apparent" pages. 
> If you use the FireFox browser you can review the generated HTML.
> 
> Now where did the generated HTML come from, you might ask? It came 
> from the server after a request was made from the client to the 
> server and the server responded with the correct data -- all without 
> requiring a browser refresh. That's an example of how ajax works.
> 
> Keep in mind that using "best practices" requires you to *first* 
> design forms to collect data WITHOUT requiring javascript and then 
> you can enhance the form to provide additional functionality to those 
> who have javascript turned on. Also keep in mind that you may not 
> need ajax to alter the form. You only need ajax if there is data on 
> the server that needs to be retrieved.
> 
> Now, please turn javascript OFF in your browser and review my page again:
> 
> http://www.webbytedd.com/a/ajax-site/
> 
> That's an example of NOT following "best practices". The visitor is 
> provided nothing if they have javascript turned OFF.
> 
> Now considering such, what additional functionality do you want your 
> form to do that can't be done already?
> 
> Cheers,
> 
> tedd
> 
> -- 

Tedd,  

  What I am trying to find out is, when I have my form with a dependent select 
menu, how can I pass the value of the select menu to another page? I have 
mentioned in the initial email that if I just allow users to type stuff, it 
passes the form back to itself and works. However, what I want
 to do is to allow users click one radio button/checkbox, and use that value to 
determine which "select menu" to bring up. However, the information I am only 
interested in storing, is the value of the select menu and not the radio  
button/checkbox. 

Am I making sense here? 

Alice
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
  
_
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-28 Thread Ashley Sheridan
On Fri, 2010-05-28 at 15:00 -0400, Alice Wei wrote:

> 
>  Date: Fri, 28 May 2010 12:34:55 -0400
> > To: aj...@alumni.iu.edu; php-general@lists.php.net
> > From: tedd.sperl...@gmail.com
> > Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different
> >  Forms
> > 
> > At 9:19 PM -0400 5/27/10, Alice Wei wrote:
> > >
> > >I am not sure how to add to the page you have set up, but here is 
> > >the code with ther portion you have set up:
> > >
> > >
> > > > >   $start = isset($_POST['start']) ? $_POST['start'] : null;
> > >?>
> > > 
> > >   
> > > Select the type of your starting point of interest:
> > > 
> > > Which Semster is this: 
> > > Fall
> > > Spring
> > > Summer
> > > 
> > > 
> > >   
> > > 
> > >
> > >  Note, what I provided here does not include anything on the ajax.
> > >
> > >Hope this answers your question.
> > 
> > Alice :
> > 
> > I didn't have a question, but here's my revision of your code:
> > 
> > http://www.webbytedd.com//alice1/
> > 
> > Please review the code and see how: 1) I captured the select value; 
> > 2) and how I used that value to focus the selected option.
> > 
> > You say:
> > 
> > >  Note, what I provided here does not include anything on the ajax.
> > 
> > I've never put anything "on the ajax" -- that doesn't make sense.
> > 
> > Ajax is simply a way to communicate from the browser to the server 
> > and back again without requiring a browser refresh. As the user 
> > triggers a client-side event (i.e., click, select, enter text, move a 
> > mouse, whatever), a javascript routine then sends data to the server 
> > to activate a server-side script, which may, or may not, return data.
> > 
> > For example -- with javascript turned ON please review:
> > 
> > http://www.webbytedd.com/a/ajax-site/
> > 
> > This is simply a one page template that uses an ajax routine to 
> > retrieve data from the server to populate the page based upon what 
> > the user triggers (i.e., the visitor clicks a navigational link).
> > 
> > If you will review the HTML source code, you will find a very basic 
> > HTML template that will remain static for all three "apparent" pages. 
> > If you use the FireFox browser you can review the generated HTML.
> > 
> > Now where did the generated HTML come from, you might ask? It came 
> > from the server after a request was made from the client to the 
> > server and the server responded with the correct data -- all without 
> > requiring a browser refresh. That's an example of how ajax works.
> > 
> > Keep in mind that using "best practices" requires you to *first* 
> > design forms to collect data WITHOUT requiring javascript and then 
> > you can enhance the form to provide additional functionality to those 
> > who have javascript turned on. Also keep in mind that you may not 
> > need ajax to alter the form. You only need ajax if there is data on 
> > the server that needs to be retrieved.
> > 
> > Now, please turn javascript OFF in your browser and review my page again:
> > 
> > http://www.webbytedd.com/a/ajax-site/
> > 
> > That's an example of NOT following "best practices". The visitor is 
> > provided nothing if they have javascript turned OFF.
> > 
> > Now considering such, what additional functionality do you want your 
> > form to do that can't be done already?
> > 
> > Cheers,
> > 
> > tedd
> > 
> > -- 
> 
> Tedd,  
> 
>   What I am trying to find out is, when I have my form with a dependent 
> select menu, how can I pass the value of the select menu to another page? I 
> have mentioned in the initial email that if I just allow users to type stuff, 
> it passes the form back to itself and works. However, what I want
>  to do is to allow users click one radio button/checkbox, and use that value 
> to determine which "select menu" to bring up. However, the information I am 
> only interested in storing, is the value of the select menu and not the radio 
>  button/checkbox. 
> 
> Am I making sense here? 
> 
> Alice
> > ---
> > http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
> _
> The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
> Hotmail. 
> http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5


You could do this a couple of ways:

1) Have all the possible form elements you need and show the one the
user needs with Javascript
2) Use ajax to grab the select list you need based on the users
selection and add it in to the current form.

It doesn't matter if you submit more form elements than you need, just
don't use them when the form is submitted to the php script.

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-28 Thread Alice Wei


 Date: Fri, 28 May 2010 12:34:55 -0400
> To: aj...@alumni.iu.edu; php-general@lists.php.net
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different 
> Forms
> 
> At 9:19 PM -0400 5/27/10, Alice Wei wrote:
> >
> >I am not sure how to add to the page you have set up, but here is 
> >the code with ther portion you have set up:
> >
> >
> > >   $start = isset($_POST['start']) ? $_POST['start'] : null;
> >?>
> > 
> >   
> > Select the type of your starting point of interest:
> > 
> > Which Semster is this: 
> > Fall
> > Spring
> > Summer
> > 
> > 
> >   
> > 
> >
> >  Note, what I provided here does not include anything on the ajax.
> >
> >Hope this answers your question.
> 
> Alice :
> 
> I didn't have a question, but here's my revision of your code:
> 
> http://www.webbytedd.com//alice1/
> 
> Please review the code and see how: 1) I captured the select value; 
> 2) and how I used that value to focus the selected option.
> 
> You say:
> 
> >  Note, what I provided here does not include anything on the ajax.
> 
> I've never put anything "on the ajax" -- that doesn't make sense.
> 
> Ajax is simply a way to communicate from the browser to the server 
> and back again without requiring a browser refresh. As the user 
> triggers a client-side event (i.e., click, select, enter text, move a 
> mouse, whatever), a javascript routine then sends data to the server 
> to activate a server-side script, which may, or may not, return data.
> 
> For example -- with javascript turned ON please review:
> 
> http://www.webbytedd.com/a/ajax-site/
> 
> This is simply a one page template that uses an ajax routine to 
> retrieve data from the server to populate the page based upon what 
> the user triggers (i.e., the visitor clicks a navigational link).
> 
> If you will review the HTML source code, you will find a very basic 
> HTML template that will remain static for all three "apparent" pages. 
> If you use the FireFox browser you can review the generated HTML.
> 
> Now where did the generated HTML come from, you might ask? It came 
> from the server after a request was made from the client to the 
> server and the server responded with the correct data -- all without 
> requiring a browser refresh. That's an example of how ajax works.
> 
> Keep in mind that using "best practices" requires you to *first* 
> design forms to collect data WITHOUT requiring javascript and then 
> you can enhance the form to provide additional functionality to those 
> who have javascript turned on. Also keep in mind that you may not 
> need ajax to alter the form. You only need ajax if there is data on 
> the server that needs to be retrieved.
> 
> Now, please turn javascript OFF in your browser and review my page again:
> 
> http://www.webbytedd.com/a/ajax-site/
> 
> That's an example of NOT following "best practices". The visitor is 
> provided nothing if they have javascript turned OFF.
> 
> Now considering such, what additional functionality do you want your 
> form to do that can't be done already?
> 
> Cheers,
> 
> tedd
> 
> -- 

Tedd,  

  What I am trying to find out is, when I have my form with a dependent select 
menu, how can I pass the value of the select menu to another page? I have 
mentioned in the initial email that if I just allow users to type stuff, it 
passes the form back to itself and works. However, what I want
 to do is to allow users click one radio button/checkbox, and use that value to 
determine which "select menu" to bring up. However, the information I am only 
interested in storing, is the value of the select menu and not the radio  
button/checkbox. 

Am I making sense here? 

Alice
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
  
_
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-28 Thread tedd

At 9:19 PM -0400 5/27/10, Alice Wei wrote:


I am not sure how to add to the page you have set up, but here is 
the code with ther portion you have set up:





  
Select the type of your starting point of interest:


Which Semster is this: 
Fall
Spring
Summer


  


 Note, what I provided here does not include anything on the ajax.

Hope this answers your question.


Alice :

I didn't have a question, but here's my revision of your code:

http://www.webbytedd.com//alice1/

Please review the code and see how: 1) I captured the select value; 
2) and how I used that value to focus the selected option.


You say:


 Note, what I provided here does not include anything on the ajax.


I've never put anything "on the ajax" -- that doesn't make sense.

Ajax is simply a way to communicate from the browser to the server 
and back again without requiring a browser refresh. As the user 
triggers a client-side event (i.e., click, select, enter text, move a 
mouse, whatever), a javascript routine then sends data to the server 
to activate a server-side script, which may, or may not, return data.


For example -- with javascript turned ON please review:

http://www.webbytedd.com/a/ajax-site/

This is simply a one page template that uses an ajax routine to 
retrieve data from the server to populate the page based upon what 
the user triggers (i.e., the visitor clicks a navigational link).


If you will review the HTML source code, you will find a very basic 
HTML template that will remain static for all three "apparent" pages. 
If you use the FireFox browser you can review the generated HTML.


Now where did the generated HTML come from, you might ask? It came 
from the server after a request was made from the client to the 
server and the server responded with the correct data -- all without 
requiring a browser refresh. That's an example of how ajax works.


Keep in mind that using "best practices" requires you to *first* 
design forms to collect data WITHOUT requiring javascript and then 
you can enhance the form to provide additional functionality to those 
who have javascript turned on. Also keep in mind that you may not 
need ajax to alter the form. You only need ajax if there is data on 
the server that needs to be retrieved.


Now, please turn javascript OFF in your browser and review my page again:

http://www.webbytedd.com/a/ajax-site/

That's an example of NOT following "best practices". The visitor is 
provided nothing if they have javascript turned OFF.


Now considering such, what additional functionality do you want your 
form to do that can't be done already?


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-27 Thread Alice Wei

  
> Date: Thu, 27 May 2010 12:23:46 -0400
> To: aj...@alumni.iu.edu; php-general@lists.php.net
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms
> 
> At 3:50 PM -0400 5/26/10, Alice Wei wrote:
> >
> > My bad, I cannot imagine I sent that stuff. To answer your 
> >question, here it is,
> >
> > 
> > Select the type of your starting point of interest:
> >  >maxlength="50"/>
> >
> > 
> > 
> >
> >
> >This is what is working now if I do it this way, but again, then I 
> >got to make sure everything is "typed up properly" before the form 
> >is submitted. Does this answer your questions by any chance?
> >
> >
> >Alice
> >
> 
> Alice:
> 
> Okay, not bad -- here's my addition:
> 
> http://www.webbytedd.com//alice/
> 
> Please review the code. I removed the maxlength because that's 
> something you should do server-side anyway. Never trust anything 
> coming from the client-side.
> 
> Also note that closing the tags, such as  is optional -- IF -- 
> you're not planning on using XML. Otherwise they will generate a W3C 
> short-tags warning. However, that's not a fatal error.
> 
> Also note the Submit button statement has three attributes. Type 
> states the type of input statement, value is what the button displays 
> to the user (i.e., Submit") and name is the name of the variable that 
> you can access via a POST/GET.
> 
> Also note how the form collects the "start" value from a POST and 
> then repopulates the form after it has the data. This important to 
> understand. Clicking the "Submit" button sends the form's data to the 
> server which then sends it back to the browser via a refreshed form.
> 
> Also note the ternary operator I used, namely:
> 
> $start = isset($_POST['start']) ? $_POST['start'] : null;
> 
> The first time the page is viewed, POST is sampled for content. If 
> there is no content, then checking for content will generate an error 
> unless we first check to see if it has content, hence the isset(). If 
> it doesn't have content, then the statement assigns NULL to $start. 
> If it does have content, then it will assign that value to $start, 
> understand?
> 
> Now, what's next? What other data do you want to collect? You 
> mentioned a select control that derived its data from a database. But 
> before we go to that, show me a "select" control working in a form 
> with embedded values -- in other words, just a simple select control. 
> Please add it to the form we have.
> 
> Cheers,
> 
> 
> tedd
> 
 
I am not sure how to add to the page you have set up, but here is the code with 
ther portion you have set up:
 



  
Select the type of your starting point of interest:

Which Semster is this: 
Fall
Spring
Summer


  


 Note, what I provided here does not include anything on the ajax. 

 

Hope this answers your question. 

 

Alice

> -- 
> ---
> http://sperling.com http://ancientstones.com http://earthstones.com


  
_
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-27 Thread tedd

At 3:50 PM -0400 5/26/10, Alice Wei wrote:


   My bad, I cannot imagine I sent that stuff. To answer your 
question, here it is,



Select the type of your starting point of interest:
 maxlength="50"/>


   
   


This is what is working now if I do it this way, but again, then I 
got to make sure everything is "typed up properly" before the form 
is submitted. Does this answer your questions by any chance?



Alice



Alice:

Okay, not bad -- here's my addition:

http://www.webbytedd.com//alice/

Please review the code. I removed the maxlength because that's 
something you should do server-side anyway. Never trust anything 
coming from the client-side.


Also note that closing the tags, such as  is optional -- IF -- 
you're not planning on using XML. Otherwise they will generate a W3C 
short-tags warning. However, that's not a fatal error.


Also note the Submit button statement has three attributes. Type 
states the type of input statement, value is what the button displays 
to the user (i.e., Submit") and name is the name of the variable that 
you can access via a POST/GET.


Also note how the form collects the "start" value from a POST and 
then repopulates the form after it has the data. This important to 
understand. Clicking the "Submit" button sends the form's data to the 
server which then sends it back to the browser via a refreshed form.


Also note the ternary operator I used, namely:

$start = isset($_POST['start']) ? $_POST['start'] : null;

The first time the page is viewed, POST is sampled for content. If 
there is no content, then checking for content will generate an error 
unless we first check to see if it has content, hence the isset(). If 
it doesn't have content, then the statement assigns NULL to $start. 
If it does have content, then it will assign that value to $start, 
understand?


Now, what's next? What other data do you want to collect? You 
mentioned a select control that derived its data from a database. But 
before we go to that, show me a "select" control working in a form 
with embedded values -- in other words, just a simple select control. 
Please add it to the form we have.


Cheers,


tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-26 Thread Nisse Engström
On Wed, 26 May 2010 11:02:10 -0400, Alice Wei wrote:

[De-indented to preserve sanity]

>  
>   

Bzzt. Only  elements can be children of .

>   Select the type of your starting point of interest:
>
> 

Bzzt. You didn't close the previous . You can *not*
have nested  elements.

> onclick="check(document.form1.start)"/> Apartment 
> onclick="check(document.form1.start)"/> Grocery  
>

Bzzt. Non-standard DOM references. Use

check(document.forms.form1.elements.start)
or
check(this.form.elements.start)
or
check(this)

Note that the first two will pass a collection of
elements because you have two controls with the
same name. The third will pass a single element.

> 
> 
> 
>  
>   
>   
>   
>   
>  

Bzzt. An input control with the same name as one of the
  forms? Wasn't it confusing enough already?


/Nisse

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



Re: [PHP] Select Values Didn't Get Passed in From Two DifferentForms

2010-05-26 Thread Al



On 5/26/2010 3:50 PM, Alice Wei wrote:




Date: Wed, 26 May 2010 15:36:18 -0400
To: php-general@lists.php.net; aj...@alumni.iu.edu
From: tedd.sperl...@gmail.com
Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

Alice:

You provide:




Select the type of your starting point of interest:

  Apartment
  Grocery

  















My bad, I cannot imagine I sent that stuff. To answer your question, here 
it is,




 
 Select the type of your starting point of interest:
  






This is what is working now if I do it this way, but again, then I got to make sure 
everything is "typed up properly" before the form is submitted. Does this 
answer your questions by any chance?



Thanks for your help.



Alice





You also state:


I hope this helps in understanding what my problem may be.


It's very apparent that your problem is multifold and to solve it we
need to take the "solution" in steps.

First, the above HTML code is just plain horrible -- and that's just
html part or the problem -- let alone the more complicated
php/mysql/javascript coding.

If that is the best html code you can write, then I suggest that you
go back to learn html before learning anything else.

So, your assignment (if you want me to continue to help) is to create
a simple form to collect the data you want. Nothing fancy, just a
simple form -- can you do that?

The assignment is in your court. If you can show you can do that,
then we'll proceed to the next step.

Cheers,

tedd

--
---
http://sperling.com http://ancientstones.com http://earthstones.com



_
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4


Alice:

First, always make certain your html code is perfect. Use W3C's validator. 
http://validator.w3.org/


I recommend html 1.1 It's really not much extra effort and helps greatly to 
insure compatibility with all modern browsers.





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



RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-26 Thread Alice Wei


> Date: Wed, 26 May 2010 15:36:18 -0400
> To: php-general@lists.php.net; aj...@alumni.iu.edu
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms
> 
> Alice:
> 
> You provide:
> 
> > 
> > 
> > Select the type of your starting point of interest:
> >  >action="test_getrss.php" name="form1" method="post">
> >  >value="Apartment" name="start"
> > 
> >onclick="check(document.form1.start)"/> Apartment 
> >  >value="Grocery" name="start"
> > 
> >onclick="check(document.form1.start)"/> Grocery 
> > 
> >   
> >
> > 
> > 
> >  >value=""/>
> > 
> > 
> > 
> > 
> >
> >
> 


   My bad, I cannot imagine I sent that stuff. To answer your question, here it 
is, 

 



Select the type of your starting point of interest:
 

   
   

 

This is what is working now if I do it this way, but again, then I got to make 
sure everything is "typed up properly" before the form is submitted. Does this 
answer your questions by any chance?

 

Thanks for your help.

 

Alice

 

> 
> You also state:
> 
> > I hope this helps in understanding what my problem may be.
> 
> It's very apparent that your problem is multifold and to solve it we 
> need to take the "solution" in steps.
> 
> First, the above HTML code is just plain horrible -- and that's just 
> html part or the problem -- let alone the more complicated 
> php/mysql/javascript coding.
> 
> If that is the best html code you can write, then I suggest that you 
> go back to learn html before learning anything else.
> 
> So, your assignment (if you want me to continue to help) is to create 
> a simple form to collect the data you want. Nothing fancy, just a 
> simple form -- can you do that?
> 
> The assignment is in your court. If you can show you can do that, 
> then we'll proceed to the next step.
> 
> Cheers,
> 
> tedd
> 
> -- 
> ---
> http://sperling.com http://ancientstones.com http://earthstones.com

  
_
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-26 Thread tedd

Alice:

You provide:


 

Select the type of your starting point of interest:
action="test_getrss.php" name="form1" method="post">
value="Apartment" name="start"


onclick="check(document.form1.start)"/> Apartment 
value="Grocery" name="start"


onclick="check(document.form1.start)"/> Grocery 
   



  
 
value=""/>

   









You also state:


 I hope this helps in understanding what my problem may be.


It's very apparent that your problem is multifold and to solve it we 
need to take the "solution" in steps.


First, the above HTML code is just plain horrible -- and that's just 
html part or the problem -- let alone the more complicated 
php/mysql/javascript coding.


If that is the best html code you can write, then I suggest that you 
go back to learn html before learning anything else.


So, your assignment (if you want me to continue to help) is to create 
a simple form to collect the data you want. Nothing fancy, just a 
simple form -- can you do that?


The assignment is in your court. If you can show you can do that, 
then we'll proceed to the next step.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-26 Thread Alice Wei


> Date: Wed, 26 May 2010 09:19:26 -0400
> To: php-general@lists.php.net; aj...@alumni.iu.edu
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different  
> Forms
> 
> At 9:17 PM -0400 5/25/10, Alice Wei wrote:
> >No, the fields are populated in the first and second
> >form, form1 and form2. What I want to do is to get the selections from
> >both forms and pass them on to the third. Does this make sense? For some
> >  reason, the text input and the semester drop down menu result can be
> >passed to process.php, but the results that I try to select from the
> >first and second does not. So, the form is not passing the results of
> >what I had from the radio button selections.
> >
> >To illustrate, the
> >second looks something like this:
> 
> Alice:
> 
> No offense, but "Looking" like something isn't going to cut it.
> 
> I advise you to:
> 
> 1. Show us the code. -- give us a url where your code is located.
> 
> 2. Tell us what you *want* to do -- and don't show us with "it looks 
> something like this" nonsense.
> 
> 3. Get the simple stuff to work first before jumping into the harder stuff.
> 
> If you are willing to do the above, then I'll help you with your problem.
> 
> Please understand that forms are very simple with very simple rules 
> to follow. Enhancing forms with javascript routines can become 
> complicated very quickly. But if you can describe it, it can be done.
> 
> Cheers,
> 
> tedd
> 
> 


I thought I provided the whole code, but looks like it somehow got lost in the 
thread. 

Here is the main file I would like to use for my data entry:

Main:


 

Select the type of your starting point of interest:

 Apartment 
 Grocery  
   
 

  
  

   


 



This is the script that I use to construct the drop down menu in test_getrss.php

";
// printing the list box select command

while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "$nt[0]";
/* Option values are added by looping through the array */
}
echo "";// Closing of list box 
?> 


See, I am trying to get the users pick something from the  and have the info in there to pass on to process.php

";





?>

Therefore, the radio button info. does not need to be recorded. This is not the 
only field I need to pass to process.php, which the data would be used to enter 
into a database. I am leaving what is not working in my code. I hope this helps 
in understanding what my problem may be. 

Thanks for your help. 

Alice
  
_
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-26 Thread tedd

At 9:17 PM -0400 5/25/10, Alice Wei wrote:

No, the fields are populated in the first and second
form, form1 and form2. What I want to do is to get the selections from
both forms and pass them on to the third. Does this make sense? For some
 reason, the text input and the semester drop down menu result can be
passed to process.php, but the results that I try to select from the
first and second does not. So, the form is not passing the results of
what I had from the radio button selections.

To illustrate, the
second looks something like this:


Alice:

No offense, but "Looking" like something isn't going to cut it.

I advise you to:

1. Show us the code. -- give us a url where your code is located.

2. Tell us what you *want* to do -- and don't show us with "it looks 
something like this" nonsense.


3. Get the simple stuff to work first before jumping into the harder stuff.

If you are willing to do the above, then I'll help you with your problem.

Please understand that forms are very simple with very simple rules 
to follow. Enhancing forms with javascript routines can become 
complicated very quickly. But if you can describe it, it can be done.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-26 Thread Bob McConnell
From: Alice Wei

> On Tue, 2010-05-25 at 15:41 -0400, Alice Wei wrote:
> 
>> Date: Tue, 25 May 2010 13:40:44 -0400
>> Subject: Re: [PHP] 
> Select Values Didn't Get Passed in From Two Different Forms
>> 
> From: marc.g...@gmail.com
>> To: aj...@alumni.iu.edu
>> 
>>
> > I would like to take those values away into my third form, which 
> is what you
>> > see with the hidden. If they are not populated,
>  then how come I could see
>> > the drop down menus?
>> 
>>
>  So you're expecting the values selected in the first two forms to
>>
>  populate the values of the hidden fields in the third form?  Why not
>> 
>  wrap the whole thing in a single form?  Do test_getrss.php and
>> 
> test_getrss2.php perform anything useful or are they just hanging
>>
>  around?
> 
> No, the fields are populated in the first and second 
> form, form1 and form2. What I want to do is to get the selections from

> both forms and pass them on to the third. Does this make sense? For
some
>  reason, the text input and the semester drop down menu result can be 
> passed to process.php, but the results that I try to select from the 
> first and second does not. So, the form is not passing the results of 
> what I had from the radio button selections.
> 

Alice,

What you seem to be missing is that the browser, by design, will only
send the fields in the form that was submitted. If you want to change
that you need to either replace the browser with one you modified to act
the way you want, or change the page to combine all of the forms into
one. You can try to work around it using Javascript, but that will only
work for people that don't know enough to disable that primary infection
vector for malware.

Bob McConnell

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



RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-26 Thread Ashley Sheridan
On Wed, 2010-05-26 at 08:28 -0400, Alice Wei wrote:

> On Tue, 2010-05-25 at 15:41 -0400, Alice Wei wrote:
> 
> > Date: Tue, 25 May 2010 13:40:44 -0400
> > Subject: Re: [PHP] 
> Select Values Didn't Get Passed in From Two Different Forms
> > 
> From: marc.g...@gmail.com
> > To: aj...@alumni.iu.edu
> > 
> >
>  > I would like to take those values away into my third form, which 
> is what you
> > > see with the hidden. If they are not populated,
>  then how come I could see
> > > the drop down menus?
> > 
> >
>  So you're expecting the values selected in the first two forms to
> >
>  populate the values of the hidden fields in the third form?  Why not
> >
>  wrap the whole thing in a single form?  Do test_getrss.php and
> > 
> test_getrss2.php perform anything useful or are they just hanging
> >
>  around?
> 
> No, the fields are populated in the first and second 
> form, form1 and form2. What I want to do is to get the selections from 
> both forms and pass them on to the third. Does this make sense? For some
>  reason, the text input and the semester drop down menu result can be 
> passed to process.php, but the results that I try to select from the 
> first and second does not. So, the form is not passing the results of 
> what I had from the radio button selections.
> 
> To illustrate, the 
> second looks something like this:
> 
> echo " name='end_location'>";
> while($nt=mysql_fetch_array($result)){//Array
>  or records stored in $nt
> echo " value=$nt[0]>$nt[0]";
> }
> echo "";
> 
> How
>  can I pass the values of what I picked in end_location here to 
> process.php?
> 
> Thanks for your help.
> 
> Alice
>   
>   
> _
> The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
> Hotmail. 
> http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
> 
> 
> 
> 
> 
> You can only pass results from both forms if you duplicate the results of one 
> in the other and then submit that one. You can't submit two forms at the same 
> time. Why do they have to be two forms anyway?
> 
> 
> Well, two of them are created with Ajax that are passed through PHP, so you 
> select one drop down menu are a time, as the drop down menu comes from what 
> you select from a radio button. The results are dynamically. so I don't think 
> they are even created at the same time. Does this help in explaining what I 
> am trying to accomplish?
> 
> Thanks.
> 
> 
> 
> 
> 
> Thanks,
> 
> Ash
> 
> http://www.ashleysheridan.co.uk
> 
> 
> 
> 
> You should get the Ajax to modify the first form. It's a lot easier than 
> creating a second form that uses more Ajax to duplicate any selected values 
> from the first. Have a look at the JQuery library, it makes a lot of the 
> Javascript end a lot easier.
> 
>   I know this is not a PHP question, but could you direct me to something 
> more specific on what I should do here? I am really new to Ajax. 
> 
> 
> 
> 
> 
> 
> Thanks,
> 
> Ash
> 
> http://www.ashleysheridan.co.uk
> 
> 
> 
> 
> 
> 
> 
> 
> _
> Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1


Try a google search for jquery. The first site that comes up contains
all the documentation and examples to get you started.

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-26 Thread Alice Wei

On Tue, 2010-05-25 at 15:41 -0400, Alice Wei wrote:

> Date: Tue, 25 May 2010 13:40:44 -0400
> Subject: Re: [PHP] 
Select Values Didn't Get Passed in From Two Different Forms
> 
From: marc.g...@gmail.com
> To: aj...@alumni.iu.edu
> 
>
 > I would like to take those values away into my third form, which 
is what you
> > see with the hidden. If they are not populated,
 then how come I could see
> > the drop down menus?
> 
>
 So you're expecting the values selected in the first two forms to
>
 populate the values of the hidden fields in the third form?  Why not
>
 wrap the whole thing in a single form?  Do test_getrss.php and
> 
test_getrss2.php perform anything useful or are they just hanging
>
 around?

No, the fields are populated in the first and second 
form, form1 and form2. What I want to do is to get the selections from 
both forms and pass them on to the third. Does this make sense? For some
 reason, the text input and the semester drop down menu result can be 
passed to process.php, but the results that I try to select from the 
first and second does not. So, the form is not passing the results of 
what I had from the radio button selections.

To illustrate, the 
second looks something like this:

echo "";
while($nt=mysql_fetch_array($result)){//Array
 or records stored in $nt
echo "$nt[0]";
}
echo "";

How
 can I pass the values of what I picked in end_location here to 
process.php?

Thanks for your help.

Alice

  
_
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5





You can only pass results from both forms if you duplicate the results of one 
in the other and then submit that one. You can't submit two forms at the same 
time. Why do they have to be two forms anyway?


Well, two of them are created with Ajax that are passed through PHP, so you 
select one drop down menu are a time, as the drop down menu comes from what you 
select from a radio button. The results are dynamically. so I don't think they 
are even created at the same time. Does this help in explaining what I am 
trying to accomplish?

Thanks.





Thanks,

Ash

http://www.ashleysheridan.co.uk




You should get the Ajax to modify the first form. It's a lot easier than 
creating a second form that uses more Ajax to duplicate any selected values 
from the first. Have a look at the JQuery library, it makes a lot of the 
Javascript end a lot easier.

  I know this is not a PHP question, but could you direct me to something more 
specific on what I should do here? I am really new to Ajax. 






Thanks,

Ash

http://www.ashleysheridan.co.uk







  
_
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1

RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-25 Thread Edwin
Hi Adam,
I am not sure this would help but does echo command end with semi colon ;
?.  value=""/> 

Maybe the echo is having some issue? Else, you could try passing the
variables as method = get and view the variables in
Ur address bar

regards,
Edwin.

-Original Message-
From: Adam Richardson [mailto:simples...@gmail.com] 
Sent: Wednesday, May 26, 2010 1:31 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Select Values Didn't Get Passed in From Two Different
Forms

On Tue, May 25, 2010 at 1:17 PM, Alice Wei  wrote:

>
> Hi,
>
>  It is kind of difficult to explain what I am trying to do here, I will
> provide the form here to give a better idea.
>
>  
>Select the type of your starting point of
> interest:
> action="test_getrss.php" name="form1" method="post">
> value="Apartment" name="start"
>
>  onclick="check(document.form1.start)"/> Apartment 
> value="Grocery" name="start"
>
>  onclick="check(document.form1.start)"/> Grocery 
> value="Drugstore" name="start"
>
>  onclick="check(document.form1.start)"/> Drug Store 
>
>Select the type of your ending point of
> interest:
> action="test_getrss2.php" name="form2" method="post">
> value="Apartment" name="end"
>
>  onclick="check2(document.form2.end)"/> Apartment 
> value="Grocery" name="end"
>
>  onclick="check2(document.form2.end)"/> Grocery 
> value="Drugstore" name="end"
>
>  onclick="check2(document.form2.end)"/> Drug Store 
>
>   
>Start Time:  name="start_time"/>
>Arrive Time:  name="end_time"/>
>Which Semster is this: 
>Fall
>Spring
>Summer
>
>
> value=""/>
> value="Submit" name="submit"/>
> name="reset"/>
>
>
>
> For some reason, when I pass in the output with process.php, the hidden
> input does not get passed in. Here is the process.php:
>
>  //get the q parameter from URL
>
> $start_time = $_POST['start_time'];
> $end_time = $_POST['end_time'];
> $semester = $_POST['semester'];
> $form1 = $_POST['form1'];
> $form2 = $_POST['form2'];
>
> echo "Start Time " . $start_time . "";
> echo "End Time " . $end_time . "";
> echo "Semester " . $semester . "";
> echo "Start Location " . $form1 . "";
> echo "End Location " . $form2 . "";
>
> ?>
>
> I get values for start_time, end_time and semester, but not the last two
> values. What have I done wrong here?
>
> Thanks for your help.
>
> Alice
>
>
> _
> The New Busy is not the old busy. Search, chat and e-mail from your inbox.
>
>
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:W
L:en-US:WM_HMP:042010_3


Where are you setting the variables $start and $end?

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


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



RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-25 Thread Ashley Sheridan
On Tue, 2010-05-25 at 21:17 -0400, Alice Wei wrote:

> 
> Subject: Re: [PHP] Select Values Didn't Get Passed in From Two Different Forms
> From: a...@ashleysheridan.co.uk
> To: aj...@alumni.iu.edu
> CC: php-general@lists.php.net
> Date: Tue, 25 May 2010 20:37:29 +0100
> 
> 
> 
> 
> 
> 
>   
>   
> 
> 
> On Tue, 2010-05-25 at 15:41 -0400, Alice Wei wrote:
> 
> > Date: Tue, 25 May 2010 13:40:44 -0400
> > Subject: Re: [PHP] 
> Select Values Didn't Get Passed in From Two Different Forms
> > 
> From: marc.g...@gmail.com
> > To: aj...@alumni.iu.edu
> > 
> >
>  > I would like to take those values away into my third form, which 
> is what you
> > > see with the hidden. If they are not populated,
>  then how come I could see
> > > the drop down menus?
> > 
> >
>  So you're expecting the values selected in the first two forms to
> >
>  populate the values of the hidden fields in the third form?  Why not
> >
>  wrap the whole thing in a single form?  Do test_getrss.php and
> > 
> test_getrss2.php perform anything useful or are they just hanging
> >
>  around?
> 
> No, the fields are populated in the first and second 
> form, form1 and form2. What I want to do is to get the selections from 
> both forms and pass them on to the third. Does this make sense? For some
>  reason, the text input and the semester drop down menu result can be 
> passed to process.php, but the results that I try to select from the 
> first and second does not. So, the form is not passing the results of 
> what I had from the radio button selections.
> 
> To illustrate, the 
> second looks something like this:
> 
> echo " name='end_location'>";
> while($nt=mysql_fetch_array($result)){//Array
>  or records stored in $nt
> echo " value=$nt[0]>$nt[0]";
> }
> echo "";
> 
> How
>  can I pass the values of what I picked in end_location here to 
> process.php?
> 
> Thanks for your help.
> 
> Alice
>   
>   
> _
> The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
> Hotmail. 
> http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
> 
> 
> 
> 
> 
> You can only pass results from both forms if you duplicate the results of one 
> in the other and then submit that one. You can't submit two forms at the same 
> time. Why do they have to be two forms anyway?
> 
> 
> Well, two of them are created with Ajax that are passed through PHP, so you 
> select one drop down menu are a time, as the drop down menu comes from what 
> you select from a radio button. The results are dynamically. so I don't think 
> they are even created at the same time. Does this help in explaining what I 
> am trying to accomplish?
> 
> Thanks.
> 
> 
> 
> 
> 
> Thanks,
> 
> Ash
> 
> http://www.ashleysheridan.co.uk
> 
> 
> 
> 
> 
> 
> 
> 
> _
> The New Busy is not the old busy. Search, chat and e-mail from your inbox.
> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3


You should get the Ajax to modify the first form. It's a lot easier than
creating a second form that uses more Ajax to duplicate any selected
values from the first. Have a look at the JQuery library, it makes a lot
of the Javascript end a lot easier.

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-25 Thread Alice Wei


Subject: Re: [PHP] Select Values Didn't Get Passed in From Two Different Forms
From: a...@ashleysheridan.co.uk
To: aj...@alumni.iu.edu
CC: php-general@lists.php.net
Date: Tue, 25 May 2010 20:37:29 +0100






  
  


On Tue, 2010-05-25 at 15:41 -0400, Alice Wei wrote:

> Date: Tue, 25 May 2010 13:40:44 -0400
> Subject: Re: [PHP] 
Select Values Didn't Get Passed in From Two Different Forms
> 
From: marc.g...@gmail.com
> To: aj...@alumni.iu.edu
> 
>
 > I would like to take those values away into my third form, which 
is what you
> > see with the hidden. If they are not populated,
 then how come I could see
> > the drop down menus?
> 
>
 So you're expecting the values selected in the first two forms to
>
 populate the values of the hidden fields in the third form?  Why not
>
 wrap the whole thing in a single form?  Do test_getrss.php and
> 
test_getrss2.php perform anything useful or are they just hanging
>
 around?

No, the fields are populated in the first and second 
form, form1 and form2. What I want to do is to get the selections from 
both forms and pass them on to the third. Does this make sense? For some
 reason, the text input and the semester drop down menu result can be 
passed to process.php, but the results that I try to select from the 
first and second does not. So, the form is not passing the results of 
what I had from the radio button selections.

To illustrate, the 
second looks something like this:

echo "";
while($nt=mysql_fetch_array($result)){//Array
 or records stored in $nt
echo "$nt[0]";
}
echo "";

How
 can I pass the values of what I picked in end_location here to 
process.php?

Thanks for your help.

Alice

  
_
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5





You can only pass results from both forms if you duplicate the results of one 
in the other and then submit that one. You can't submit two forms at the same 
time. Why do they have to be two forms anyway?


Well, two of them are created with Ajax that are passed through PHP, so you 
select one drop down menu are a time, as the drop down menu comes from what you 
select from a radio button. The results are dynamically. so I don't think they 
are even created at the same time. Does this help in explaining what I am 
trying to accomplish?

Thanks.





Thanks,

Ash

http://www.ashleysheridan.co.uk







  
_
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3

Re: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-25 Thread Ashley Sheridan
On Tue, 2010-05-25 at 15:41 -0400, Alice Wei wrote:

> > Date: Tue, 25 May 2010 13:40:44 -0400
> > Subject: Re: [PHP] 
> Select Values Didn't Get Passed in From Two Different Forms
> > 
> From: marc.g...@gmail.com
> > To: aj...@alumni.iu.edu
> > 
> >
>  > I would like to take those values away into my third form, which 
> is what you
> > > see with the hidden. If they are not populated,
>  then how come I could see
> > > the drop down menus?
> > 
> >
>  So you're expecting the values selected in the first two forms to
> >
>  populate the values of the hidden fields in the third form?  Why not
> >
>  wrap the whole thing in a single form?  Do test_getrss.php and
> > 
> test_getrss2.php perform anything useful or are they just hanging
> >
>  around?
> 
> No, the fields are populated in the first and second 
> form, form1 and form2. What I want to do is to get the selections from 
> both forms and pass them on to the third. Does this make sense? For some
>  reason, the text input and the semester drop down menu result can be 
> passed to process.php, but the results that I try to select from the 
> first and second does not. So, the form is not passing the results of 
> what I had from the radio button selections.
> 
> To illustrate, the 
> second looks something like this:
> 
> echo " name='end_location'>";
> while($nt=mysql_fetch_array($result)){//Array
>  or records stored in $nt
> echo " value=$nt[0]>$nt[0]";
> }
> echo "";
> 
> How
>  can I pass the values of what I picked in end_location here to 
> process.php?
> 
> Thanks for your help.
> 
> Alice
>   
>   
> _
> The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
> Hotmail. 
> http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5


You can only pass results from both forms if you duplicate the results
of one in the other and then submit that one. You can't submit two forms
at the same time. Why do they have to be two forms anyway?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-25 Thread Alice Wei

> Date: Tue, 25 May 2010 13:40:44 -0400
> Subject: Re: [PHP] 
Select Values Didn't Get Passed in From Two Different Forms
> 
From: marc.g...@gmail.com
> To: aj...@alumni.iu.edu
> 
>
 > I would like to take those values away into my third form, which 
is what you
> > see with the hidden. If they are not populated,
 then how come I could see
> > the drop down menus?
> 
>
 So you're expecting the values selected in the first two forms to
>
 populate the values of the hidden fields in the third form?  Why not
>
 wrap the whole thing in a single form?  Do test_getrss.php and
> 
test_getrss2.php perform anything useful or are they just hanging
>
 around?

No, the fields are populated in the first and second 
form, form1 and form2. What I want to do is to get the selections from 
both forms and pass them on to the third. Does this make sense? For some
 reason, the text input and the semester drop down menu result can be 
passed to process.php, but the results that I try to select from the 
first and second does not. So, the form is not passing the results of 
what I had from the radio button selections.

To illustrate, the 
second looks something like this:

echo "";
while($nt=mysql_fetch_array($result)){//Array
 or records stored in $nt
echo "$nt[0]";
}
echo "";

How
 can I pass the values of what I picked in end_location here to 
process.php?

Thanks for your help.

Alice

  
_
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

Re: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-25 Thread Marc Guay
>> > I would like to take those values away into my third form, which is what
>> > you
>> > see with the hidden. If they are not populated, then how come I could
>> > see
>> > the drop down menus?
>>
>> So you're expecting the values selected in the first two forms to
>> populate the values of the hidden fields in the third form? Why not
>> wrap the whole thing in a single form? Do test_getrss.php and
>> test_getrss2.php perform anything useful or are they just hanging
>> around?
>
> No, the fields are populated in the first and second form, form1 and form2.
> What I want to do is to get the selections from both forms and pass them on
> to the third. Does this make sense? For some reason, the text input and the
> semester drop down menu result can be passed to process.php, but the results
> that I try to select from the first and second does not. So, the form is not
> passing the results of what I had from the radio button selections.

We forgot to reply to the group for the last few messages, they're copied above.

You should probably wrap the whole thing in a single form.  The reason
you're not getting the first 2 values in process.php is because
they're inputs inside of a different form.  Only the elements inside
that particular form will get passed to the action.

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



Re: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-25 Thread Adam Richardson
On Tue, May 25, 2010 at 1:17 PM, Alice Wei  wrote:

>
> Hi,
>
>  It is kind of difficult to explain what I am trying to do here, I will
> provide the form here to give a better idea.
>
>  
>Select the type of your starting point of
> interest:
> action="test_getrss.php" name="form1" method="post">
> value="Apartment" name="start"
>
>  onclick="check(document.form1.start)"/> Apartment 
> value="Grocery" name="start"
>
>  onclick="check(document.form1.start)"/> Grocery 
> value="Drugstore" name="start"
>
>  onclick="check(document.form1.start)"/> Drug Store 
>
>Select the type of your ending point of
> interest:
> action="test_getrss2.php" name="form2" method="post">
> value="Apartment" name="end"
>
>  onclick="check2(document.form2.end)"/> Apartment 
> value="Grocery" name="end"
>
>  onclick="check2(document.form2.end)"/> Grocery 
> value="Drugstore" name="end"
>
>  onclick="check2(document.form2.end)"/> Drug Store 
>
>   
>Start Time:  name="start_time"/>
>Arrive Time:  name="end_time"/>
>Which Semster is this: 
>Fall
>Spring
>Summer
>
>
> value=""/>
> value="Submit" name="submit"/>
> name="reset"/>
>
>
>
> For some reason, when I pass in the output with process.php, the hidden
> input does not get passed in. Here is the process.php:
>
>  //get the q parameter from URL
>
> $start_time = $_POST['start_time'];
> $end_time = $_POST['end_time'];
> $semester = $_POST['semester'];
> $form1 = $_POST['form1'];
> $form2 = $_POST['form2'];
>
> echo "Start Time " . $start_time . "";
> echo "End Time " . $end_time . "";
> echo "Semester " . $semester . "";
> echo "Start Location " . $form1 . "";
> echo "End Location " . $form2 . "";
>
> ?>
>
> I get values for start_time, end_time and semester, but not the last two
> values. What have I done wrong here?
>
> Thanks for your help.
>
> Alice
>
>
> _
> The New Busy is not the old busy. Search, chat and e-mail from your inbox.
>
> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3


Where are you setting the variables $start and $end?

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] Select and compare problems still ...

2009-07-01 Thread Miller, Terion



On 7/1/09 10:29 AM, "Andrew Ballard"  wrote:

$data = array($ucName, $ucAddress, $inDate, $inType, $notes,
> $critical, $cleanViolations, $noncritical);
>
> $sql = vprintf("INSERT INTO `restaurants` (name, address, inDate,
> inType, notes, critical, cviolations, noncritical) VALUES ('%s', '%s',
> '%s', '%s', '%s', '%s', '%s', '%s')",
> array_map('mysql_real_escape_string', $data));
>
> $result = mysql_query($sql) or die(mysql_error());

Well I had wondered about the escape_string and did it like this, now I have a 
new problem, it is inserting all the records in the database (making 
duplicates) I want it to match the records and only insert the ones not there...

Here's my code so far:

$cleanViolations = str_replace('*', '', $cviolations);$ucName = 
ucwords($name);$ucAddress = ucwords($address);$mysql_name = 
mysql_escape_string($ucName);$mysql_address = 
mysql_escape_string($ucAddress);$mysql_inDate = 
mysql_escape_string($inDate);$mysql_inType = mysql_escape_string($inType);  
  $mysql_notes = mysql_escape_string($notes);$mysql_critical = 
mysql_escape_string($critical);$mysql_cviolations = 
mysql_escape_string($cleanViolations);$mysql_noncritical = 
mysql_escape_string($noncritical);   echo "$ucName ";
echo "$ucAddress ";echo "$inDate ";echo "$inType "; 
   echo "$notes ";echo "$critical ";//echo 
"$cviolations ";echo "$cleanViolations ";echo 
"$noncritical "; //compare entries and insert new 
inspections to the database //call what is in the database$query = "SELECT 
* FROM  restaurants  WHERE name LIKE '$mysql_name' AND address LIKE 
'$mysql_address' AND inDate LIKE '$mysql_inDate' AND inType LIKE 
'$mysql_inType'" ; $result = mysql_query($query) or die(mysql_error()); 
 echo $result; $row = mysql_numrows($result);  if ($row == 0){  
  $sql = "INSERT INTO `restaurants` (name, address, inDate, inType, notes, 
critical, cviolations, noncritical)  VALUES (" ;  $sql .= " '$ucName', 
'$ucAddress', '$inDate', '$inType', '$notes', '$critical', '$cleanViolations', 
'$noncritical')";$result = mysql_query($sql) or die(mysql_error()); 
   }  /**/ };

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



Re: [PHP] Select and compare problems still ...

2009-07-01 Thread Andrew Ballard
On Wed, Jul 1, 2009 at 11:23 AM, Andrew Ballard wrote:
> On Wed, Jul 1, 2009 at 10:56 AM, Miller,
> Terion wrote:
>> Why doesn't this work?
>>
>>
>>    $query = "SELECT * FROM `restaurants` WHERE name ='$ucName' AND
>> address = '$ucAddress'  " ;
>>
>> $result = mysql_query($query) or die(mysql_error());
>>
>>
>>  echo $result;
>>     $row = mysql_fetch_array ($result);
>>
>>
>>
>>  $sql = "INSERT INTO `restaurants` (name, address, inDate, inType, notes,
>> critical, cviolations, noncritical)  VALUES (" ;
>>     $sql .= " '$ucName',
>> '$ucAddress', '$inDate', '$inType', '$notes', '$critical',
>> '$cleanViolations', '$noncritical')";
>>
>>
>>
>>        $result = mysql_query($sql) or die(mysql_error());
>>
>> The error I keep getting is:
>>
>> You have an error in your SQL syntax; check the manual that corresponds to
>> your MySQL server version for the right syntax to use
>>
>> And I have gone in the mySQL panel and let it make the query so I'm
>> really stumped why it hangs ...
>>
>>
>>
>
> The last example you posted said:
>
> You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use
> near 's Roast Beef Restaurant #9459', ' 1833 W Republic Rd ',
> '3/2/09', '' at line 1
>
> This indicated that the value for $ucName contained an
> apostrophe/single-quote character. (Perhaps it was supposed to be
> "Arby's Roast Beef Restaurant #9459"?).
>
> Try this:
>
> 
> $data = array($ucName, $ucAddress, $inDate, $inType, $notes,
> $critical, $cleanViolations, $noncritical);
>
> $sql = vprintf("INSERT INTO `restaurants` (name, address, inDate,
> inType, notes, critical, cviolations, noncritical) VALUES ('%s', '%s',
> '%s', '%s', '%s', '%s', '%s', '%s')",
> array_map('mysql_real_escape_string', $data));
>
> $result = mysql_query($sql) or die(mysql_error());
>
> ?>
>

oops = make that vsprintf(), not vprintf();

Andrew

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



Re: [PHP] Select and compare problems still ...

2009-07-01 Thread Miller, Terion



On 7/1/09 10:06 AM, "Phpster"  wrote:






On Jul 1, 2009, at 10:56 AM, "Miller, Terion"  wrote:

> Why doesn't this work?
>
>
>$query = "SELECT * FROM `restaurants` WHERE name ='$ucName' AND
> address = '$ucAddress'  " ;
>
> $result = mysql_query($query) or die(mysql_error());
>
>
>  echo $result;
> $row = mysql_fetch_array ($result);
>
>
>
> $sql = "INSERT INTO `restaurants` (name, address, inDate, inType,
> notes,
> critical, cviolations, noncritical)  VALUES (" ;
> $sql .= " '$ucName',
> '$ucAddress', '$inDate', '$inType', '$notes', '$critical',
> '$cleanViolations', '$noncritical')";
>
>
>
>$result = mysql_query($sql) or die(mysql_error());
>
> The error I keep getting is:
>
> You have an error in your SQL syntax; check the manual that
> corresponds to
> your MySQL server version for the right syntax to use
>
> And I have gone in the mySQL panel and let it make the query so
> I'm
> really stumped why it hangs ...
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Try removing the backticks from the tablename, I have found that if
you include the backticks around the table name and not the field
names, mysql will throw the occassional fit.

Bastien

Sent from my iPod

Removed them and still getting the same error
It returns one record then spits out the error...weird.

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



Re: [PHP] Select and compare problems still ...

2009-07-01 Thread Andrew Ballard
On Wed, Jul 1, 2009 at 10:56 AM, Miller,
Terion wrote:
> Why doesn't this work?
>
>
>    $query = "SELECT * FROM `restaurants` WHERE name ='$ucName' AND
> address = '$ucAddress'  " ;
>
> $result = mysql_query($query) or die(mysql_error());
>
>
>  echo $result;
>     $row = mysql_fetch_array ($result);
>
>
>
>  $sql = "INSERT INTO `restaurants` (name, address, inDate, inType, notes,
> critical, cviolations, noncritical)  VALUES (" ;
>     $sql .= " '$ucName',
> '$ucAddress', '$inDate', '$inType', '$notes', '$critical',
> '$cleanViolations', '$noncritical')";
>
>
>
>        $result = mysql_query($sql) or die(mysql_error());
>
> The error I keep getting is:
>
> You have an error in your SQL syntax; check the manual that corresponds to
> your MySQL server version for the right syntax to use
>
> And I have gone in the mySQL panel and let it make the query so I'm
> really stumped why it hangs ...
>
>
>

The last example you posted said:

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 's Roast Beef Restaurant #9459', ' 1833 W Republic Rd ',
'3/2/09', '' at line 1

This indicated that the value for $ucName contained an
apostrophe/single-quote character. (Perhaps it was supposed to be
"Arby's Roast Beef Restaurant #9459"?).

Try this:



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



Re: [PHP] Select and compare problems still ...

2009-07-01 Thread Phpster





On Jul 1, 2009, at 10:56 AM, "Miller, Terion" > wrote:



Why doesn't this work?


   $query = "SELECT * FROM `restaurants` WHERE name ='$ucName' AND
address = '$ucAddress'  " ;

$result = mysql_query($query) or die(mysql_error());


 echo $result;
$row = mysql_fetch_array ($result);



$sql = "INSERT INTO `restaurants` (name, address, inDate, inType,  
notes,

critical, cviolations, noncritical)  VALUES (" ;
$sql .= " '$ucName',
'$ucAddress', '$inDate', '$inType', '$notes', '$critical',
'$cleanViolations', '$noncritical')";



   $result = mysql_query($sql) or die(mysql_error());

The error I keep getting is:

You have an error in your SQL syntax; check the manual that  
corresponds to

your MySQL server version for the right syntax to use

And I have gone in the mySQL panel and let it make the query so  
I'm

really stumped why it hangs ...



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



Try removing the backticks from the tablename, I have found that if  
you include the backticks around the table name and not the field  
names, mysql will throw the occassional fit.


Bastien

Sent from my iPod 


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



Re: [PHP] Select List/Menu

2009-04-17 Thread Richard Heyes
> in VBSCRIPT

In what?

Use [] at the end of your selects name:


   ...


-- 
Richard Heyes

HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.net (Updated April 11th)

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



Re: [PHP] Select Query with Multiple Optional Values

2009-03-22 Thread Robert Cummings
On Sun, 2009-03-22 at 09:22 +0800, Virgilio Quilario wrote:
> >> Trying to find best way to accomplish following scenario.  Looking to 
> >> search
> >> inventory through a POST form, have the following optional fields to search
> >> by: Product Name, Color, Size, and Status.  Search maybe for the Product
> >> Name and/or Color or they may search for just the Color or all 4 fields.  I
> >> am trying to find the most efficient way to do this without having 100
> >> different if statements.
> >
> >  >
> > $where = array( '1 = 1' );
> >
> > if( !empty( $_POST['name'] ) )
> > {
> >where[] = 'name = '.$db->quote( $_POST['name'] );
> > }
> >
> > if( !empty( $_POST['colour'] ) )
> > {
> >where[] = 'colour = '.$db->quote( $_POST['colour'] );
> > }
> >
> > if( !empty( $_POST['size'] ) )
> > {
> >where[] = 'size = '.$db->quote( $_POST['size'] );
> > }
> >
> > if( !empty( $_POST['status'] ) )
> > {
> >where[] = 'status = '.$db->quote( $_POST['status'] );
> > }
> >
> > $query =
> >"SELECT "
> >   ."* "
> >   ."FROM "
> >   ."inventory "
> >   ."WHERE "
> >   ."(".implode( ") AND (", $where ).")";
> >
> > ?>
> >
> > Cheers,
> > Rob.
> 
> Yep, that's the way to do it.
> Or you may do it this way.
> 
> $fields = array('name','colour','size','status');
> foreach ($_POST as $name => $value) {
>   if (empty($value)) continue;
>   if (!in_array($name, $fields, TRUE)) continue;
>   $where[] = $name . '=' . $db->quote($value);
> }
> 
> which is more compact and useful when you have 100 different optional fields.

As long as your form field names are the same as your database field
names. Also as long as you don't need to post process the submitted
values in any way :)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Select Query with Multiple Optional Values

2009-03-21 Thread Virgilio Quilario
>> Trying to find best way to accomplish following scenario.  Looking to search
>> inventory through a POST form, have the following optional fields to search
>> by: Product Name, Color, Size, and Status.  Search maybe for the Product
>> Name and/or Color or they may search for just the Color or all 4 fields.  I
>> am trying to find the most efficient way to do this without having 100
>> different if statements.
>
> 
> $where = array( '1 = 1' );
>
> if( !empty( $_POST['name'] ) )
> {
>    where[] = 'name = '.$db->quote( $_POST['name'] );
> }
>
> if( !empty( $_POST['colour'] ) )
> {
>    where[] = 'colour = '.$db->quote( $_POST['colour'] );
> }
>
> if( !empty( $_POST['size'] ) )
> {
>    where[] = 'size = '.$db->quote( $_POST['size'] );
> }
>
> if( !empty( $_POST['status'] ) )
> {
>    where[] = 'status = '.$db->quote( $_POST['status'] );
> }
>
> $query =
>    "SELECT "
>   ."    * "
>   ."FROM "
>   ."    inventory "
>   ."WHERE "
>   ."    (".implode( ") AND (", $where ).")";
>
> ?>
>
> Cheers,
> Rob.

Yep, that's the way to do it.
Or you may do it this way.

$fields = array('name','colour','size','status');
foreach ($_POST as $name => $value) {
  if (empty($value)) continue;
  if (!in_array($name, $fields, TRUE)) continue;
  $where[] = $name . '=' . $db->quote($value);
}

which is more compact and useful when you have 100 different optional fields.

Virgil
http://www.jampmark.com
Free tips, tutorials, innovative tools and techniques useful for
building and improving web sites.

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



Re: [PHP] Select Query with Multiple Optional Values

2009-03-21 Thread Robert Cummings
On Sat, 2009-03-21 at 10:30 -0700, ben...@gmail.com wrote:
> Trying to find best way to accomplish following scenario.  Looking to search
> inventory through a POST form, have the following optional fields to search
> by: Product Name, Color, Size, and Status.  Search maybe for the Product
> Name and/or Color or they may search for just the Color or all 4 fields.  I
> am trying to find the most efficient way to do this without having 100
> different if statements.

quote( $_POST['name'] );
}

if( !empty( $_POST['colour'] ) )
{
where[] = 'colour = '.$db->quote( $_POST['colour'] );
}

if( !empty( $_POST['size'] ) )
{
where[] = 'size = '.$db->quote( $_POST['size'] );
}

if( !empty( $_POST['status'] ) )
{
where[] = 'status = '.$db->quote( $_POST['status'] );
}

$query =
"SELECT "
   ."* "
   ."FROM "
   ."inventory "
   ."WHERE "
   ."(".implode( ") AND (", $where ).")";

?>

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] SELECT into array of arrays

2008-12-03 Thread Yeti
And yet another thing i have overseen in my statement ..
If you remove the first for loop, also change the sql query. But I'm
sure you saw that already

NEW QUERY:
$sql = "SELECT study,symbol FROM test WHERE study IN ('".implode(', ',
$myArray)."')";

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



Re: [PHP] SELECT into array of arrays

2008-12-03 Thread ceo

I actually would do more like:



$myArray[$study][$symbol] = true;



No need to call in_array.



Probably won't matter, really, but it's a good practice for when you end up 
doing the same kind of code for an array with thousands of elements.



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



Re: [PHP] SELECT into array of arrays

2008-12-03 Thread Andrej Kastrin

Thanks Yeti, it works.

Best, Andrej

Yeti wrote:

Correcting myself now ..

$myArray = array('b2005', 'b2008');
$sql = "SELECT study,symbol FROM test WHERE study IN ('$myArray[$i]')";
$result = mysql_query($sql);

if(mysql_num_rows($result) > 0) {
  while ($myrow = mysql_fetch_array($result)) {
  if (in_array($myrow['study'], $myArray))
$combinedArray[$myrow['study']][] = $myrow['symbol'];
  }
}

Forgot to get rid of the first for loop


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



Re: [PHP] SELECT into array of arrays

2008-12-03 Thread Yeti
Correcting myself now ..

$myArray = array('b2005', 'b2008');
$sql = "SELECT study,symbol FROM test WHERE study IN ('$myArray[$i]')";
$result = mysql_query($sql);

if(mysql_num_rows($result) > 0) {
  while ($myrow = mysql_fetch_array($result)) {
  if (in_array($myrow['study'], $myArray))
$combinedArray[$myrow['study']][] = $myrow['symbol'];
  }
}

Forgot to get rid of the first for loop

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



Re: [PHP] SELECT into array of arrays

2008-12-03 Thread Yeti
> How should I proceed? Thanks in advance for any suggestions.

Since you are looping through the result already, why not do it this way ..

$combinedArray = array();
for ($i=0;$i 0) {
   while ($myrow = mysql_fetch_array($result)) {
   if (in_array($myrow['study'], $myArray))
$combinedArray[$myrow['study']][] = $myrow['symbol'];
   }
}
}

You should get an array like this ...
array("b2008" => array("A", "B", "C", "D"), "b2005" => array("A", "B", "E"))

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



Re: [PHP] Select Box CSS OT

2007-12-18 Thread Børge Holen
On Wednesday 19 December 2007 03:59:11 Richard Lynch wrote:
> On Tue, December 18, 2007 2:06 pm, Børge Holen wrote:
> > On Tuesday 18 December 2007 20:03:53 Stut wrote:
> >> VamVan wrote:
> >> > Please apologize for sending this question to PHP forums.
> >>
> >> If you know this already why ask the question here? Also, this is
> >> not a
> >> forum.
> >>
> >> > But I would appreciate it very much if some could please help me
> >>
> >> styling
> >>
> >> >  in HTMl with CSS?
> >> >
> >> > I have .selectmulti { border: 1px solid #c9c9c9 } this code but it
> >>
> >> only
> >>
> >> > works in firefox How can I make this work in IE?
> >> >
> >> > And also I want to change the selected color.
> >>
> >> AFAIK this can't be done without some very nasty code due to the way
> >> IE
> >> renders select elements. Google has the answer if you really want
> >> it.
> >
> > Trinity renders shit, but for gods sake I would prefer if gecko would
> > render
> > atleast acid2 and keep up with the demands of the stylists, before
> > they call
> > themselves better than others. But then again, neither webkit or khtml
> > is as
> > versatile as the other two.
> > Anyone with thoughts on opera...
>
> All the browsers suck.
>
> They are all rushing half-baked "features" to market instead of
> focussing on quality user experience.
>
> Opera just sucks in different ways.  No worse, no better.
>
> ymmv

lol, the suckiness scale close to tips to the point where it almost f*s up on 
serverside ;D

>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?



-- 
---
Børge Holen
http://www.arivene.net

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



Re: [PHP] Select Box CSS OT

2007-12-18 Thread Richard Lynch
On Tue, December 18, 2007 2:06 pm, Børge Holen wrote:
> On Tuesday 18 December 2007 20:03:53 Stut wrote:
>> VamVan wrote:
>> > Please apologize for sending this question to PHP forums.
>>
>> If you know this already why ask the question here? Also, this is
>> not a
>> forum.
>>
>> > But I would appreciate it very much if some could please help me
>> styling
>> >  in HTMl with CSS?
>> >
>> > I have .selectmulti { border: 1px solid #c9c9c9 } this code but it
>> only
>> > works in firefox How can I make this work in IE?
>> >
>> > And also I want to change the selected color.
>>
>> AFAIK this can't be done without some very nasty code due to the way
>> IE
>> renders select elements. Google has the answer if you really want
>> it.
>
> Trinity renders shit, but for gods sake I would prefer if gecko would
> render
> atleast acid2 and keep up with the demands of the stylists, before
> they call
> themselves better than others. But then again, neither webkit or khtml
> is as
> versatile as the other two.
> Anyone with thoughts on opera...

All the browsers suck.

They are all rushing half-baked "features" to market instead of
focussing on quality user experience.

Opera just sucks in different ways.  No worse, no better.

ymmv

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Select Box CSS OT

2007-12-18 Thread Børge Holen
On Tuesday 18 December 2007 21:16:46 you wrote:
> Why not try a css list? css-discuss for example?

Yes why not?

>
> On Dec 18, 2007 8:06 PM, Børge Holen <[EMAIL PROTECTED]> wrote:
> > On Tuesday 18 December 2007 20:03:53 Stut wrote:
> > > VamVan wrote:
> > > > Please apologize for sending this question to PHP forums.
> > >
> > > If you know this already why ask the question here? Also, this is not a
> > > forum.
> > >
> > > > But I would appreciate it very much if some could please help me
> >
> > styling
> >
> > > >  in HTMl with CSS?
> > > >
> > > > I have .selectmulti { border: 1px solid #c9c9c9 } this code but it
> >
> > only
> >
> > > > works in firefox How can I make this work in IE?
> > > >
> > > > And also I want to change the selected color.
> > >
> > > AFAIK this can't be done without some very nasty code due to the way IE
> > > renders select elements. Google has the answer if you really want it.
> >
> > Trinity renders shit, but for gods sake I would prefer if gecko would
> > render
> > atleast acid2 and keep up with the demands of the stylists, before they
> > call
> > themselves better than others. But then again, neither webkit or khtml is
> > as
> > versatile as the other two.
> > Anyone with thoughts on opera...
> >
> > > -Stut
> > >
> > > --
> > > http://stut.net/
> >
> > --
> > ---
> > Børge Holen
> > http://www.arivene.net
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php



-- 
---
Børge Holen
http://www.arivene.net

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



Re: [PHP] Select Box CSS OT

2007-12-18 Thread Dave Goodchild
Why not try a css list? css-discuss for example?

On Dec 18, 2007 8:06 PM, Børge Holen <[EMAIL PROTECTED]> wrote:

> On Tuesday 18 December 2007 20:03:53 Stut wrote:
> > VamVan wrote:
> > > Please apologize for sending this question to PHP forums.
> >
> > If you know this already why ask the question here? Also, this is not a
> > forum.
> >
> > > But I would appreciate it very much if some could please help me
> styling
> > >  in HTMl with CSS?
> > >
> > > I have .selectmulti { border: 1px solid #c9c9c9 } this code but it
> only
> > > works in firefox How can I make this work in IE?
> > >
> > > And also I want to change the selected color.
> >
> > AFAIK this can't be done without some very nasty code due to the way IE
> > renders select elements. Google has the answer if you really want it.
>
> Trinity renders shit, but for gods sake I would prefer if gecko would
> render
> atleast acid2 and keep up with the demands of the stylists, before they
> call
> themselves better than others. But then again, neither webkit or khtml is
> as
> versatile as the other two.
> Anyone with thoughts on opera...
>
> >
> > -Stut
> >
> > --
> > http://stut.net/
>
>
>
> --
> ---
> Børge Holen
> http://www.arivene.net
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Select Box CSS OT

2007-12-18 Thread Børge Holen
On Tuesday 18 December 2007 20:03:53 Stut wrote:
> VamVan wrote:
> > Please apologize for sending this question to PHP forums.
>
> If you know this already why ask the question here? Also, this is not a
> forum.
>
> > But I would appreciate it very much if some could please help me styling
> >  in HTMl with CSS?
> >
> > I have .selectmulti { border: 1px solid #c9c9c9 } this code but it only
> > works in firefox How can I make this work in IE?
> >
> > And also I want to change the selected color.
>
> AFAIK this can't be done without some very nasty code due to the way IE
> renders select elements. Google has the answer if you really want it.

Trinity renders shit, but for gods sake I would prefer if gecko would render 
atleast acid2 and keep up with the demands of the stylists, before they call 
themselves better than others. But then again, neither webkit or khtml is as 
versatile as the other two.
Anyone with thoughts on opera...

>
> -Stut
>
> --
> http://stut.net/



-- 
---
Børge Holen
http://www.arivene.net

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



Re: [PHP] Select Box CSS

2007-12-18 Thread Stut

VamVan wrote:

Please apologize for sending this question to PHP forums.


If you know this already why ask the question here? Also, this is not a 
forum.



But I would appreciate it very much if some could please help me styling
 in HTMl with CSS?

I have .selectmulti { border: 1px solid #c9c9c9 } this code but it only
works in firefox How can I make this work in IE?

And also I want to change the selected color.


AFAIK this can't be done without some very nasty code due to the way IE 
renders select elements. Google has the answer if you really want it.


-Stut

--
http://stut.net/

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



Re: [PHP] Select record by ID

2007-01-31 Thread Richard Lynch
On Tue, January 30, 2007 7:23 pm, Craige Leeder wrote:
>> atleast this part: $user_id = mysql_real_escape_string((int)
>> $_GET['user_id']);
>
> I'm not sure who put this in there, but you don't need to use
> mysql_real_escape_string() on that value if you're type casting it. If
> you are forcing it to be an integer, there is nothing to escape.
> Integers are perfectly fine to be put into a query as they are.

Can you guarantee that in every character encoding, past, present, and
future?...

Before you answer, keep in mind that the '-' sign is part of an (int).

I'm not claiming that there is any real danger -- only that there is
the theoretical possibility, and skimping on a
mysql_real_escape_string() call is not the right thing to do.

Actually, all I really wanted to do with that was to be sure that the
OP did *something* to learn more about the security issues of user
input and SQL injection attacks...  Didn't expect it to engender this
much discussion, but there it is.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Select record by ID

2007-01-31 Thread Richard Lynch
On Tue, January 30, 2007 4:14 pm, nitrox . wrote:
> Richard, ive included your suggested code and now my php script is
> working
> properly. But I dont want to be a php copy/paste newb who has no clue
> of how
> things are working. If its not too much would you (or anybody) give a
> brief
> explanation of what this code is doing? Or are there any tutorials
> online
> that I can read that will educate me on this? Thanks again to all for
> your
> replies. Ive saved them all for future reference.
>
> atleast this part: $user_id = mysql_real_escape_string((int)
> $_GET['user_id']);

$_GET is an array which has all the values from the URL.

For example, this URL:
http://example.com/yourscript.php?user_id=42
would cause PHP to pre-build this for you:
$_GET['user_id'] = 42;

If you didn't care about SECURITY, you could just do:
$user_id = $_GET['user_id'];
and go on your merry way.

All the rest of the stuff is about SECURITY.

Bad Guys know that you are probably using that user_id in an SQL
query, and will do mean things like:
http://example.com/yourscript.php?user_id=NULL
http://example.com/yourscript.php?user_id=
http://example.com/yourscript.php?user_id[]=
http://example.com/yourscript.php?user_id=1
http://example.com/yourscript.php?user_id=reallylongstringtocauseabufferoverflowfollowedbynastyexecutablecode
http://example.com/yourscript.php?user_id=42 OR user_id IN (update
mysql.users  set password = password('password') where user = 'root')
.
.
.
in attempts to break into your website/webserver or otherwise wreak
havoc.

I did not URL encode the value in that last URL for demonstrative
purposes.  Plus most browsers fix that for you these days anyway.  And
I don't know if any SQL engine would actually *DO* that, but it's sort
of the idea of much more complicated things that could work.

So, to tear apart the rest.

(int) in PHP will type-cast a value to an integer.  This means that if
you do:
$user_id = (int) $_GET['user_id'];
you are immediately protected from most of the hacks above, since you
are forcing the $user_id variable to contain an INTEGER, such as 42,
0, 27, or -14.

You have thrown out the possibility that they are going to splice in
some nasty text SQL.

It's not perfect, as they could still perhaps manage to pretend to be
user #5 instead of user #42, if your script was silly enough to
implicitly trust GET input data.

The mysql_real_escape_string() part is a function provided by MySQL
which will make sure that the value you are providing is properly
escaped.  It is a more mature solution to what
http://php.net/addslashes and Magic Quotes were trying to solve.

Specifically, suppose your user_id in the database was NOT a number,
but was just people's names:
'Richard Lynch'
'Nitrox'
'Kevin O'Brien'

Ooops.  Look at that last name.  The ' in O'Brien is going to confuse
the ' that MySQL uses to delimit a string.

mysql_real_escape_string() takes the 'Kevin O'Brien' and converts it
to 'Kevin O\'Brien' so that when the MySQL SQL parser reads it, it
*knows* that the \' in O'Brien is part of the name.

That way, MySQL can store the right thing down in the guts of its
storage: Kevin O'Brien

Calling mysql_real_escape_string() on an integer is probably a bit of
overkill -- There is NO WAY for anything other than [0-9-] to be in
the result of the (int) typecast.

However, recent attacks have been using very funky features of Unicode
character sets, for languages other than English, so that what looks
like a perfectly normal valid input in English turns into something
realy nasty (in computer science terms, not linguistics).

I don't *think* there are any character sets for which 0-9 and - are
anything other than 0-9 and -, but I'd rather be safe than sorry.

To understand more about why I added all this stuff, start reading here:
http://phpsec.org
and keep reading that site until it's second nature.

>   die ("Could not perform query $query: ".mysql_error()."\n");

This is a Bad Thing to do on most newbie servers where php.ini has:
display_errors = On
because it will expose your exact query and all kinds of mysql stuff
to the Bad Guys, which just makes it easier for them to attack.

You should explore setting up your server with php.ini or .htaccess so
that you have display_errors OFF and log_errors ON, and then you can
use trigger_error("Could not perform query $query: " . mysql_error(),
E_USER_ERROR);
or something similar to that.

A simpler short-term option would be to replace die("...") with:
die("An error has occured." . error_log("Could not perform query
$query: " . mysql_error());

I'm not sure what error_log returns, but it probably won't be
particularly useful, nor dangerous to expose to the Bad Guys.

The Bad News is that you should count on spending about 3 X as much
time thinking about Security to write your application as you would
have spent if everybody in the world was Good People.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some sta

Re: [PHP] Select record by ID

2007-01-30 Thread Craige Leeder

atleast this part: $user_id = mysql_real_escape_string((int)
$_GET['user_id']);


I'm not sure who put this in there, but you don't need to use
mysql_real_escape_string() on that value if you're type casting it. If
you are forcing it to be an integer, there is nothing to escape.
Integers are perfectly fine to be put into a query as they are.

- Craige

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



Re: [PHP] Select record by ID

2007-01-30 Thread Paul Novitski

At 1/30/2007 02:14 PM, nitrox . wrote:
If its not too much would you (or anybody) give a brief explanation 
of what this code is doing? Or are there any tutorials online that I 
can read that will educate me on this? Thanks again to all for your 
replies. Ive saved them all for future reference.


atleast this part: $user_id = mysql_real_escape_string((int) 
$_GET['user_id']);



The querystring parameter user_id is interpreted as an integer and 
then escaped as needed to be safe in a querystring:


"mysql_real_escape_string -- Escapes special characters in a string 
for use in a SQL statement"

http://php.net/mysql_real_escape_string

(int) casts the subsequent value as an integer.  "Type casting in PHP 
works much as it does in C: the name of the desired type is written 
in parentheses before the variable which is to be cast."

http://php.net/manual/en/language.types.type-juggling.php#language.types.typecasting

see also:
Converting to integer
http://php.net/manual/en/language.types.integer.php#language.types.integer.casting

HTTP GET variables: $_GET. "An associative array of variables passed 
to the current script via the HTTP GET method."

http://php.net/manual/en/reserved.variables.php#reserved.variables.get

I recommend that you make the online PHP manual your resource of 
first resort.  It's got a built-in search engine: just enter 
php.net/searchterm into your browser address bar.


Regards,

Paul
__

Juniper Webcraft Ltd.
http://juniperwebcraft.com 


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



Re: [PHP] Select record by ID

2007-01-30 Thread nitrox .
Thanks to all who have replied. As you probably have noticed im a total 
novice to php who is trying to achieve big things.


Richard, ive included your suggested code and now my php script is working 
properly. But I dont want to be a php copy/paste newb who has no clue of how 
things are working. If its not too much would you (or anybody) give a brief 
explanation of what this code is doing? Or are there any tutorials online 
that I can read that will educate me on this? Thanks again to all for your 
replies. Ive saved them all for future reference.


atleast this part: $user_id = mysql_real_escape_string((int) 
$_GET['user_id']);


I understand the rest.

";
echo $myrow['user_name'];
echo "";
}
?>

_
Invite your Hotmail contacts to join your friends list with Windows Live 
Spaces 
http://clk.atdmt.com/MSN/go/msnnkwsp007001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us


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



Re: [PHP] Select record by ID

2007-01-29 Thread Richard Lynch
On Mon, January 29, 2007 7:43 pm, Larry Garfield wrote:
> On Monday 29 January 2007 7:19 pm, Richard Lynch wrote:
>
>> Looks like PostgreSQL caved in to the unwashed masses of MySQL users
>> who couldn't handle not putting apostrophes around everything to
>> me...
>> [sigh]
>>
>> :-) :-) :-)
>>
>> Oh well.
>>
>> I personally would prefer that the DB not accept bogus input like
>> this.
>>
>> Different strokes for different folks.
>
> Different strokes indeed.  Personally I'd much rather one be able to
> just
> say "quote a literal, dagnabbit" and not worry about whether it was a
> string
> or an int.  I'm sure there's some reason for it deep in the bowels of
> SQL
> engines as they existed in the early '80s, but for anyone trying to
> not
> hand-write every frickin' SQL query and automate common tasks it makes
> life
> considerably more annoying.

I can see where you are coming from, but if you don't know what data
type you have, and what data type you are using in SQL, you're already
screwed. :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Select record by ID

2007-01-29 Thread Larry Garfield
On Monday 29 January 2007 7:19 pm, Richard Lynch wrote:

> Looks like PostgreSQL caved in to the unwashed masses of MySQL users
> who couldn't handle not putting apostrophes around everything to me...
> [sigh]
>
> :-) :-) :-)
>
> Oh well.
>
> I personally would prefer that the DB not accept bogus input like this.
>
> Different strokes for different folks.

Different strokes indeed.  Personally I'd much rather one be able to just 
say "quote a literal, dagnabbit" and not worry about whether it was a string 
or an int.  I'm sure there's some reason for it deep in the bowels of SQL 
engines as they existed in the early '80s, but for anyone trying to not 
hand-write every frickin' SQL query and automate common tasks it makes life 
considerably more annoying.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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



Re: [PHP] Select record by ID

2007-01-29 Thread Richard Lynch
On Mon, January 29, 2007 6:55 pm, Roman Neuhauser wrote:
> # [EMAIL PROTECTED] / 2007-01-29 17:54:03 -0600:
>> MySQL is the *only* db engine that lets you get away with [bleep]
>> like
>> apostrophes around numbers.
>
> Actually, these are examples of valid SQL: INTEGER '1', FLOAT '13.5'.

> test=# select float '13.5' * integer '10';
>  ?column?
> --
>   135
> (1 row)

E.

Yes, you can TYPE-CAST string data into integer/float data...

But you are INPUTTING string data at that point, not numeric, and
forcing PostgreSQL to convert it internally.

It's the exact analog of:



> test=# create table t (f float, i integer);
> CREATE TABLE
> test=# insert into t values ('13.5', '10');
> INSERT 0 1
> test=# select * from t;
>   f   | i
> --+
>  13.5 | 10
> (1 row)

I'm amazed this worked and didn't error out...

It definitely USED to error out.

Looks like PostgreSQL caved in to the unwashed masses of MySQL users
who couldn't handle not putting apostrophes around everything to me...
[sigh]
:-) :-) :-)

Oh well.

I personally would prefer that the DB not accept bogus input like this.

Different strokes for different folks.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Select record by ID

2007-01-29 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-29 17:54:03 -0600:
> MySQL is the *only* db engine that lets you get away with [bleep] like
> apostrophes around numbers.

Actually, these are examples of valid SQL: INTEGER '1', FLOAT '13.5'.

test=# select version();
 version
 
-
 PostgreSQL 8.1.3 on amd64-portbld-freebsd6.1, compiled by GCC cc (GCC) 3.4.4 
[FreeBSD] 20050518
(1 row)

test=# select '13.5' * '30';
ERROR:  operator is not unique: "unknown" * "unknown"
test=# select float '13.5' * integer '10';
 ?column? 
--
  135
(1 row)

test=# create table t (f float, i integer);
CREATE TABLE
test=# insert into t values ('13.5', '10');
INSERT 0 1
test=# select * from t;
  f   | i  
--+
 13.5 | 10
(1 row)

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Select record by ID

2007-01-29 Thread Richard Lynch
On Sun, January 28, 2007 6:20 pm, Larry Garfield wrote:
> On Sunday 28 January 2007 5:54 pm, Francisco M. Marzoa Alonso wrote:
>> On dom, 2007-01-28 at 18:51 -0500, nitrox . wrote:
>> > I took the quotes off. I thought that quotes around numbers was
>> wrong
>> > also.
>>
>> Quotes are no necessary around numeric values, but they aren't wrong
>> neither, simply optional.
>
> Actually, I believe they are wrong in some database engines but not
> others.
> MySQL doesn't care.  Some others do.  Yes, it sucks. :-(

The sql_mode stuff requires MySQL 5.x :-(

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Select record by ID

2007-01-29 Thread Richard Lynch
> January 28, 2007 6:20 pm, Larry Garfield wrote:
> On Sunday 28 January 2007 5:54 pm, Francisco M. Marzoa Alonso wrote:
>> On dom, 2007-01-28 at 18:51 -0500, nitrox . wrote:
>> > I took the quotes off. I thought that quotes around numbers was
>> wrong
>> > also.
>>
>> Quotes are no necessary around numeric values, but they aren't wrong
>> neither, simply optional.
>
> Actually, I believe they are wrong in some database engines but not
> others.
> MySQL doesn't care.  Some others do.  Yes, it sucks. :-(

I believe it is now possible to *make* MySQL care by putting it into
"strict" mode when you start it...

MySQL is the *only* db engine that lets you get away with [bleep] like
apostrophes around numbers.

I think strict mode also stops MySQL from the annoying habit of
silently converting inadmissable date/time to '-00-00' [g]

It may even be possible to turn on strict mode with a query, and not
just from launch...

http://dev.mysql.com/ would tell you more about this.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Select record by ID

2007-01-29 Thread Richard Lynch
On Sun, January 28, 2007 5:21 pm, nitrox . wrote:
> Im trying to display one record at a time by ID. Well im getting a
> blank
> page. Ive looked over my code and tried 20 different ways to get it to
> work
> to no avail. So any pointers on what Im doing wrong would be great.
> here is
> the code im working with so far.

First, be sure you are using "View Source" in your browser, so that
something like:



>  include("db.php");

include is not actually a function, and doesn't need parens, so the
()s here are just kinda silly...

> $result = mysql_query("SELECT * FROM inf_member WHERE
> user_id='$user_id' ");

You need *SOME* kind of check here on whether your query succeeded.

The canonical example is:
$result = mysql_query(...) or die(mysql_error());

It would also be wise to get in the habit now of configuring your
web-server to NOT display_errors but to log_errors in your php.ini (or
in .htaccess with php_value) and then to read your error logs instead
of your web page.

The point being to not expose the internal workings of your
application to the Bad Guys who use such info to make it easier to
break into your machine.

Read this over and over until you understand all of it:
http://phpsec.org

> while($myrow = mysql_fetch_assoc($result))
>   {
>  echo "";
>  echo $myrow['user_name'];
>  echo "";
>  echo $myrow['rank'];
>echo "";
>  echo $myrow['country'];
>echo "";
>  echo $myrow['email'];
>  echo "";
>  echo $myrow['quote'];
>  echo "";
>  echo $myrow['config'];
>echo "";
>echo $myrow['map'];
>  echo "";
>  echo $myrow['gun'];
>  echo "";
>  echo $myrow['brand'];
>echo "";
>echo $myrow['cpu'];
>echo "";
>  echo $myrow['ram'];
>  echo "";
>  echo $myrow['video'];
>  echo "";
>  echo $myrow['sound'];
>echo "";
>echo $myrow['monitor'];
>  echo "";
>  echo $myrow['mouse'];
>  echo "";
>  echo $myrow['brand'];
>echo "";

Instead of a bunch of echo statements like this, you may want to
consider the 'heredoc' syntax, or at least fewer echo statements such
as:
echo "$myrow[brand]\n";

Or, you could do like this:
foreach($myrow as $field => value){
  echo "$field: $value\n";
}
instead of all those echo statements.

>  }
> ?>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Select record by ID

2007-01-29 Thread Robert Cummings
On Sun, 2007-01-28 at 21:12 -0500, Craige Leeder wrote:
> As someone else already stated, my best guess according to that error
> is that $user_id has a null, or inappropriate value. The error occurs
> at the last character of the query, so it has to be something like
> hat. Echo the query and let us know what it outputs.

This is coding 101, echo your output and don't presume you know what
you're doing. My wager is that there's a 100% chance he has a null or
empty string value in the variable. A two second echo would have
presented the problem immediately. Given that he probably doesn't have a
clue what's in the variable, it's probably registered via register
globals or pulled directly from $_GET or $_POST and he's asking for
trouble by not escaping it.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Select record by ID

2007-01-28 Thread Craige Leeder

As someone else already stated, my best guess according to that error
is that $user_id has a null, or inappropriate value. The error occurs
at the last character of the query, so it has to be something like
hat. Echo the query and let us know what it outputs.

- Craige

On 1/28/07, Francisco M. Marzoa Alonso <[EMAIL PROTECTED]> wrote:

On dom, 2007-01-28 at 18:20 -0600, Larry Garfield wrote:
> On Sunday 28 January 2007 5:54 pm, Francisco M. Marzoa Alonso wrote:
> > On dom, 2007-01-28 at 18:51 -0500, nitrox . wrote:
> > > I took the quotes off. I thought that quotes around numbers was wrong
> > > also.
> >
> > Quotes are no necessary around numeric values, but they aren't wrong
> > neither, simply optional.
>
> Actually, I believe they are wrong in some database engines but not others.
> MySQL doesn't care.  Some others do.  Yes, it sucks. :-(

Good point, but he's using mysql in this case, and in mysql they're
simply optional but not wrong.

Regards,






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



Re: [PHP] Select record by ID

2007-01-28 Thread Francisco M. Marzoa Alonso
On dom, 2007-01-28 at 18:20 -0600, Larry Garfield wrote:
> On Sunday 28 January 2007 5:54 pm, Francisco M. Marzoa Alonso wrote:
> > On dom, 2007-01-28 at 18:51 -0500, nitrox . wrote:
> > > I took the quotes off. I thought that quotes around numbers was wrong
> > > also.
> >
> > Quotes are no necessary around numeric values, but they aren't wrong
> > neither, simply optional.
> 
> Actually, I believe they are wrong in some database engines but not others.  
> MySQL doesn't care.  Some others do.  Yes, it sucks. :-(

Good point, but he's using mysql in this case, and in mysql they're
simply optional but not wrong.

Regards,



signature.asc
Description: This is a digitally signed message part


Re: [PHP] Select record by ID

2007-01-28 Thread Larry Garfield
On Sunday 28 January 2007 5:54 pm, Francisco M. Marzoa Alonso wrote:
> On dom, 2007-01-28 at 18:51 -0500, nitrox . wrote:
> > I took the quotes off. I thought that quotes around numbers was wrong
> > also.
>
> Quotes are no necessary around numeric values, but they aren't wrong
> neither, simply optional.

Actually, I believe they are wrong in some database engines but not others.  
MySQL doesn't care.  Some others do.  Yes, it sucks. :-(

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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



Re: [PHP] Select record by ID

2007-01-28 Thread Francisco M. Marzoa Alonso
On dom, 2007-01-28 at 18:51 -0500, nitrox . wrote:
> I took the quotes off. I thought that quotes around numbers was wrong also. 

Quotes are no necessary around numeric values, but they aren't wrong
neither, simply optional.

> I added the error checking and this is the error:
> 
> Could not perform query : You have an error in your SQL syntax; check the 
> manual that corresponds to your MySQL server version for the right syntax to 
> use near '' at line 1

Try with the new code I sent you too see the query you're sending,
probably -but not sure- $user_id is void and you're doing:

SELECT * FROM inf_member WHERE user_id=

Anyway if you can see the query, you'll see the source of the error.

> 
> and this is the code again:
> 
>  include("db.php");
> $result = mysql_query("SELECT * FROM inf_member WHERE 
> user_id=$user_id");
> if ( ! $result ) {
>   die ("Could not perform query $query: ".mysql_error()."\n");
>   }
> 
>   while($myrow = mysql_fetch_assoc($result))
>   {
>  echo "";
>  echo $myrow['user_name'];
>  echo "";
>  echo $myrow['rank'];
>echo "";
>  echo $myrow['country'];
>echo "";
>  echo $myrow['email'];
>  echo "";
>  echo $myrow['quote'];
>  echo "";
>  echo $myrow['config'];
>echo "";
>echo $myrow['map'];
>  echo "";
>  echo $myrow['gun'];
>  echo "";
>  echo $myrow['brand'];
>echo "";
>echo $myrow['cpu'];
>echo "";
>  echo $myrow['ram'];
>  echo "";
>  echo $myrow['video'];
>  echo "";
>  echo $myrow['sound'];
>echo "";
>echo $myrow['monitor'];
>  echo "";
>  echo $myrow['mouse'];
>  echo "";
>  echo $myrow['brand'];
>echo "";
> 
>  }
> ?>
> 
> _
> Laugh, share and connect with Windows Live Messenger 
> http://clk.atdmt.com/MSN/go/msnnkwme002001msn/direct/01/?href=http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=hmtagline
> 


signature.asc
Description: This is a digitally signed message part


Re: [PHP] Select record by ID

2007-01-28 Thread Paul Novitski

At 1/28/2007 03:21 PM, nitrox . wrote:
Im trying to display one record at a time by ID. Well im getting a 
blank page. Ive looked over my code and tried 20 different ways to 
get it to work to no avail. So any pointers on what Im doing wrong 
would be great. here is the code im working with so far.


   $result = mysql_query("SELECT * FROM inf_member WHERE 
user_id='$user_id' ");

   while($myrow = mysql_fetch_assoc($result))
 {
echo "";
echo $myrow['user_name'];

...

My off-hand guess is that your user_id might be a numeric value 
(auto-increment?) and that putting it in quotes makes for an invalid query.


What is the value of $result?  If $result === false then display 
mysql_error() to diagnose the problem.


Regards,

Paul
__

Juniper Webcraft Ltd.
http://juniperwebcraft.com 


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



Re: [PHP] Select record by ID

2007-01-28 Thread Francisco M. Marzoa Alonso
Ops!, Better this one:

$query = "SELECT inf_member WHERE user_id='$user_id' ";
$result = mysql_query($query);
if ( ! $result ) {
die ("Could not perform query $query: ".mysql_error()."\n");
}

I did copy and paste from my own code and you've not $query defined on
your one. I prefer to store first the query on a string to show it
complete if there's an error late, because it may show also the point.



On lun, 2007-01-29 at 00:39 +0100, Francisco M. Marzoa Alonso wrote:
> The first thing that I probably do is to check for possible errors from
> DB:
> 
> $result = mysql_query("SELECT  inf_member WHERE
> user_id='$user_id' ");
>   if ( ! $result ) {
>   die ("Could not perform query $query: ".mysql_error()."\n");
>   }
> 
> Regards,
> 
> 
> On dom, 2007-01-28 at 18:21 -0500, nitrox . wrote:
> > Before I ask my next question I just wanted to thank you all for being in 
> > this mailing community and sharing your knowledge. Its communitys like this 
> > that make life easier for all of us. Ok enough with the mushy stuff
> > 
> > Im trying to display one record at a time by ID. Well im getting a blank 
> > page. Ive looked over my code and tried 20 different ways to get it to work 
> > to no avail. So any pointers on what Im doing wrong would be great. here is 
> > the code im working with so far.
> > 
> >  > include("db.php");
> > 
> > $result = mysql_query("SELECT * FROM inf_member WHERE 
> > user_id='$user_id' ");
> > while($myrow = mysql_fetch_assoc($result))
> >   {
> >  echo "";
> >  echo $myrow['user_name'];
> >  echo "";
> >  echo $myrow['rank'];
> >  echo "";
> >  echo $myrow['country'];
> >  echo "";
> >  echo $myrow['email'];
> >  echo "";
> >  echo $myrow['quote'];
> >  echo "";
> >  echo $myrow['config'];
> >  echo "";
> >  echo $myrow['map'];
> >  echo "";
> >  echo $myrow['gun'];
> >  echo "";
> >  echo $myrow['brand'];
> >  echo "";
> >  echo $myrow['cpu'];
> >  echo "";
> >  echo $myrow['ram'];
> >  echo "";
> >  echo $myrow['video'];
> >  echo "";
> >  echo $myrow['sound'];
> >  echo "";
> >  echo $myrow['monitor'];
> >  echo "";
> >  echo $myrow['mouse'];
> >  echo "";
> >  echo $myrow['brand'];
> >  echo "";
> > 
> >  }
> > ?>
> > 
> > _
> > FREE online classifieds from Windows Live Expo – buy and sell with people 
> > you know 
> > http://clk.atdmt.com/MSN/go/msnnkwex001001msn/direct/01/?href=http://expo.live.com?s_cid=Hotmail_tagline_12/06
> > 


signature.asc
Description: This is a digitally signed message part


Re: [PHP] Select record by ID

2007-01-28 Thread nitrox .
I took the quotes off. I thought that quotes around numbers was wrong also. 
I added the error checking and this is the error:


Could not perform query : You have an error in your SQL syntax; check the 
manual that corresponds to your MySQL server version for the right syntax to 
use near '' at line 1


and this is the code again:

   $result = mysql_query("SELECT * FROM inf_member WHERE 
user_id=$user_id");

   if ( ! $result ) {
die ("Could not perform query $query: ".mysql_error()."\n");
}

while($myrow = mysql_fetch_assoc($result))
 {
echo "";
echo $myrow['user_name'];
echo "";
echo $myrow['rank'];
 echo "";
echo $myrow['country'];
 echo "";
echo $myrow['email'];
echo "";
echo $myrow['quote'];
echo "";
echo $myrow['config'];
 echo "";
 echo $myrow['map'];
echo "";
echo $myrow['gun'];
echo "";
echo $myrow['brand'];
 echo "";
 echo $myrow['cpu'];
 echo "";
echo $myrow['ram'];
echo "";
echo $myrow['video'];
echo "";
echo $myrow['sound'];
 echo "";
 echo $myrow['monitor'];
echo "";
echo $myrow['mouse'];
echo "";
echo $myrow['brand'];
 echo "";

}
?>

_
Laugh, share and connect with Windows Live Messenger 
http://clk.atdmt.com/MSN/go/msnnkwme002001msn/direct/01/?href=http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=hmtagline


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



Re: [PHP] Select record by ID

2007-01-28 Thread Francisco M. Marzoa Alonso
The first thing that I probably do is to check for possible errors from
DB:

$result = mysql_query("SELECT * FROM inf_member WHERE
user_id='$user_id' ");
if ( ! $result ) {
die ("Could not perform query $query: ".mysql_error()."\n");
}

Regards,


On dom, 2007-01-28 at 18:21 -0500, nitrox . wrote:
> Before I ask my next question I just wanted to thank you all for being in 
> this mailing community and sharing your knowledge. Its communitys like this 
> that make life easier for all of us. Ok enough with the mushy stuff
> 
> Im trying to display one record at a time by ID. Well im getting a blank 
> page. Ive looked over my code and tried 20 different ways to get it to work 
> to no avail. So any pointers on what Im doing wrong would be great. here is 
> the code im working with so far.
> 
>  include("db.php");
> 
> $result = mysql_query("SELECT * FROM inf_member WHERE 
> user_id='$user_id' ");
> while($myrow = mysql_fetch_assoc($result))
>   {
>  echo "";
>  echo $myrow['user_name'];
>  echo "";
>  echo $myrow['rank'];
>echo "";
>  echo $myrow['country'];
>echo "";
>  echo $myrow['email'];
>  echo "";
>  echo $myrow['quote'];
>  echo "";
>  echo $myrow['config'];
>echo "";
>echo $myrow['map'];
>  echo "";
>  echo $myrow['gun'];
>  echo "";
>  echo $myrow['brand'];
>echo "";
>echo $myrow['cpu'];
>echo "";
>  echo $myrow['ram'];
>  echo "";
>  echo $myrow['video'];
>  echo "";
>  echo $myrow['sound'];
>echo "";
>echo $myrow['monitor'];
>  echo "";
>  echo $myrow['mouse'];
>  echo "";
>  echo $myrow['brand'];
>echo "";
> 
>  }
> ?>
> 
> _
> FREE online classifieds from Windows Live Expo – buy and sell with people 
> you know 
> http://clk.atdmt.com/MSN/go/msnnkwex001001msn/direct/01/?href=http://expo.live.com?s_cid=Hotmail_tagline_12/06
> 


signature.asc
Description: This is a digitally signed message part


Re: [PHP] Select two table with DB_DataObject

2006-11-24 Thread Yves Tannier

2006/11/24, Richard Lynch <[EMAIL PROTECTED]>:


On Fri, November 24, 2006 10:27 am, Yves Tannier wrote:
> First, sorry for my bad english ;)
>
> I'm looking for a simple way to provide query with two table like this
> :
>
> SELECT t1.idperson, t1.lastname FROM table1 t1, table2 t2 WHERE
> t1.idperson=t2.idperson AND t1.idperson=2
>
> I try with joinAdd and selectAs but its always complexe query like :
>
> SELECT t1.idperson, t1.lastname FROM table1 t1 INNER JOIN table2 t2
> ect...
>
> I can't use query() method because I need to use find() method after
> (orderBy, Pager, limit ect...)

I'm not quite sure what DB_DataObject is, or where it comes from...

But wherever that software came from, there is probably a better
list/forum/space to ask this, if nobody here answers.



So sorry. It's a mistake ;)

I've subcribe on php-general@lists.php.net but not on
[EMAIL PROTECTED]

DB_DataObject is a pear package.

bye.
Yves


<[EMAIL PROTECTED]>


Re: [PHP] Select two table with DB_DataObject

2006-11-24 Thread Richard Lynch
On Fri, November 24, 2006 10:27 am, Yves Tannier wrote:
> First, sorry for my bad english ;)
>
> I'm looking for a simple way to provide query with two table like this
> :
>
> SELECT t1.idperson, t1.lastname FROM table1 t1, table2 t2 WHERE
> t1.idperson=t2.idperson AND t1.idperson=2
>
> I try with joinAdd and selectAs but its always complexe query like :
>
> SELECT t1.idperson, t1.lastname FROM table1 t1 INNER JOIN table2 t2
> ect...
>
> I can't use query() method because I need to use find() method after
> (orderBy, Pager, limit ect...)

I'm not quite sure what DB_DataObject is, or where it comes from...

But wherever that software came from, there is probably a better
list/forum/space to ask this, if nobody here answers.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] select colum in array.

2006-08-18 Thread Adam Zey

Richard Lynch wrote:

On Thu, August 17, 2006 9:02 am, João Cândido de Souza Neto wrote:

I´m not sure if it´s the right place to get such answer, but if
someone
know, please, help me.

In a select id,name,picture1,picture2,picture3 from product where
id="10" i
get an array with each colum in each element like this $result ("id"
=>
"10", "name" => "name of product", "picture1" => "pic1.gif",
"picture2" =>
"pic2.gif", "picture3" => "pic3.gif").

Is there any way in select to get something like this:

$result ("id" => "10", "name" => "name of product", "pictures" =>
array(
"pic1" => "pic1.gif", "pic2" => "pic2.gif", "pic3" => "pic3.gif") ).


If your database (MySQL? PostgreSQL? SQL Server? Oracle? Sybase?
Informix? DB?) has an array datatype, or, I guess, any datatype that
gets mapped to an array by the database-client + PHP implementation,
then, in theory, you could compose a SELECT that would "work" for that
particular database...

You'd be better off, however, to munge the data in your PHP, in my
opinion as that will be much more portable, and unless you are getting
thousands of rows at once, not much slower.

These functions will be very useful:
http://php.net/array_slice
http://php.net/array_splice

I think this is correct for your example:
$pictures = array_slice($result, 3);
$results = array_splice($result, 3, 3, $pictures);

The first line grabs everyting from the 3rd element on (the 3 pictures)

The second line replaces everything from element 3 through 6 (the
second 3 is a length parameter) with your new array.


I must say, I'm of the opinion that as much data processing should be 
done in the database server possible. For one thing, munging data in PHP 
means you MUST have a complete copy of the result set in memory, instead 
of processing it row by row. PHP's 8MB memory limit can sometimes pose a 
problem if that munging involves several copies of the data floating around.


Further, database servers are, in my opinion, easier to distribute than 
web servers if load is an issue. While your single script could easily 
connect properly to a database cluster, distributing the PHP scripts 
involves somehow getting the client to the right one, either by 
roundrobin DNS, or some sort of redirection mechanism.


I also tend to think that the database would be faster. Perhaps the PHP 
script would only a few milliseconds longer than the database to process 
the data, but when you have multiple requests per second, those few 
milliseconds can REALLY add up. I'd rather spend the processor time on 
the webserver gzipping the data as it goes out. Of course, I have no 
benchmarks telling me that PHP would be slower than a database server 
for messing with data, I'm just making an assumption.


Regards, Adam.

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



Re: [PHP] select colum in array.

2006-08-18 Thread Richard Lynch
On Fri, August 18, 2006 1:32 pm, Adam Zey wrote:
> I must say, I'm of the opinion that as much data processing should be
> done in the database server possible.

I agree with you 100% in principle...

But in this case, we're talking about structuring the data in a
PHP-specific data structure for easier application development.

Last I checked, SQL has not yet Standardized on an Array datatype,
much less all the major players actually IMPLEMENTED that Standard...

If you didn't detect the dripping sarcasm laden in the preceding
sentence, you haven't looked at SQL Standards versus actual
implementation much... :-)

> For one thing, munging data in
> PHP
> means you MUST have a complete copy of the result set in memory,
> instead
> of processing it row by row.

No, no, no.

We're just re-arranging the elements of the same result set from a 1-D
array into a nested array!

We're certainly not snarfing down the whole table and letting PHP sort
it out!

> PHP's 8MB memory limit can sometimes pose
> a
> problem if that munging involves several copies of the data floating
> around.

Yes -- But if you are loading in enough elements of a result set that
the difference between the $result and the spliced $result matters,
then you've got problems already.

Also, the default 8M went up to 16M yesterday in 5.2.0RC2 and 6.0.*
because you can't even [mumble mumble install PECL? mumble mumble]
with 8M...

At any rate, you're not quite envisioning the right thing here...

> Further, database servers are, in my opinion, easier to distribute
> than
> web servers if load is an issue. While your single script could easily
> connect properly to a database cluster, distributing the PHP scripts
> involves somehow getting the client to the right one, either by
> roundrobin DNS, or some sort of redirection mechanism.

Actually, in this case, I'm pretty sure we're not looking at an N-tier
architecture...

If we are, you'd have to rsync the PHP scripts, but that's about it.

There's no heavy lifting going on in PHP -- Just splicing an extra
array super-structure into part of an existing single result row.

BEFORE:
$result = mysql_fetch_row();

AFTER:
$result = mysql_fetch_row();
$pictures = array_slice($result, 3);
$result = array_splice($result, 3, 3, $pictures);

I suppose you could unset($pictures) to free up a single array of 3
strings, if you want to get real anal about the RAM...

> I also tend to think that the database would be faster. Perhaps the
> PHP
> script would only a few milliseconds longer than the database to
> process
> the data, but when you have multiple requests per second, those few
> milliseconds can REALLY add up. I'd rather spend the processor time on
> the webserver gzipping the data as it goes out. Of course, I have no
> benchmarks telling me that PHP would be slower than a database server
> for messing with data, I'm just making an assumption.

Your assumption is correct, in general.

The DB should do any FILTERING / SORTING of large-scale data.

But there's no way you're going to construct a SELECT query to get
back an array of SOME fields from a single row pre-populated in PHP
that will work across SQL platforms, and even if you get it to work in
one specific DB, it's going to be a close call as to whether there's
any savings at all in the DB building an array so that PHP can detect
that array and build that array in C, and a couple calls to
array_s[p]lice to build that array in PHP code.

NOTE:
The issue of having 3 fields named 'picture1', 'picture2', and
'picture3' being a sure indicator of a badly-designed
not-so-relational database schema is being completely ignored here,
until now... :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] select colum in array.

2006-08-18 Thread Richard Lynch
On Thu, August 17, 2006 9:02 am, João Cândido de Souza Neto wrote:
> I´m not sure if it´s the right place to get such answer, but if
> someone
> know, please, help me.
>
> In a select id,name,picture1,picture2,picture3 from product where
> id="10" i
> get an array with each colum in each element like this $result ("id"
> =>
> "10", "name" => "name of product", "picture1" => "pic1.gif",
> "picture2" =>
> "pic2.gif", "picture3" => "pic3.gif").
>
> Is there any way in select to get something like this:
>
> $result ("id" => "10", "name" => "name of product", "pictures" =>
> array(
> "pic1" => "pic1.gif", "pic2" => "pic2.gif", "pic3" => "pic3.gif") ).

If your database (MySQL? PostgreSQL? SQL Server? Oracle? Sybase?
Informix? DB?) has an array datatype, or, I guess, any datatype that
gets mapped to an array by the database-client + PHP implementation,
then, in theory, you could compose a SELECT that would "work" for that
particular database...

You'd be better off, however, to munge the data in your PHP, in my
opinion as that will be much more portable, and unless you are getting
thousands of rows at once, not much slower.

These functions will be very useful:
http://php.net/array_slice
http://php.net/array_splice

I think this is correct for your example:
$pictures = array_slice($result, 3);
$results = array_splice($result, 3, 3, $pictures);

The first line grabs everyting from the 3rd element on (the 3 pictures)

The second line replaces everything from element 3 through 6 (the
second 3 is a length parameter) with your new array.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] select colum in array.

2006-08-18 Thread John Nichel

Adam Zey wrote:

I must say


So you've said.  Three times now.  ;)

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] select colum in array.

2006-08-17 Thread Robert Cummings
On Thu, 2006-08-17 at 11:02 -0300, João Cândido de Souza Neto wrote:
> Hi everyone,
> 
> Im not sure if its the right place to get such answer, but if someone 
> know, please, help me.
> 
> In a select id,name,picture1,picture2,picture3 from product where id="10" i 
> get an array with each colum in each element like this $result ("id" => 
> "10", "name" => "name of product", "picture1" => "pic1.gif", "picture2" => 
> "pic2.gif", "picture3" => "pic3.gif").
> 
> Is there any way in select to get something like this:
> 
> $result ("id" => "10", "name" => "name of product", "pictures" => array( 
> "pic1" => "pic1.gif", "pic2" => "pic2.gif", "pic3" => "pic3.gif") ).

Not via the select. But it's like 2 lines of code to stuff it into a sub
array when handling the result set.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] select tag doesn't update post or get

2006-08-08 Thread Jochem Maas
Roel Dillen wrote:
> I have a xhtml form with a  with options
> 
> if I click submit the processing page is loaded and the result of the form is
> shown. 
> The option given to the processing page however is always the same: the first
> in the list. It doesn't matter what I select in the drop down menu, the value
> of $_POST['nameOfSelectTag'] (or get for that matter) never differs from the
> first value in the drop down list. I don't use a default selected value
> because the  tag values are dependent on the contents of a certain
> table in my database.
> 
> The weird thing is that in get mode the field nameOfSelectTag does take the
> right value in the adress bar but that doesn't get translated into the correct
> value in $_GET so i am thinking the same happens in $_POST.

sounds like you have another field also named 'nameOfSelectTag', probably
near the bottom of your form.

> 
> Ideas anyone
> 
> Roel
> 
> --
> Scarlet Club: Iedereen wint! Indien u nu klant wordt van Scarlet via een 
> bestaande Scarlet klant kunnen jullie beide cadeaucheques ontvangen ter 
> waarde van 50 euro! Bezoek snel http://www.scarletclub.be
> 

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



Re: [PHP] select option and php

2006-07-25 Thread Jochem Maas
weetat wrote:
> Hi Jay ,
> 
>I am not in the javascript group.

'the javascript group' ??

>   document.forms['listfrm'].submit;

document.forms['listfrm'].submit();

^^--- i.e. actually call the method

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



Re: [PHP] select option and php

2006-07-24 Thread weetat

Hi Jay ,

   I am not in the javascript group.
   Btw , i have added document.forms['listfrm'].pageid.value in the 
page , but the form is not submitted ?


  var pageid = document.forms['listfrm'].pageid.value;
  var urlpath = "../listflag.php?start=&pageID="+pageid;

  document.forms['listfrm'].method = 'post';  --> did not submit form 
at all

  document.forms['listfrm'].action = urlpath;
  document.forms['listfrm'].submit;

Any ideas why ? How to submit form when user change value in the select 
tag ?


Thanks


Jay Blanchard wrote:

[snip]
It will produce the html tag as shown below:

function gotoPage(){

  var urlpath = "../listflag.php?start=&pageID="+3;
  document.forms['listfrm'].method = 'post';
  document.forms['listfrm'].action = urlpath;
  document.forms['listfrm'].submit;

}



Go to Page:onchange="javascript:gotoPage()">

1
2
3
4
5
 
   


I tried using onchange in the select tag,but it did not work. It go to 
the javascript but the form is not submitted .


Anyideas why?
[/snip]

In gotoPage() you're not referencing the value of pageid
(document.forms['listfrm'].pageid.value). More of a JavaScript question,
are you a member of a JavaScript list?


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



RE: [PHP] select option and php

2006-07-24 Thread Jay Blanchard
[snip]
It will produce the html tag as shown below:

function gotoPage(){

  var urlpath = "../listflag.php?start=&pageID="+3;
  document.forms['listfrm'].method = 'post';
  document.forms['listfrm'].action = urlpath;
  document.forms['listfrm'].submit;

}



Go to Page:
1
2
3
4
5
   
 


I tried using onchange in the select tag,but it did not work. It go to 
the javascript but the form is not submitted .

Anyideas why?
[/snip]

In gotoPage() you're not referencing the value of pageid
(document.forms['listfrm'].pageid.value). More of a JavaScript question,
are you a member of a JavaScript list?

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



Re: [PHP] SELECT?

2005-12-30 Thread Paul Waring
On 12/30/05, Richard Lynch <[EMAIL PROTECTED]> wrote:
> The suggestions so far are good, but watch out for this:
>
> If you do one record at a time, and are using LIMIT, and then
> something gets inserted into the original table...
>
> Boom!

You could always lock the tables whilst performing the update - not
very useful if the database has to be up all the time but it's
probably the safest way of doing it.

Paul

--
Data Circle
http://datacircle.org

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



Re: [PHP] SELECT?

2005-12-30 Thread Richard Lynch
On Wed, December 28, 2005 2:50 am, William Stokes wrote:
> I have one MySQL table with about 500 rows. I need to read the table
> one row
> at a
> time, make some changes to data in one field and then store the
> changed data
> to another table.
>
> I'm using PHP to change the data but I have no idea how to select one
> row at
> a time from the DB table. There's one auto-increment id field in the
> table
> but the id's doesn't start from 1 and are not sequential.

The suggestions so far are good, but watch out for this:

If you do one record at a time, and are using LIMIT, and then
something gets inserted into the original table...

Boom!

Ordering by the auto_increment will "work" to make sure the new rows
are at the end, but that's kind of icky to rely on in production code.

Your best bet probably is to just get all 500 records and process them
in one batch.

After that, adding a column to mark records "done" or not is good.

Relying solely on LIMIT and auto_increment is only okay for a quick
one-time hack you'll never need again...  And still kind of icky.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] SELECT?

2005-12-28 Thread Zareef Ahmed
Hi,

As there are only 500 rows, there is not any harm in fetching all
records through one query and then do the update between while loop


$query="select * from table";
$result=mysql_query($query);

while($row=mysql_fetch_array($result))
{
$newquery="update YOUR STATEMENT where uniquefield like
$row['uniquefield']";
mysql_query($newquery);
}


if you really need to fetch only one record at a time, you can use the LIMIT
keyword in your SQL statement, and can create the script as needed.


Zareef Ahmed

- Original Message - 
From: "Christian Ista" <[EMAIL PROTECTED]>
To: "'William Stokes'" <[EMAIL PROTECTED]>; 
Sent: Wednesday, December 28, 2005 3:57 AM
Subject: RE: [PHP] SELECT?


> > From: William Stokes [mailto:[EMAIL PROTECTED]
> > I have one MySQL table with about 500 rows. I need to read the table one
> > row at a time, make some changes to data in one field and then store the
> > changed data to another table.
>
> 1. May be add a column, CHANGED_FL with default value N.
> 2. Select to find the ID minimum with a select CHANGED_FL is N
> 3. Select the row with the ID found above and make you business
> 4. Make change and change CHANGED_FL to Y
>
> Repeat operation 2 to 4
>
> C.
>



PHP Expert Consultancy in Development  http://www.indiaphp.com
Yahoo! : consultant_php MSN : [EMAIL PROTECTED]

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

2005-12-28 Thread Paul Waring
On 12/28/05, William Stokes <[EMAIL PROTECTED]> wrote:
> I have one MySQL table with about 500 rows. I need to read the table one row
> at a
> time, make some changes to data in one field and then store the changed data
> to another table.
>
> I'm using PHP to change the data but I have no idea how to select one row at
> a time from the DB table. There's one auto-increment id field in the table
> but the id's doesn't start from 1 and are not sequential.
>
> Any ideas or help is much appreciated!

Can you not just fetch all the data at once like so:

$result = mysql_query("SELECT * FROM mytable");

then iterate over the results:

while ( $row = mysql_fetch_assoc($result) )
{
mysql_query("INSERT INTO othertable (column1) VALUES (" .
$row['column_x'] . ");
}

The only thing you'd have to be careful with is the maximum execution
time settings if you're running this script over the web, as opposed
to on the command line. If you're only making changes to 500 rows
though it shouldn't take too long - I've restored thousands of rows to
a database before and that took less than a second.

Paul

--
Data Circle
http://datacircle.org

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



Re: [PHP] SELECT?

2005-12-28 Thread Max Schwanekamp

William Stokes wrote:
I have one MySQL table with about 500 rows. I need to read the table one row 
at a

time, make some changes to data in one field and then store the changed data
to another table.
I'm using PHP to change the data but I have no idea how to select one row at
a time from the DB table.


A couple of possible options, depending on your specific situation:
1. Use INSERT...SELECT syntax.  If you're doing a regular transformation 
on all selected rows that can be handled by MySQL function(s), this 
would be easiest and fastest.  e.g. (table_b.id is an auto-incremented 
primary key):

INSERT INTO table_b (id, table_a_id, transformed_value)
SELECT NULL, id, SOME_FUNCTION(mycolumn)
FROM table_a

2. Depending on the size of the records, you might want to just read all 
500 rows into a two-dimensional array and use an array fn such as 
array_walk to apply a function to change the relevant data and insert 
into your new table.  To get all rows into an array, you set an array 
variable and iterate over the MySQL result set to build the members of 
the array.


If you need details on how to do *that*, you'll need to indicate which 
version of PHP you're using and whether you're using an abstraction 
layer for database access.  For an example in PHP 4, you might have:

$db_cursor = mysql_query("SELECT * FROM my_table", $db);
//check for errors [omitted]
//count the records
$recordcount = mysql_num_rows($db_cursor);
//assemble the recordset array
$recordset = array();
for($i=0;$i<$recordcount; $i++)
{
$recordset[] = mysql_fetch_assoc($db_cursor);   
}
//clean up, etc. [omitted]

Then use array_walk() or similar...

HTH

--
Max Schwanekamp
http://www.neptunewebworks.com/

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



RE: [PHP] SELECT?

2005-12-28 Thread Christian Ista
> From: William Stokes [mailto:[EMAIL PROTECTED]
> I have one MySQL table with about 500 rows. I need to read the table one
> row at a time, make some changes to data in one field and then store the 
> changed data to another table.

1. May be add a column, CHANGED_FL with default value N.
2. Select to find the ID minimum with a select CHANGED_FL is N
3. Select the row with the ID found above and make you business
4. Make change and change CHANGED_FL to Y

Repeat operation 2 to 4 

C.

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



Re: [PHP] select statement with variables ???

2005-12-21 Thread Jochem Maas

Jay Blanchard wrote:

[snip]

Jay how come you though concating would give
a different result to interpolation?

[/snip]

It is not really a different result, it is just something that I am in the
habit of doing. The "concat or not to concat" question has fueled many a
holy war. I concat, others do not. I am used to seeing it and looking for it
in code. Others think that it adds too much junk.


I see - personally I don't give a  about this holy war; I use both
pretty interchangably - depends on the context what I think looks neater.


it is my believe the technically this:

echo $a, $b, $c;

is (should be) faster than:

echo $a . $b . $c;

can anyone confirm this to be true?




[snip]


My bet is that you need to concatenate



...I don't agree that concat'ing will help...
[/snip]

I probably shouldn't have used "bet"...I just should have suggested it.


I still stand by the fact that whether you bet or suggest the OP would end up
with the same broken query string.

now the hint about using ECHO .. that you could have written in 40 foot high 
letters :-)





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



RE: [PHP] select statement with variables ???

2005-12-21 Thread Jay Blanchard
[snip]

Jay how come you though concating would give
a different result to interpolation?

[/snip]

It is not really a different result, it is just something that I am in the
habit of doing. The "concat or not to concat" question has fueled many a
holy war. I concat, others do not. I am used to seeing it and looking for it
in code. Others think that it adds too much junk.

[snip]
> My bet is that you need to concatenate

...I don't agree that concat'ing will help...
[/snip]

I probably shouldn't have used "bet"...I just should have suggested it.

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



Re: [PHP] select statement with variables ???

2005-12-21 Thread Jochem Maas


Jay how come you though concating would give
a different result to interpolation?


Jay Blanchard wrote:

[snip]


$query=" SELECT title FROM $cat WHERE id='$id'";


[/snip]

echo $query; // does it look right to you?
Alway throw an error when in question

if(!($result = mysql_query($query, $connection))){
   echo mysql_error() . "\n";
   exit();
}



up to here I agree with Jay 100%, especially the 'echo' part (also get
familiar with var_dump() and print_r() functions to help debug your problems...


My bet is that you need to concatenate

$query = "SELECT title FROM " . $cat . " WHERE id = '". $id ."' ";


now unless either $cat or $id is actually an object with a 'magic'
__toString() method defined and the engine has been changed to fully/properly
support 'magic' object2string casting I don't agree that concat'ing will help
(even all of what I sAid was true I don't think it would help either),
the reaosn being that AFAICT the following 2 statements leave you with the same
string:


$cat = "mytable";
$id  = 1234;
$one = "SELECT title FROM $cat WHERE id='$id'";
$two = "SELECT title FROM ".$cat." WHERE id = '".$id."'";

var_dump( ($one === $two) ); // <-- will show you that this equates to TRUE.

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



  1   2   3   >