October 30th, 2011, 06:20 PM
Select Key=Value from a SQL WHERE clause
I am programming in PHP and I have a SQL statement:
$sql='SELECT PROPID, ADDRESS_1, ADDRESS_2, TOWN, POSTCODE1, POSTCODE2, BEDROOMS, BATHROOMS, RECEPTIONS, PRICE, TRANS_TYPE_ID FROM properties WHERE TRANS_TYPE_ID=2 AND BEDROOMS =3 AND PROP_SUB_ID IN (1,2,3,4,5,6,21,22,23,24,27,30,95,128,131) ORDER BY DATE_ADDED, PROPID DESC';
I want to be able to get the fields and their corresponding values as such:
And then capture the values in PROB_SUB_IN IN(*)
How can I do this?
Any help will be greatly appreciated. Thanks
with /m/g options.
([A-Z_]+ ?=\d+)|([A-Z_]+ IN \(.*\))