Results 1 to 4 of 4

Thread: [RESOLVED] anchor with Image clicks

Threaded View

  1. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: anchor with Image clicks

    if you would like to have an image be a link, then make it into a link.
    HTML Code:
    <a href=""><img src="" /></a>
    I can't give you real feedback on if your method is "the good one" (it's weird that you keep saying it like that, even if you aren't great with english); you basically did what I told you to in the last post you asked about it. it looks like it works okay. one problem I do see is that you're querying the database once and then on every record returned you're querying the database again. this is inefficient, and, well, wrong. you should use SQL JOINs to create one SQL statement that returns all of the desired information for you. I will not get into how to do that, though -- if you're inexperienced with databases it can be a hard concept to grasp. I suggest taking a database class, reading some database (MySQL-based, in this case) books, or reading through the MySQL manual on JOINs. if you have questions, you can ask them in the Database Development section of this forum.

    if anything, I would advise you to stop echoing out HTML. PHP is an embedded language and because of that can be integrated within your HTML. here, you're instead using it to output all of your HTML. you could do something like:
    PHP Code:
    <?php
      
    while( ..... ){
    ?>
    <tr>
      <td><img src="<?php echo $userimg?>" /></td>
      <td><a href="...."><?php echo $username?></a></td>
    </tr>
    <?php
      
    }
    ?>
    this makes things much easier to maintain and read on your part.
    Last edited by kows; Jan 27th, 2010 at 02:11 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width