I have one file with checkbox's a user can select. Now if they select one and click submit I want my next file to show the user what they selected. I cant seem to get this working. It looks likes it grabbing the first word and because there is a space in the name everything else is ignored. For example, I have a checkbox with the name "My First Code". When I click submit it displays only the first word "My" on the screen. Why is everything else ignored? How can I fix this?

myTable.php

if (mysql_num_rows($result) > 0) {
			echo "<form action=" . "compare.php" . " " . "method=" . "post>";
			echo "<table cellpadding=10 border=1>";
			while($row = mysql_fetch_row($result))
			{
				$checkboxName = $row[1];
				$rpl = str_replace("","_",$checkboxName);
				echo "<tr>";
				echo "<td>" . "<input type=" . "checkbox" . " " . "name=" . "Compare[]" . " " . "value=" . $rpl . "></td>";
				echo "<td>" . $row[0] . "</td>";
				echo "<td>" . $row[1] . "</td>";
				echo "<td>" . $row[2] . "</td>";
				echo "<td>" . $row[3] . "</td>";
				echo "</tr>";
			}
			echo "</table>";
			echo "<input type=" . "submit" . " " . "name=" . "submit" . " " . "value=" . "submit" . ">";
			echo "</form>";
		}

compare.php

<?php

$Name = $_POST['Compare'];

while (list($key,$val) = @each ($Name)) {
	echo "$val";
}

?>

Thank You

I found my mistake.

$rpl = str_replace("","_",$checkboxName);

Should Be:

$rpl = str_replace(" ","_",$checkboxName);
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.