need help with this one. I need to create a php code to see the items i've selected

<html>
<body>
<form method = "get" action = "new.php">

<center>
RANDOM IMAGES<br>
<table> 
<?php
	$images = array('2010 BMW M6.jpg','2011 BMW 750 Li.jpg','2009 BMW M5.jpg','2010 BMW 650 i.jpg','2010 BMW X6 ActiveHybrid.jpg','2010 BMW 550 I G.jpg','2011 BMW X6 xDrive50i.jpg','2011 BMW X6 xDrive50i.jpg','2011 BMW X5 xDrive50i.jpg');
	shuffle($images);

for($x=0; $x<3; $x++) 
	{
			echo '<tr>';
			for($y=$x*3; $y<(($x+1)*3) ; $y++)
			{
				echo '<td align="center"><img src="';
  				echo $images[$y];
				$snew = substr($s,0,-4);
				echo '" width="150" height="150">';
				echo '<br>';
				echo '<input type = "checkbox" name = "num[]" value =<?php echo $snew;?>';
				echo 'Add to cart <br>';
				echo '</td>';
  				
			}
			echo'</tr>';
			
	}
echo '<center><input type = "submit" name = "submit" value = "ORDER"></center>';
										
?>
</center>

</body>
</table>
</html>

upon submitting, i must see the image file name. I'm just studying php sorry and thanks! =p

line 18 you may need $images["{$y}"]
line 22 you have php tags.
change to:

value="'.$snew.'"

you also don't have a $s for your substr

hope this helps :)

so if i do this it will look like this?

<html>
<body>
<form method = "get" action = "new.php">

<center>
RANDOM IMAGES<br>
<table> 
<?php
	$images = array('2010 BMW M6.jpg','2011 BMW 750 Li.jpg','2009 BMW M5.jpg','2010 BMW 650 i.jpg','2010 BMW X6 ActiveHybrid.jpg','2010 BMW 550 I G.jpg','2011 BMW X6 xDrive50i.jpg','2011 BMW X6 xDrive50i.jpg','2011 BMW X5 xDrive50i.jpg');
	shuffle($images);

for($x=0; $x<3; $x++) 
	{
			echo '<tr>';
			for($y=$x*3; $y<(($x+1)*3) ; $y++)
			{
				echo '<td align="center"><img src="';
  				echo $images["{$y}"];
				$snew = substr($s,0,-4);
				echo '" width="150" height="150">';
				echo '<br>';
				echo '<input type = "checkbox" name = "num[]" value ="'.$snew.'">';
				echo 'Add to cart <br>';
				echo '</td>';
  				
			}
			echo'</tr>';
			
	}
echo '<center><input type = "submit" name = "submit" value = "ORDER"></center>';
										
?>
</center>

</body>
</table>
</html>

how will i see the output if i submit this form?

well firstly you need to close the form
also line 22 for the name change to:

echo '<input type = "checkbox" name = "num['.$y.']" value ="'.$snew.'">';

so as to make each input have a unique id.
then on your form handling script use a foreach $_post as name => value to get all the input check boxes.
I don't actually know what your script is supposed to do so if you could elaborate I might be able to help more

From where $s in this line $snew = substr($s,0,-4) is being derived.
The grid works, because $s is empty you will not get any value in num check box array. This should works fine with correct $s value. I have re arranged the code as below.
Please see to the value of $s.

<html>
<body>
<form method = "get" action = "new.php">

<center>
RANDOM IMAGES<br>
<table>
<?php
$images = array('2010 BMW M6.jpg','2011 BMW 750 Li.jpg','2009 BMW M5.jpg','2010 BMW 650 i.jpg','2010 BMW X6 ActiveHybrid.jpg','2010 BMW 550 I G.jpg','2011 BMW X6 xDrive50i.jpg','2011 BMW X6 xDrive50i.jpg','2011 BMW X5 xDrive50i.jpg');
shuffle($images);

for($x=0; $x<3; $x++)
{
echo '<tr>';
for($y=$x*3; $y<(($x+1)*3) ; $y++)
{
        $snew = substr($s,0,-4);
echo '<td align="center"><img src="';
  echo $images[$y];
echo '" width="150" height="150">';
echo '<br>';
echo '<input type = "checkbox" name = "num[]" value ="'.$snew.'">';
echo 'Add to cart <br>';
echo '</td>';
 
}
echo'</tr>';

}
echo '<center><input type = "submit" name = "submit" value = "ORDER"></center>';

?>
</center>

</body>
</table>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.