|
|
 |
Re: FN-FORUM: MySQL PHP Query
date posted 21st January 2007 15:26
I may well be wrong but cant you create a for loop to general the WHERE part
of the SELECT statement? Am not an expert in PHP but this should be doable
e.g.
string whereSection = "WHERE ";
For(int k = 0; k < sumVal; k++)
{
if (k = 0)
whereSection = whereSection + "value = " + k;
else
whereSection = whereSection + "and value = " + k;
}
string query = "SELECT FROM tablName " + whereSection;
----Original Message Follows----
I think the array is correct howver the query in using $value and I don't
think the query wil work with an array or will it?
lest say i define the variable
$variable="1";
this is fine becuase there is only one value for the query to handle
howver
if I have an array the query
FROM tbl_value_info as pi
WHERE value= "'.$value.'"';
wont work because I need AND or is there a way around this?
Andrew
----- Original Message -----
From: "James Herrington" [EMAIL REMOVED]
To: [EMAIL REMOVED]
Sent: Sunday, January 21, 2007 3:35 PM
Subject: Re: FN-FORUM: MySQL PHP Query
>
> I don't really understand what your trying to do here but from what you
> said
> it sounds like you need an array and then a for loop to iterate through
> the
> array elements!
>
> Might be way off the mark but i dont really understand what your after
>
> James
>
> ----- Original Message -----
> From: "Punters Power" [EMAIL REMOVED]
> To: [EMAIL REMOVED]
> Sent: Sunday, January 21, 2007 3:27 PM
> Subject: FN-FORUM: MySQL PHP Query
>
>
>>
>> little teaser that shouldn't be any bother having I have a block
>>
>> I have a query that current;y is just one value '1' however I now need
to
>> add more values so that it is using 1,2,3
>>
>> because I am using a $value
>>
>> what is the best way to 'repeat' $value within the query without
>> repeating
>> it? Sounds dumb I know, but maybe this is what I have a block!
>>
>> I want
>>
>> $value="1 AND 2 AND 3";
>>
>> I currently have $value="1";
>>
>> Andrew
>>
>>
>> --
>> Freelancers, contractors earn more with Prosperity4
>> Call 0870 870 4414 or visit www.prosperity4.com
>> and benefit from Inland Revenue approved expenses today.
>>
>> To advertise here: http://www.freelancers.net/advertising.html
>>
>>
> --
> Freelancers, contractors earn more with Prosperity4
> Call 0870 870 4414 or visit www.prosperity4.com
> and benefit from Inland Revenue approved expenses today.
>
> To advertise here: http://www.freelancers.net/advertising.html
>
>
--
Freelancers, contractors earn more with Prosperity4
Call 0870 870 4414 or visit www.prosperity4.com
and benefit from Inland Revenue approved expenses today.
To advertise here: http://www.freelancers.net/advertising.html
|
 |
|