I am trying to display images side by side from mysql database using php, i want 4

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nili
    New Member
    • Mar 2014
    • 5

    I am trying to display images side by side from mysql database using php, i want 4

    ----- this is my image.php file---- for getting id----

    Code:
    <?php 
     include('connect.php');
         if (isset($_GET['id'])) 
    	 {
        $gotten =mysql_query("select  *from reg  where id=".$_GET['id']);
        while ($row = mysql_fetch_array($gotten))
        {
        echo $row['id']; 
         }
        mysql_free_result($gotten);
        }
        ?>
    -----imagefetcher.ph p------

    Code:
     <html> <head> <title>home page</title> </head> <?php 
    include("connect.php");
     $strSQL = "select * from reg";
    $rsPix = mysql_query($strSQL);
    $numRows = mysql_num_rows($rsPix);
    $i = 0;
    ?> <table border="1"> <tr> <?php
     	 while($i<$numRows)
    	 {
         ?> <td> <img src="http://bytes.com/image.php?id=<?php echo mysql_result($rsPix,$i,"id"); ?>"/></a> </td> <?php
          $i++;
              if ($i%3==0)
    		  {
           ?> </tr> <tr> <?php
             }
            ?> <?php
     		}
            ?> <?php
            if ($numRows%3>0)
    		{
            ?> <td "colspan="<?php echo $numRows%3; ?>">*</td> <?php
            }
            ?> </tr> </table> </body> </html>
    Last edited by Dormilich; Mar 12 '14, 01:31 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    and what’s the problem?

    Comment

    • nili
      New Member
      • Mar 2014
      • 5

      #3
      where can i use
      Code:
       and
      tages please tell me as i am new for php me it will be helpfull if you guide me

      Comment

      • nili
        New Member
        • Mar 2014
        • 5

        #4
        problem is images are not display its just giving table with image icon but images are not displays

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          if you only see the image icon it means that either the image URL is invalid or that the URL didn’t return an image.

          in this case the latter because:
          - the URL returns an HTML page (without the tags, though)
          - effectively you return what you pass in (though in a very complicated way)
          Last edited by Dormilich; Mar 12 '14, 01:33 PM.

          Comment

          • nili
            New Member
            • Mar 2014
            • 5

            #6
            i use varchar datatype to store images in database is that possible this may be error ?and the mysql_result is use for blob datatype

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              i use varchar datatype to store images in database is that possible this may be error ?
              no. the error is that image.php doesn’t return an image.

              Comment

              • nili
                New Member
                • Mar 2014
                • 5

                #8
                thanks for your reply let me play with image.php

                Comment

                Working...