www.webdeveloper.com
Results 1 to 6 of 6

Thread: Displaying an image with link underneath in the table

  1. #1
    Join Date
    Apr 2013
    Posts
    4

    Displaying an image with link underneath in the table

    Code:
        $chkuserid = mysql_query("select UserID from users where Username = '".$_SESSION['Username']."'");
        $row = mysql_fetch_array($chkuserid);
        $finall = $row['UserID'];
        $result = mysql_query("SELECT PhotoDesc, photoDateAdded, PhotoString from photo where photographerID='".$finall."'");
        if (!$result) {
        die("Database query failed: " . mysql_error());
      }
      
      //
      // 4. Use returned data
      //
      
      // while ($row = mysql_fetch_array($result)) {
      //  echo $row[0]." ".$row[1]."<br />";
      //}
      
      ?>
    
    <?php
    
    //
    //Set up table headings
    //
    echo "<table border=5 align=center>";
    echo "<tr>";
    echo '<td>Photo Desc.</td>';
    echo '<td>Date&Time Added</td>';
    echo '<td>Photo</td>';
    echo '<tr>';
    
    
    //
    //Display data returned by the query
    //
    
    $i=0;
    while ($row = mysql_fetch_array($result))
      {
      echo "<tr>";
      echo '<td>'.mysql_result($result,$i,0).'</td>';
      echo '<td>'.mysql_result($result,$i,1).'</td>';
      $image = mysql_result($result,$i,2);
      echo '<td>'.'<img src="http://'.$image.'">'.
      .'<a href="http://'.$image.'">View>'. <==== this is line 185
      '</td>';
      echo '</tr>';
      $i++;
      }
    echo "</table>";
    Parse error: syntax error, unexpected '.' in /srv/disk7/1259829/www/blablabla/imgup.php on line 185
    I want to display an image and just below it a link to display it full size in seperate tab.

    When I get rid of link code I can display the images but when I add link code I get this error message.

  2. #2
    Join Date
    Apr 2013
    Posts
    56
    There is a dot which is not needed on line 185. Just remove it (first dot you encounter).

  3. #3
    Join Date
    Apr 2013
    Posts
    1
    Hi,
    you need to change your following code
    echo '<td>'.'<img src="http://'.$image.'">'.
    .'<a href="http://'.$image.'">View>'.
    '</td>';
    to

    echo '<td>'.'<img src="http://'.$image.'">'.
    '<a href="http://'.$image.'">View</a>'. '</td>';

    There is extra dot and ending tag of a is missing.

    if you want to read tutorials on webdevelopment please also vist http://www.websourceblog.com.

  4. #4
    Join Date
    Apr 2013
    Posts
    23
    How about creating a web-based image viewer to help display an image with link underneath? I am not very sure about it. But you can google it and have a try. And I am also testing about the relevant programs these days. We can aommunicate about it later. Good luck.



    Best regards,
    Arron

  5. #5
    Join Date
    Feb 2014
    Location
    Canada
    Posts
    124
    You need the . for concatenation but when you're specifying HTML elements inside an echo statement, it's easier to use " " as it will automatically make the distinction between PHP variables and HTML elements. This will make your life easier and will (hopefully) avoid these sorts of errors. For example:

    PHP Code:
    echo("<td><img src = $yourSrc /><a href = $yourHref >View</a></td>"); 

  6. #6
    Join Date
    Mar 2014
    Posts
    25
    <table cellspacing="0" cellpadding="0" border="0" width="500">
    <tr><td><img src="nav1.gif"><img src="nav2.gif"><img src="nav3.gif"><img
    src="nav4.gif"><img src="nav5.gif"></td></tr>
    <tr><td style="background: red;">
    <img src="smallred.gif" height="1" width="1"></td></tr>
    <tr><td>
    <p style="margin: 0.5em;">This is text in another cell of the
    table. Within the textthere is an icon <img src="icon2.gif">
    that indicates a link to another site. It's very worldly. Lorem
    ipsum, dolor sit amet...</p></td></tr></table>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles