Numeric values..
$price = $_POST['price'];
$zipcode = $_POST['zipcode'];
How can I filter two fields passing through a single select tag field called category_id that uses the explode() to recieve the values from this category_id field.
Form
<?php echo '<label for="Category">Category:</label>
<select name="category_id" size="1" ><br />';
$sql = "SELECT id, name FROM category ORDER BY name";
$rs = mysql_query($sql);
while($row = mysql_fetch_array($rs))
{
echo "<option value=\"".$row['name']."$".$row['id']."\">".$row['name']."</option>\n ";
}
echo '</select>';
the way I receive the category_id field with explode but don’t know how to filter it since it is a numeric and data field at the same time.
$option = explode("$", $_POST['category_id']);
enter code here
Are you just trying to retrieve the category name and ID from the posted,
$delimitedcategory_idfield?If so, then this should do it
I would be more inclined to just set the ID in the
<option>valueattribute and fetch the name from the database or a pre-fetched associative array.Update
If you’re wanting to validate that field, you could try something like
I wouldn’t attempt to filter out invalid characters on that field. Validation and error conditions are more concise.