View Single Post
Old Feb 11th, 2006, 10:47 AM   #23
k4pil
Programmer
 
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4 k4pil is on a distinguished road
Sorz, your right.

Ok, so my array is working correctly as
echo $text[$i];
returns a list of productID's from my database.

Its my for loop and something to do with the GET method.

When i check the boxes and hit submit nothing happens.

My code is
<?php
header("Cache-control: private"); //IE 6 Fix 
error_reporting(E_ALL);


include 'connect.php';

$query = "SELECT * FROM product"; 
$result = mysql_query($query); 
$num = mysql_numrows($result);
mysql_close(); 


$text = array("$num");
?>

<form action="cbox.php" method="get" name="myForm"> 
    <input name="ButtonWidget"     type="submit" value="Submit"><br/> 

<?
$i=0;
while ($i < $num)
	{
	$productID=mysql_result($result,$i,"productID");
	$prodName=mysql_result($result,$i,"prodName");
	$text[$i] = "$productID";
	echo $text[$i]; 

?>	


    Checkbox <?php echo $prodName;?>&nbsp;<input name="CheckBox<?php echo $productID;?>" type="checkbox" value="<?php echo $productID;?>"><br/> 

</form> 
</body> 
</html> 
	
	<?
	$i++;
	}
	
	
	echo "Boxes checked: "; 
for ($i = 0; $i < $num; $i++) 
{ 
    if (!empty ($_GET ["CheckBox$productID"])) 
    {
	    echo $productID; 
    }//if
} 
	
	
echo "<br/>"; 


?>

The page im working on is www.lingan.co.uk/cbox.php
k4pil is offline   Reply With Quote