I have a simple form which is designed to allow a user to enter numeric values and then sent them to a page which calculates the result.
The problem I'm having is that post variables that includes a space in their name don't seem to be recognised.
The form is created like so:
<?php
$minerals = mysqli_query($con, "SELECT * FROM items");
?>
<table border='1'>
<tr>
<td>Product: </td>
<td>Quanitity: </td>
<td>Buyback Price: </td>
</tr>
Minerals
</br>
</br>
<?php
while($row = mysqli_fetch_array($minerals)) {
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . "Amount: <input type='text' value='0' name='" . $row['name'] . "'>" . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo "</tr>";
if($row['name'] == "Morphite") {
break;
}
}
echo "</table>";
?>
And I'm trying to retrieve the post data like so:
echo '<table border="1">';
echo '<tr><td>Product</td><td>Value</td></tr>';
while($item = mysqli_fetch_array($items)) {
echo '<tr>';
echo '<td>';
echo $item['name'];
echo '</td>';
echo '<td>';
echo $_POST[$item['name']];
echo '</td>';
echo '</tr>';
}
echo '<tr><td>Total</td><td></td></tr>';
echo '</table>';
But any 'name' in the database that contains a space causes nothing to be displayed on the other end.