Search code examples
phpjavascriptdatabasescroller

auto scroller horizontal images from database


i have the following code that generate some images with urls associated from database:

<html>
<head>
    <title></title>

</head>

<body>

<div id="datacontainer">


<?php
ini_set('display_errors', 0); 
 header('Content-type: text/html; charset=UTF-8') ; 


//Retriving informations from database

    mysql_connect("****", "****", "*****");

    mysql_select_db("*****);

    $result = mysql_query("SELECT * FROM table ORDER BY  RAND() LIMIT 52");



print "<table  width='200' border='0'  ><style>
 td {overflow:hidden;}
</style> ";
 while($row = mysql_fetch_array($result, MYSQL_ASSOC))

    {    


                $link=$row['url'];
                $title=$row['siteTitle'];                              
                $thumb= $row['url'];




  print "          <tr>
    <td><div style= 'text-align:center;height:90px;padding: 5px 5px 5px 5px;overflow:hidden;'><a href='$link' target='_blank'><img src='http://open.thumbshots.org/image.pxf?url=$thumb'/></a></div></td>
  </tr>
  <tr>
    <td><div style= 'text-align:center;height:20px;padding: 5px 5px 5px 5px;overflow:hidden;'><a href='$link'target='_blank'><font color='0000ff'>$title </font></a></div></td>
  </tr>";



  }
print"</table>";





?>




</div>



</body>
</html>

i need of implement a auto horizontal scroller of this images from left to right possibly with a width of container of max 4 images I'm searching a gallery image script or similar can you help me? thanks


Solution

  • I guess you are mentioning about an Image gallery. Well there are many of them available (one can be found here - http://www.dynamicdrive.com/dynamicindex14/leftrightslide.htm ). You will have to modify your current code though in order to incorporate a gallery and provide the gallery code with the inputs it expects.

    Hope this helps.