0

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

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by n3xtgen
0

I found my mistake.

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

Should Be:

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

Edited by n3xtgen: n/a

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.