Page 1 of 1
a simple WHERE = question I think
Posted: Tue May 18, 2004 6:31 pm
by hward
how can you do this
Code: Select all
WHERE $adv_picture = '/images/$adv_username.jpg'
stored picture path is always /members/XXXX.jpg
XXXX matches adv_username
Posted: Tue May 18, 2004 6:34 pm
by Weirdan
Code: Select all
where adv_picture = concat('/images/',adv_username,'.jpg');
Did I get it right?
Posted: Tue May 18, 2004 6:40 pm
by hward
won't execute
Posted: Tue May 18, 2004 6:42 pm
by zenabi
It might be clearer to make a variable for the path to your image first, for example:
Code: Select all
$image_path = "members/".$adv_username.".jpg";
//and then add that to your sql statement:
$sql = "SELECT * FROM tablename WHERE fieldname=$image_path";
Posted: Tue May 18, 2004 6:42 pm
by hward
Code: Select all
WHERE adv_picture = concat('/images/',adv_username,'.jpg')
query executes but no returns
Posted: Tue May 18, 2004 6:49 pm
by hward
Code: Select all
$image_path = "members/".$adv_username.".jpg";
//and then add that to your sql statement:
$sql = "SELECT * FROM tablename WHERE fieldname=$image_path";
Couldn't execute query.
Posted: Tue May 18, 2004 6:57 pm
by zenabi
It may help if you post the code to your page.
Posted: Tue May 18, 2004 6:57 pm
by hward
Code: Select all
where adv_picture = concat('/members/',adv_username,'.jpg')
works fine
my bad it was members not images
Posted: Tue May 18, 2004 6:59 pm
by feyd
do all path's stored in the table have /members/ in them? If so, then what's the point of storing that? The script can automatically tack that on, freeing up potentially many many bytes of stored redundant data.
Posted: Tue May 18, 2004 7:04 pm
by hward
no if some no photo is uploaded a generic photo is added and i didn't want those to return