please help with code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dlazic
Forum Newbie
Posts: 2
Joined: Wed Oct 04, 2006 5:41 pm

please help with code

Post by dlazic »

I have the following code, it works fine except for one thing.

I am trying to query the database for clients who fit the specifications from the previous page.

To make the long story short, I need to display clients thumbnail pictures and their name under the picture. It displays the first client and clients picture but then the others do not. I believe that the problem is with file_exists function and the first "print". Any help is well appreciated.


Code: Select all

<?php
$result = mysql_query("SELECT clients_name, id FROM clients_info WHERE city='$city' AND $category='x'group by clients_name");
while ($row = mysql_fetch_array($result, MYSQL_NUM))

{
$filename="/data/11/0/77/86/729738/user/744719/htdocs/b/admin/client_pics/$row[1]/";
if (file_exists($filename)) 
{
   $dir = "/data/11/0/77/86/729738/user/744719/htdocs/b/admin/client_pics/$row[1]/";
$dh  = opendir($dir);
while (false !== ($filename = readdir($dh))) {
       $files[]=$filename; }
} else {
   echo "This client has no pictures";
        }

print("<TR><TD><center><img src=/phpThumb/phpThumb.php?src=/b/admin/client_pics/$row[1]/$files[2]&w=100></TD></TR>");
print("<TR><TD><center><a href=view_profile.php?id=$row[1] target=frame3>$row[0]</a></TD></TR>");}

mysql_free_result($result);
?>
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

hello dlazic, welcome to the forum.

Your print() is outside of the loop.
dlazic
Forum Newbie
Posts: 2
Joined: Wed Oct 04, 2006 5:41 pm

Post by dlazic »

I am not sure how to put it inside of the loop. Do you mind doing it for me? Thank you so much for your help.
Post Reply