0

I've got a page that displays all of a users' photos but I'm looking to exclude the default profile picture which is thumb-default.png. How do I do that?

<?

$getphotos = mysql_query("SELECT ID, Link FROM images WHERE MemberID = '$vid'");
while($iph = mysql_fetch_array($getphotos))
{
$pID = $iph['ID'];
$pLINK = $iph['Link'];

echo "

<li><a href=\"members_image/$vid/$pLINK\" rel=\"prettyPhoto[gallery]\"><img src='/members_image/$vid/thumb-$pLINK' width='105'></a></li>

";


}

Thank you!! :-)

3
  • 1
    you know you can use combination of double quote and single quote to get rid of escape character `\` Commented Apr 9, 2013 at 13:39
  • do not use short tags. Do escape variables passed to query. Commented Apr 9, 2013 at 13:40
  • @NullPonyPointer That is true, but if doing the single quote in HTML makes in 'technically' invalid HTML, and if doing it on the outside, requires concatenation of multiple string which adds more code that really isn't needed, nor does it help with readability. Commented Apr 9, 2013 at 13:48

2 Answers 2

3

Add at the end of your query AND Link != 'thumb-default.png'

$getphotos = mysql_query("SELECT ID, Link FROM images WHERE MemberID = '$vid' AND Link != 'thumb-default.png'");

This excludes every entry with this link to be selected.

Sign up to request clarification or add additional context in comments.

1 Comment

I think 'Link' should have the value default.png (not thumb-default.png)
0

I agree with the above and also it is better to use this,

while($iph = mysql_fetch_object($getphotos))
{
$pID = $iph->ID;
$pLINK = $iph->Link;

}

Because I think mysql_fetch_array, prefers array element keys as numbers. $iph[0], $iph[1]...

I think for alpha key elements, you use

mysql_fetch_assoc

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.