Mike521
-
Posts
29 -
Joined
-
Last visited
Posts posted by Mike521
-
-
works perfect, thanks!!
edit: can you point me to some documentation that explains the AS statement you used? i've seen it used a couple of times and looks really useful but I don't quite understand how it works yet
hopefully I can read up on it and do things like this with no problem in the future
-
Hi all, if you have a query ordered by whatever, is it possible to check if a certain item exists, and then move that item to the top of the list?
-
hi all, is it possible to use htaccess password protection and send a user to a different file depending on their login credentials?
so user A would go to admin/userA.php and userB would go to admin/userB.php?
Or is it possible to send all users to a php script that simply registers their username in a global variable and then redirects them to "users.php" which then grabs their username and displays material accordingly?
Thanks
select individual items from comma separated list?
in MySQL Help
Posted
[code]
$selection = "some columns to select";
$zipcode = "11787"; //this can be any zip code, it's not really hardcoded like this.
$low = $zipcode - 2500; //the lowest number we'll consider a close enough match
$high = $zipcode + 2500; //the highest number we'll consider a close enough match
//the ABS stuff below is just to order the results by the closest to $zipcode
$query = "SELECT $selection, ABS(zipcode-$zipcode) AS distance FROM ourDB WHERE zipcode BETWEEN $low AND $high ORDER BY distance";
[/code]
so we have $zipcode which is a php variable, and zipcode which is a column in our DB. right now the column only has one zip, but I'd like to have multiple zips and still do the whole search in mysql. the alternative is to have a comma separated list, grab ALL the zipcodes into php, explode, and loop through with php.. what a pain..
any ideas? thanks everyone