Jump to content

All image information gets stored in the database except for the last 2


sandhya_sep14

Recommended Posts

Hi Everyone,

 

I have a program that generates 200 unique images keeping the first image static in each run.The images keep scrolling on to the screen pause for 3 seconds and scroll off I'm able to generated all 200 unique images without repetition, everything is working well except for the lase two images the last two  images are scrolling on to the screen but are not been displayed in the database, Moreover The last image is a duplicate of 197th image.I don't know what is happening.....

 

Here is MY code..........

 

 

 

<?php

session_start();

$sid = $_SESSION['id'];

$_SESSION['imageDispCnt'] = 0;

$myQuery = "SELECT * from image";

$conn = mysql_connect("localhost","User","Passwd");

mysql_select_db("database_Name",$conn);

$result = mysql_query($myQuery);

$img =Array();

$id =Array();

$i =0;

$imagepath = 'http://localhost/images/';

while ($row = mysql_fetch_array($result))

  {

  $img[$i] =  $imagepath.$row['img_name'];

  $id[$i] =  $row['imageid'];

  $i = $i + 1;

      }

?>

</head>

<script language="JavaScript1.2">

var scrollerwidth='800px';

var scrollerheight='600px';

var scrollerbgcolor='white';

var pausebetweenimages=3200;

var s;

var sec;

var d;

var j;

var imgid;

var milisec = 0;

var seconds = 0;

var flag = 1;

var ses_id = '<?php echo $sid;?>';

var count = 0;

var i = 0;

var imgname;

var imgid;

var k =0;

var slideimages=new Array();

var img_id = new Array();

var index;

 

<?php

  $l =0;   

$count = array();

$j = rand(0,199);

while($l < 200)

{

while(in_array($j, $count))

        {

        $j = rand(0,199);

        }

        $count[$l] =  $j;

        $l++;

       

    }?>

    <?php

  $k = 0;

  for($k = 0;$k<count($count);$k++){

  ?>

  index = <?php echo $k;?>;

  <?php

  $indx = $count[$k];?>

  if(index == 0){

  slideimages[0] = '<img src="http://localhost/images/hbag044.jpg" name="r_img" id="0"/>';

  img_id[0] = '<input type="hidden" value="0" id="imgId" />';

  }

 

  else if(index > 0)

  {

slideimages[<?php echo $k?>] = '<img src="<?php echo $img[$indx]?>" name="r_img" id="<?php echo $id[$indx]?>"/>';

    img_id[<?php echo $k?>] = '<input type="hidden" value="<?php echo $id[$indx]?>" id="imgId" />';

  }

<?php

}

?>

 

 

Can Any one plese help me

 

Appreciate your help...

 

 

Thanks

Link to comment
Share on other sites

Well if the last two images display in your scroller but don't appear in the database, then I would suggest making sure there isn't another page in the database view in phpMyAdmin (assuming you're using this). Having 200 records on the one page seems like alot, so it might be broken up into a couple of pages.

 

Also, you have a typo near the bottom with index.

$indx = $count[$k];?>

should be

$index = $count[$k];?>

I do believe....

 

As for the 200th picture, this is infact the 201st picture, as indexing starts at 0. So maybe you're having a problem there somewhere?

 

Denno

 

P.S. Use the code tags or php tags in the future so it's easier for us to read your code.

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.