Re: [PHP] Re: SELECT data base on a upper level SELECT

2013-08-01 Thread jomali
On Thu, Aug 1, 2013 at 6:33 PM, iccsi  wrote:

> Thanks for the information and help,
> The query can solve server side, but client side, user might select any
> one dropdown, for example, user might select manager from drop down without
> choose Department dropdown.
>
> For this case, application needs inject data for supervisor and lower
> level,
>

No, simply prevent client from submitting form until all required fields
are filled in. (A blindingly simple procedure).

>
> Thanks again for helping,
>
> Regards,
>
> Iccsi,
>
> "Jim Giner"  wrote in message news:8C.41.29774.C0E5AF15@pb1.**pair.com...
>
> On 7/31/2013 9:37 PM, iccsi wrote:
>
>> I have 5 SELECT for Department, Manager, supervisor, Group Leader and
>> Employees
>> I want to every SELECT list narrow down for an upper SELECT.
>> For example, once user select Department then all Manager, Supervisor,
>> Group Leader and Employee list will be narrow down by department and
>> same for manager and supervisor and so on.
>>
>> I can use iframe or jQuery to do every level, but it needs to call
>> iframe or jQuery to 5 levels.
>> I would like to know are there any better way to handle this situation,
>>
>> Your help and information is great appreciated,
>>
>> Regards,
>>
>>
>> Iccsi,
>>
>>  How about using just one select and add variables to the where clause?
> Set the variable(s) to the values that you want to filter on.
>
> For ex.:
>
> your query is
> $sel = 1;
> $q = "select Department, Manager, supervisor, Group Leader,Employees
> where $sel";
>
> Then when the user selects a department $d:
>
> $sel = "Department = '$d'";
>
> OR if you have selected a department $d and a manager $m:
>
> $sel = "Department ='$d' and Manager='$m'";
>
> One query.  A variable 'where' clause.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] Re: SELECT data base on a upper level SELECT

2013-08-01 Thread iccsi

Thanks for the information and help,
The query can solve server side, but client side, user might select any one 
dropdown, for example, user might select manager from drop down without 
choose Department dropdown.


For this case, application needs inject data for supervisor and lower level,

Thanks again for helping,

Regards,

Iccsi,

"Jim Giner"  wrote in message news:8c.41.29774.c0e5a...@pb1.pair.com...

On 7/31/2013 9:37 PM, iccsi wrote:

I have 5 SELECT for Department, Manager, supervisor, Group Leader and
Employees
I want to every SELECT list narrow down for an upper SELECT.
For example, once user select Department then all Manager, Supervisor,
Group Leader and Employee list will be narrow down by department and
same for manager and supervisor and so on.

I can use iframe or jQuery to do every level, but it needs to call
iframe or jQuery to 5 levels.
I would like to know are there any better way to handle this situation,

Your help and information is great appreciated,

Regards,


Iccsi,


How about using just one select and add variables to the where clause?
Set the variable(s) to the values that you want to filter on.

For ex.:

your query is
$sel = 1;
$q = "select Department, Manager, supervisor, Group Leader,Employees
where $sel";

Then when the user selects a department $d:

$sel = "Department = '$d'";

OR if you have selected a department $d and a manager $m:

$sel = "Department ='$d' and Manager='$m'";

One query.  A variable 'where' clause. 



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



[PHP] Re: SELECT data base on a upper level SELECT

2013-08-01 Thread Jim Giner

On 7/31/2013 9:37 PM, iccsi wrote:

I have 5 SELECT for Department, Manager, supervisor, Group Leader and
Employees
I want to every SELECT list narrow down for an upper SELECT.
For example, once user select Department then all Manager, Supervisor,
Group Leader and Employee list will be narrow down by department and
same for manager and supervisor and so on.

I can use iframe or jQuery to do every level, but it needs to call
iframe or jQuery to 5 levels.
I would like to know are there any better way to handle this situation,

Your help and information is great appreciated,

Regards,


Iccsi,

How about using just one select and add variables to the where clause? 
Set the variable(s) to the values that you want to filter on.


For ex.:

your query is
$sel = 1;
$q = "select Department, Manager, supervisor, Group Leader,Employees 
where $sel";


Then when the user selects a department $d:

$sel = "Department = '$d'";

OR if you have selected a department $d and a manager $m:

$sel = "Department ='$d' and Manager='$m'";

One query.  A variable 'where' clause.

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



[PHP] Re: select colum in array.

2006-08-17 Thread Jo�o C�ndido de Souza Neto
I found another solution myself.

Thanks four your answer Robert.

""João Cândido de Souza Neto"" <[EMAIL PROTECTED]> escreveu na 
mensagem news:[EMAIL PROTECTED]
> Hi everyone,
>
> 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") ).
>
>
> -- 
> João Cândido de Souza Neto
> Curitiba Online
> [EMAIL PROTECTED]
> (41) 3324-2294 (41) 9985-6894
> http://www.curitibaonline.com.br 

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



Re: [PHP] Re: Select and $_POST

2005-11-11 Thread GamblerZG

Curt Zirzow wrote:

There is a pecl extension that you can register, custom
superglobals although it comes with some extra stuff as well:
  http://php.net/runkit


I wish it would be a part of core distribution. Would be extremely useful.

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



Re: [PHP] Re: Select and $_POST

2005-11-10 Thread Curt Zirzow
On Thu, Nov 10, 2005 at 05:21:51PM -0500, Ben Ramsey wrote:
> On 11/10/05 4:48 PM, Richard Lynch wrote:
> >Here's an idea...  Quite possibly half-baked.
> >
> >Suppose PHP had a superglobal $_CLEAN which was an empty array.
> >
> >Further suppose it was documented in the manual as *the* place to put
> >your scrubbed data.
> >
> >This rather small and hopefully inexpensive change (in terms of PHP
> >Dev/Docs team work) would quite possibly improve scripts by newbies,
> >simply by nudging them in the proper direction, because it would be a
> >documented feature, and it would have all the nifty cross-links in the
> >manual and all that.
> >
> >It would also help to keep code cleaner to have $_CLEAN be a
> >superglobal rather than just something I made up and have to declare
> >as "global" all the time.
> >
> >Comments?  Suggestions?  Derogatory remarks?
> 
> There is an Input Filter PECL extension that's still in beta, and I 
> think it's a good step, though I'm not so sure about some of the 
> sanitizing it performs. It doesn't offer the superglobal you're 
> suggesting, but it probably wouldn't be too difficult to put it in there.

There is a pecl extension that you can register, custom
superglobals although it comes with some extra stuff as well:
  http://php.net/runkit

 
> The only issue I see with building in a superglobal to the language (or 
> this extension) is that it doesn't force the user to instantiate the 
> empty array at the top of the script. This could make for a lazy 
> developer, and, if s/he's not careful, anyone running the application on 
> a machine in which register_globals is turned on would run the risk of 
> having a potentially tainted $_CLEAN array, which defeats the purpose of 
> the clean array altogether. The point is that the developer should be 
> able to trust the data in $clean.

I think the idea would be that $_CLEAN is protected from anything
but your own code assigning a value to it, and will always be an
empty array.  I'm not sure that will stop anyone from abusing  it
and just stick $_REQUEST['password'] into the array without really
cleaning it.

The other issue with having a system variable like this, is if i
choose to not use it, perhaps i have a different method of
sanitizing my input,  the variable just becomes an empty useless
item.

> 
> If PHP had a taint mode and didn't have register_globals, then we'd be 
> making some progress.

hmm.. an E_TAINTED error, that might be something good to have put
in php6, since register_globals appears to be going away then.  I
could forsee some though code like this though:

  array_walk_recursive($_REQUEST, create_function('&$v,$k', '$v = $k'));


Curt.
-- 

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



Re: [PHP] Re: Select and $_POST

2005-11-10 Thread Richard Lynch
On Thu, November 10, 2005 4:21 pm, Ben Ramsey wrote:
> On 11/10/05 4:48 PM, Richard Lynch wrote:
> The only issue I see with building in a superglobal to the language
> (or
> this extension) is that it doesn't force the user to instantiate the
> empty array at the top of the script. This could make for a lazy
> developer, and, if s/he's not careful, anyone running the application
> on
> a machine in which register_globals is turned on would run the risk of
> having a potentially tainted $_CLEAN array, which defeats the purpose
> of
> the clean array altogether. The point is that the developer should be
> able to trust the data in $clean.

I specifically stated the $_CLEAN "was an empty array"

By that I meant that $_CLEAN is initialized (by PHP core code) to be
an empty array, as part of the initialization routine that sets up
$_SERVER and sometimes $_POST/$_GET/$_COOKIE.

$_CLEAN would start as an empty array in all PHP setups (Module, CGI,
CLI, whatever) regardless of any other condition, pre-condition,
php.ini setting, or phase of the moon. :-)

--- unit test 

--

--- expected output --
array(0) {
}
--


I wouldn't be too keen on it being only done as part of some PECL
extension that may or may not get loaded, particularly as the order of
loading of PECL extensions then would have an effect, I should
think...

PS
The problem with any generic/modular Input Filtering is that one is
never too sure about some of the sanitizing it performs.

There are simply too many application-specific sanitization "gotchas"
that make this something that is almost always best re-written from
scratch each time, imho...

Not that you don't re-use and cut-and-paste, but maybe in this one
email  can be blank, but not in that one, or whatever.  Too many
variables, and I've never seen (and can't really imagine) a good clean
modular way to handle this without being so damn complex it's
unwieldy.

-- 
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] Re: Select and $_POST

2005-11-10 Thread Ben Ramsey

On 11/10/05 4:48 PM, Richard Lynch wrote:

Here's an idea...  Quite possibly half-baked.

Suppose PHP had a superglobal $_CLEAN which was an empty array.

Further suppose it was documented in the manual as *the* place to put
your scrubbed data.

This rather small and hopefully inexpensive change (in terms of PHP
Dev/Docs team work) would quite possibly improve scripts by newbies,
simply by nudging them in the proper direction, because it would be a
documented feature, and it would have all the nifty cross-links in the
manual and all that.

It would also help to keep code cleaner to have $_CLEAN be a
superglobal rather than just something I made up and have to declare
as "global" all the time.

Comments?  Suggestions?  Derogatory remarks?


There is an Input Filter PECL extension that's still in beta, and I 
think it's a good step, though I'm not so sure about some of the 
sanitizing it performs. It doesn't offer the superglobal you're 
suggesting, but it probably wouldn't be too difficult to put it in there.


The only issue I see with building in a superglobal to the language (or 
this extension) is that it doesn't force the user to instantiate the 
empty array at the top of the script. This could make for a lazy 
developer, and, if s/he's not careful, anyone running the application on 
a machine in which register_globals is turned on would run the risk of 
having a potentially tainted $_CLEAN array, which defeats the purpose of 
the clean array altogether. The point is that the developer should be 
able to trust the data in $clean.


If PHP had a taint mode and didn't have register_globals, then we'd be 
making some progress.


--
Ben Ramsey
http://benramsey.com/

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



Re: [PHP] Re: Select and $_POST

2005-11-10 Thread Richard Lynch
On Wed, November 9, 2005 7:15 pm, Chris Shiflett wrote:
> Ben Ramsey wrote:
>> $clean = array();
>> $sql   = array();

Here's an idea...  Quite possibly half-baked.

Suppose PHP had a superglobal $_CLEAN which was an empty array.

Further suppose it was documented in the manual as *the* place to put
your scrubbed data.

This rather small and hopefully inexpensive change (in terms of PHP
Dev/Docs team work) would quite possibly improve scripts by newbies,
simply by nudging them in the proper direction, because it would be a
documented feature, and it would have all the nifty cross-links in the
manual and all that.

It would also help to keep code cleaner to have $_CLEAN be a
superglobal rather than just something I made up and have to declare
as "global" all the time.

Comments?  Suggestions?  Derogatory remarks?

PS
What does Chris Shifflett use to validate an email?
Enquiring minds want to know!
:-)

-- 
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] Re: Select and $_POST

2005-11-10 Thread Chris Shiflett

M wrote:

$clean['pass'] = md5((ini_get('magic_quotes_gpc') ?
stripslashes($_POST['pass']) : $_POST['pass']));

or users with quotes in their password won't be able to log in.


This is best handled in one place, so that it's easier to maintain and 
less likely to be overlooked. In the examples provided, $_POST['pass'] 
is the password provided by the user.


Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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



Re: [PHP] Re: Select and $_POST

2005-11-10 Thread M

Chris Shiflett wrote:

Ben Ramsey wrote:


$clean = array();
$sql   = array();



Glad to see someone spreading this habit. :-) Thanks, Ben.


if (ctype_alnum($_POST['pass']))
{
$clean['pass'] = $_POST['pass'];
}



I think it's fine to cheat a bit with the password and trust the output 
format of md5():




$clean['pass'] = md5((ini_get('magic_quotes_gpc') ? 
stripslashes($_POST['pass']) : $_POST['pass']));


or users with quotes in their password won't be able to log in.


$clean['pass'] = md5($_POST['pass']);

Of course, it is best to use a salt:

$salt = 'SHIFLETT';
$clean['pass'] = md5($salt . md5($_POST['pass'] . $salt));

Chris



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



Re: [PHP] Re: Select and $_POST

2005-11-09 Thread Chris Shiflett

Ben Ramsey wrote:

$clean = array();
$sql   = array();


Glad to see someone spreading this habit. :-) Thanks, Ben.


if (ctype_alnum($_POST['pass']))
{
$clean['pass'] = $_POST['pass'];
}


I think it's fine to cheat a bit with the password and trust the output 
format of md5():


$clean['pass'] = md5($_POST['pass']);

Of course, it is best to use a salt:

$salt = 'SHIFLETT';
$clean['pass'] = md5($salt . md5($_POST['pass'] . $salt));

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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



[PHP] Re: Select and $_POST

2005-11-09 Thread Ben Ramsey

On 11/9/05 6:21 PM, Ross wrote:

What is the correct syntax for

$query = "SELECT * FROM login where username='$_POST['username']' AND pass 
='$_POST['pass']'";



Thought this would work.

R. 


The correct syntax in this case is actually:

$query = "SELECT * FROM login where username='{$_POST['username']}' AND 
pass='{$_POST['pass']}'";


Note the curly braces.

BUT! Never do this!

For example, consider if someone typed in their username like this:

foo' AND 1=1 --

The "--" in most database engines starts a comment, so the query would 
end up being:


SELECT * FROM login where username='foo' AND 1=1 --' AND pass=''

Everything after the "--" is ignored. There doesn't have to be a user 
named "foo" because 1 will always equal 1, so the user is instantly 
logged in.


Instead, filter your input (data received) and escape your output (in 
this case, data going to the database), and try something like this:


$query = "SELECT * FROM login where username='{$sql['username']}' AND 
pass='{$sql['pass']}'";


?>

Everything in $_POST should be treated as tainted data. Everything in 
$clean can be treated as valid and untainted. This ensures that the 
username and password received only contain values that you expect. You 
can modify the filtering to suit your needs. Then, it ensures that data 
sent to the database in the SQL statement is always escaped so that it 
doesn't try to do something it shouldn't.


This, of course, assumes you're using MySQL, but there are other 
escaping functions for other databases. Just look in the PHP manual.


--
Ben Ramsey
http://benramsey.com/

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



Re: [PHP] Re: select-option link list

2005-01-19 Thread Richard Morley
This should work




Please select a site to visit
http://www.google.com";>Google
http://www.yahoo.com";>Yahoo
http://www.microsoft.com";>MS





On Wed, 19 Jan 2005 22:23:52 +0100, Jochem Maas <[EMAIL PROTECTED]>  
wrote:

Ricky Morley wrote:
Like this. Here's the html code. I'm sure you can convert to the   
appropriate PHP

this is totally not PHP but...




shouldn't that be something like:

which is evil and crude, but does 2 things: uses the selectedIndex to  
get the value of the selection options and only sets the window location  
is the value if not empty.


http://www.google.com";>Google
http://www.yahoo.com";>Yahoo
http://www.microsoft.com";>MS




On Wed, 19 Jan 2005 20:10:25 +0200, William Stokes  
<[EMAIL PROTECTED]>  wrote:

Hello,
Hope someone can give some directions...
I'm trying to create a list box of links to other pages. I just can't   
figure
out how to move to the other page whe user selects one of the options  
in  the
list box.

here's the code...
$sql="SELECT team_name FROM teams";
$result=mysql_query($sql);
$num = mysql_num_rows($result);
$cur = 1;
print "";
print "";
while ($num >= $cur) {
$row = mysql_fetch_array($result);
$team_name = $row["team_name "];
print "$team_name ";
$cur++;
}
print "";
print "";
print "";

This propably can be don without the "Go" button. But i Don't know  
how...

Thank a lot
-Will
BTW thanks for the debugging stuff earlier. Got that workin...


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: select-option link list

2005-01-19 Thread Jochem Maas
Ricky Morley wrote:
Like this. Here's the html code. I'm sure you can convert to the  
appropriate PHP

this is totally not PHP but...




shouldn't that be something like:

which is evil and crude, but does 2 things: uses the selectedIndex to 
get the value of the selection options and only sets the window location 
is the value if not empty.


http://www.google.com";>Google
http://www.yahoo.com";>Yahoo
http://www.microsoft.com";>MS





On Wed, 19 Jan 2005 20:10:25 +0200, William Stokes 
<[EMAIL PROTECTED]>  wrote:

Hello,
Hope someone can give some directions...
I'm trying to create a list box of links to other pages. I just can't  
figure
out how to move to the other page whe user selects one of the options 
in  the
list box.

here's the code...
$sql="SELECT team_name FROM teams";
$result=mysql_query($sql);
$num = mysql_num_rows($result);
$cur = 1;
print "";
print "";
while ($num >= $cur) {
$row = mysql_fetch_array($result);
$team_name = $row["team_name "];
print "$team_name ";
$cur++;
}
print "";
print "";
print "";
This propably can be don without the "Go" button. But i Don't know how...
Thank a lot
-Will
BTW thanks for the debugging stuff earlier. Got that workin...

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


[PHP] Re: select-option link list

2005-01-19 Thread Ricky Morley
Like this. Here's the html code. I'm sure you can convert to the  
appropriate PHP





http://www.google.com";>Google
http://www.yahoo.com";>Yahoo
http://www.microsoft.com";>MS





On Wed, 19 Jan 2005 20:10:25 +0200, William Stokes <[EMAIL PROTECTED]>  
wrote:

Hello,
Hope someone can give some directions...
I'm trying to create a list box of links to other pages. I just can't  
figure
out how to move to the other page whe user selects one of the options in  
the
list box.

here's the code...
$sql="SELECT team_name FROM teams";
$result=mysql_query($sql);
$num = mysql_num_rows($result);
$cur = 1;
print "";
print "";
while ($num >= $cur) {
$row = mysql_fetch_array($result);
$team_name = $row["team_name "];
print "$team_name ";
$cur++;
}
print "";
print "";
print "";
This propably can be don without the "Go" button. But i Don't know how...
Thank a lot
-Will
BTW thanks for the debugging stuff earlier. Got that workin...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: select * on all current?

2004-07-27 Thread Lester Caine
Louie Miranda wrote:
now its working,
i was wondering if we can do max(dateposted) on update?
mysql> update datafiles set status = '1' where max(dateposted);   
 ERROR : Invalid use of group function
WHERE dateposted = max(dateposted);
Perhaps ( works in Firebird :) )
--
Lester Caine
-
L.S.Caine Electronic Services
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: select * on all current?

2004-07-26 Thread Louie Miranda
now its working,

i was wondering if we can do max(dateposted) on update?

mysql> update datafiles set status = '1' where max(dateposted);   
 ERROR : Invalid use of group function

hmm? seems, not to be working at all.

On Tue, 27 Jul 2004 14:43:58 +0800, Louie Miranda <[EMAIL PROTECTED]> wrote:
> ok, just removed the distinct syntax
> 
> 
> 
> On Mon, 26 Jul 2004 23:51:43 -0500, mos <[EMAIL PROTECTED]> wrote:
> > At 10:45 PM 7/26/2004, you wrote:
> > >if I understand you correctly, this should do it.
> > >
> > >select distinct office, max(dateposted)
> > >from table
> > >group by office
> >
> >
> > Just one more thing. You don't need "distinct" because you are already
> > using "group by".
> >
> > Mike
> >
> > --
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
> >
> >
> 
> 
> --
> Louie Miranda
> http://www.axishift.com
> 


-- 
Louie Miranda
http://www.axishift.com

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



[PHP] Re: select * on all current?

2004-07-26 Thread Louie Miranda
ok, just removed the distinct syntax

On Mon, 26 Jul 2004 23:51:43 -0500, mos <[EMAIL PROTECTED]> wrote:
> At 10:45 PM 7/26/2004, you wrote:
> >if I understand you correctly, this should do it.
> >
> >select distinct office, max(dateposted)
> >from table
> >group by office
> 
> 
> Just one more thing. You don't need "distinct" because you are already
> using "group by".
> 
> Mike
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
> 
> 


-- 
Louie Miranda
http://www.axishift.com

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



[PHP] Re: SELECT

2004-06-02 Thread Craig Donnelly
SELECT * FROM foo_table WHERE field_foo <> some_value

The above will select all from foo_table except where field_foo is equal to
some value.

HTH

Craig


"Phpu" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hi,

Is there any way  to select all entries in the database except one entry or
tho entries?

Thanks

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



[PHP] Re: Select box

2004-05-18 Thread \[php\]Walter
Sure!

';

   $sqlu  = "SELECT id,user,name ';
   $sqlu .= "FROM users  ';
   $sqlu .= "ORDER BY user ASC";

   $name_result = mysql_query($sqlu);

   while($rowu=mysql_fetch_array($name_result)){
  echo '';
   echo $rowu[user];
   echo '' . "\n";
   }

   echo 
?>

Walter

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



[PHP] Re: Select from 24 tables

2004-05-01 Thread Richard A. DeVenezia
Dave Carrera wrote:
> Hi List,
>
> How do I select data from 24 table in my database.
>
> Each one is identical in structure layout being
>
> Id,name,list
>
> I want to select where like $_POST[var] from a form all of the tables
> but I am having trouble :(
>
> I thought making a var string like
>
> $string = "table1,table2,table3,.";
>
> And doing
>
> (select * from $string where list like \"%$_POST[var]%\");
>
> Would work but I get a MySql error which say "Column: 'list' in where
> clause is ambiguous"
>
> I am stumped so I ask the list for help or advise please.
>
> Any advise is very much appreciated and I thank you in advance for
> any help or pointers.
>
> Thank you
>
> Dave C

Try constructing a query that looks like this...

select 't1' as source, t1.* from t1 where t1.list like "$criteria"
union
select 't2' as source, t2.* from t2 where t2.list like "$criteria"
union
select 't3' as source, t3.* from t3 where t3.list like "$criteria"
union
...
select 't24' as source, t24.* from t24 where t24.list like "$criteria"
;


This query can be created by
1. storing all the table names in an array
2. constructing the individual select portion using array_map()
3. combining all individual selects using join($selects, 'union')


-- 
Richard A. DeVenezia

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



[PHP] Re: Select from 24 tables

2004-05-01 Thread Red Wingate
First, this is a MySQL Question, next time you better send your request
to a list which covers your type of question.
use tablename.fieldname in your WHERE clause if you have fields with the
same name.
 -- red

Dave Carrera wrote:
Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list

I want to select where like $_POST[var] from a form all of the tables but I
am having trouble :(
I thought making a var string like

$string = "table1,table2,table3,.";

And doing

(select * from $string where list like \"%$_POST[var]%\");

Would work but I get a MySql error which say "Column: 'list' in where clause
is ambiguous"
I am stumped so I ask the list for help or advise please.

Any advise is very much appreciated and I thank you in advance for any help
or pointers.
Thank you

Dave C

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28/04/2004
 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: select * From ????

2002-12-15 Thread Javier
[EMAIL PROTECTED] (Bruce Levick) wrote in
[EMAIL PROTECTED]:">news:[EMAIL PROTECTED]: 

If you want to access the data in an array try $row['field']
> I am connecting to mysql and all works well there. I query a table
> "Illustrations" ($query = "SELECT * FROM Illustrations";), and want to
> print the values of two columns ("titletext" & "img")within each row
> as the request loops.
> 
> Print "$row[titletext]";
> Print "$row[img]";

> I am sorry if this is hard to understand and also a silly Q, I am two
> days into learning this stuff. All I want to do is to return these two
> values from within the table. "titletext" and "img". They are both
> text fields.
> 



-- 
*** s2r - public key: (http://leeloo.mine.nu/s2r-gmx.sig)

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




[PHP] Re: select * From ????

2002-12-15 Thread Seraphim

> Print "$row[titletext]";
> Print "$row[img]";

check if the img field in the returned row even has a value or try:
$row[0] and $row[1] instead of $row['titletext'] and $row['img']

-Peter



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




[PHP] Re: select box

2002-09-09 Thread yasin inat

evet   koyabilirsin


degerini   bastan   verdigin   bir   degiskenle :



bla  bla
>display  first


her   defasindaselected   olan   degisecekse ...

display  first  or".$baskadegisken; ?>


bla  bla



   kolay   gelsin 



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




[PHP] Re: select box

2002-09-09 Thread Craig Donnelly

Can you be a bit more clearer with your question?



"Meltem Demirkus" <[EMAIL PROTECTED]> wrote in message
011c01c257f0$c4499780$5583@hiborya">news:011c01c257f0$c4499780$5583@hiborya...
> Hi,
>
> Can I put the "selected" option of select box   later by using php?
>
> thanks
>
>



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




[PHP] Re: Select box won't display in Netscape 4.xx

2001-12-31 Thread Mike Eheler

This happens when a  tag is not within a  block in 
netscape 4.. if the select isn't meant to be part of a form, and is just 
for navigation (javascript onchange or whatever), then just do 
...

Mike

Edwin Boersma wrote:

> Hi,
> 
> I'm developing a website for multiple browsers. In Netscape 4.xx (both
> Win98 and Linux versions), the php-scripts display the select boxes in
> my forms only as plain text. I cannot make any selections. In other
> browsers (NS 6 and IE5), it works fine.
> 
> Anyone seen this behavior before?
> 
> Regards,
> Edwin
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: select join table on mysql

2001-12-05 Thread Fred

The most common couse of this problem is that your query generated an mysql
error.  To find out what the error is use this instead:

> $t2=mysql_db_query($db, "SELECT
radacct.UserName,sum(radacct.AcctSessionTime)
> as t1,usergroup.GroupName ".
>"from radacct LEFT JOIN  usergroup ON
> radacct.UserName=usergroup.UserName where".
>"usergroup.GroupName='unlimited' AND
> radacct.AcctStartTime>='2001-$month-01 00:00:00'".
>"AND AcctStopTime<='2001-$month-31 23:59:59' group by UserName")
or die(mysql_error());

Yamin Prabudy <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> hi i have to select this :
>
> $t2=mysql_db_query($db, "SELECT
radacct.UserName,sum(radacct.AcctSessionTime)
> as t1,usergroup.GroupName ".
>"from radacct LEFT JOIN  usergroup ON
> radacct.UserName=usergroup.UserName where".
>"usergroup.GroupName='unlimited' AND
> radacct.AcctStartTime>='2001-$month-01 00:00:00'".
>"AND AcctStopTime<='2001-$month-31 23:59:59' group by UserName");
>
>
>
> when i do it in mysql database it already give me result and thereis about
> 400 rows.
> but when i want to generate it fetch the array there is a error
> Supplied argument is not a valid MySQL result resource in
./stats.php
> on line (bellow is the line
>
> $x=mysql_fetch_array($t2);
>
>
> what might be possible wrong with the code..(it just a simple one)
>
>
> Yamin Prabudy



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Select distinct error!

2001-09-21 Thread Richard Lynch

I'm guessing the table is messed up...

Back up your database, and try running those ISAM check utilities that MySQL
provides to verify database integrity.

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
- Original Message -
From: Sophokles Zafeiris <[EMAIL PROTECTED]>
Newsgroups: php.general
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 20, 2001 9:28 AM
Subject: Select distinct error!


> Hi,
> I' m trying to execute a "select distinct" command on a table and I get
the
> following error:
> ERROR 1022: Can't write, duplicate key in table 'pmall'
> My table is about 2,7 MBytes.
> Does anybody knows what's wrong?
> I use MySQL 3.23.40 on a Solaris 7 (intel) machine.
>
> Sofoklis
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Select distinct error!

2001-09-21 Thread Richard Lynch

Whoops.  Hit send too soon.

It could just be that your table is too darn big for select distinct on the
hardware you have...

What's your disk space like on MySQL's "data" drive?

df -h

You'll need to figure out which partition holds MySQL's data directory, and
see how much free space is there.

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
- Original Message -
From: Sophokles Zafeiris <[EMAIL PROTECTED]>
Newsgroups: php.general
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 20, 2001 9:28 AM
Subject: Select distinct error!


> Hi,
> I' m trying to execute a "select distinct" command on a table and I get
the
> following error:
> ERROR 1022: Can't write, duplicate key in table 'pmall'
> My table is about 2,7 MBytes.
> Does anybody knows what's wrong?
> I use MySQL 3.23.40 on a Solaris 7 (intel) machine.
>
> Sofoklis
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Select IN array?

2001-07-15 Thread teo

Hi James!
On Sun, 15 Jul 2001, James Tan wrote:

> dear chris,
> 
> mysql does not support 'in' clause at the momment...
> the only way to this is to use the loop to generate the sql syntax..
> orr.. use the implode function... to join the array into 1 string separated by
> the first parameter...

huh?
teo@teo:/x > mysql test 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 155 to server version: 3.23.39

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> desc stock;
++-+--+-+-+---+
| Field  | Type| Null | Key | Default | Extra |
++-+--+-+-+---+
| item   | varchar(17) | YES  | | NULL|   |
| num| varchar(4)  | YES  | | NULL|   |
| weight | varchar(7)  | YES  | | NULL|   |
| price  | varchar(7)  | YES  | | NULL|   |
| date   | datetime| YES  | | NULL|   |
++-+--+-+-+---+
5 rows in set (0.00 sec)

mysql> select * from stock where num in (1,3);
+--+--++---+-+
| item | num  | weight | price | date|
+--+--++---+-+
| foo  | 1| 2kg| 123   | 2001-06-24 21:08:04 |
| bar  | 3| 7kg| 1234  | 2001-06-24 21:08:13 |
+--+--++---+-+
2 rows in set (0.00 sec)

> > I have an array of id numbers ($catids). I would like to select from the
> > mysql database all records where cid is in that array.
> >
> > This syntax fails:
> > select * from categories
> > where cid in $catids
do :
$catids = implode(',',$catids);
$qs ="SELECT * FROM categories WHERE cid IN ($catids)";

-- teodor

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Select IN array?

2001-07-14 Thread James Tan

dear chris,

mysql does not support 'in' clause at the momment...
the only way to this is to use the loop to generate the sql syntax..
orr.. use the implode function... to join the array into 1 string separated by
the first parameter...

$catsql = implode("or cid=", $catids);
$catsql  = ((strlen(catsql)>0)? substr(catsql, 3, strlen(catsql)): "");

$catsql = "select * from categories where " . $catsql;

Chris Lott wrote:

> I have an array of id numbers ($catids). I would like to select from the
> mysql database all records where cid is in that array.
>
> This syntax fails:
> select * from categories
> where cid in $catids
>
> What is the correct way to do this? It can be done outside of a loop, can't
> it?
>
> c


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]