0

hello friends,

I want to display only those images which are checked.
I had tried so many times but no use.
when I checked any images. it displays only last image.
can any tell me where is the problem
here is the code.

display.php

<?php
$i=0;
$connect = mysql_connect('localhost','root','') or die("Not connected");
$select = mysql_select_db('demo_data', $connect) or die("Not selected");
//$result = "select * from 'demo_data'.'photo_info' ";
$count = mysql_query("select * from photo_info ");
//$record = mysql_num_rows($count);
//if($record >0){
while($r= mysql_fetch_array($count)){
$i++;
$name = $r;
echo '<img src= " '.$name.'" />';
?>
<form action="new.php" method="post" >
<input type="checkbox" name="selectimg[]" value="<?php echo $i; ?> "/>
<?php }
?>
<input type="submit" value="submit" name="fsub" />
</form>

show.php

<?php //mysql_close($hostn);
require_once ("display.php");
if(isset($_POST)){
$check = $_POST;
//$box = $check;
if(empty($check)){
echo "Not getting";
}
else{
$count = count($check);
$x=0;
for($i=0; $i<$count; $i++){
$v = $check[$i];
while($x < $count){

$x++;
echo '<img src= "'.$name.'" />' ;
}
}
}
}
?>

Edited by sonia_demo: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by sonia_demo
0
<input type="checkbox" name="selectimg[]" value="<?php echo $i; ?> "/>

Look into the $i value it only sets the last value of i, bcoz it executes after the first php statement completed.

0
<input type="checkbox" name="selectimg[]" value="<?php echo $i; ?> "/>

Look into the $i value it only sets the last value of i, bcoz it executes after the first php statement completed.

thanx for ur reply. but i have check $i value and it correctly showing the checked value.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.