Jump to content

Adding motion to the images


riddhi

Recommended Posts

I want to display the product images at the button of the page using the code as follows:-

 

<?php
require_once 'library/config.php';
if (!defined('WEB_ROOT')) {
exit;
}
?>
<p> </p>
<table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
  <td align="center">
   <br />
<?
   $res=dbQuery("SELECT PD_ID,CAT_ID,PD_NAME,
             PD_THUMBNAIL,PD_DATE
		     FROM TBL_PRODUCT");

if(mysql_num_rows($res) == 0 ){ //None of the product Image found
	echo "<br><br><marquee bgcolor='red'>
	    <b>There is no Product in The Shop </b></marquee>"; 
	exit; // Quit The Script			 
     }

 while ($record=mysql_fetch_array($res)){
	if($record['PD_THUMBNAIL']){
	      $cat_image=$record['PD_THUMBNAIL'];
	        
	if($cat_image){
	    $cat_image = WEB_ROOT.'images/product/' . $cat_image; 
	 }// End If
   else 
	    $cat_image = WEB_ROOT.'images/no-image-small.png';
	}// End of Thumbnail IF
	echo "<img src='$cat_image' border='10'>"; 
     }// End While Loop			

?>
   
   </td>
</tr>
</table>
</body>
</html>

 

Now I want the image to move from left to right in a looping manner.

 

Link to comment
Share on other sites

Javascript

xCo =-100;
function move(obj) 
{    
   	obj.style.left=xCo;
   	xCo +=2;
   	if(xCo < 100) {window.setTimeout("move(" +obj.id+ ");", 0);}
}

html

<p><img src="xx.gif" id="myImg" style="z-index: 0; left: -100px; position: absolute; top: 50px"></p>
<p> 
  <script language="JavaScript">
moveObjRight('myImg');
  </script>

</p>

Link to comment
Share on other sites

Thanks for taking pain to write the code however I have the following point:-

 

1> There is no motion noticed in the images displayed :(

 

2> I would like the pictures to appear row fashion instead of columnar fashion that it is showing now :)

 

Here is the code I wrote in PHP the transformed one:-

 

echo "<p><img src=$cat_image id='myImg' style='z-index: 0  left: -100px  position: absolute  top: 50px'></p>";
        echo "<p>"; 
        echo "<script language='JavaScript'>";
    echo "moveObjRight('myImg')";
	echo "xCo =-100";
        echo "function move(obj){";
	echo "obj.style.left=xCo";
   	    echo "xCo +=2";
   	    echo "if(xCo < 100) {window.setTimeout('move(' +obj.id+ ')', 0)}";
         echo "}";
         echo "</script> </p>";
     }// End While Loop			

Link to comment
Share on other sites

Sorry, dude but I feel it is here because I want to verify the PHP Code that embeds javascript.

 

The error in the IE after html is generated by PHP is "object expected" at the line where <img> tag is there

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.