Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6177369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:15:41+00:00 2026-05-24T00:15:41+00:00

Numeric values.. $price = $_POST[‘price’]; $zipcode = $_POST[‘zipcode’]; How can I filter two fields

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:15:42+00:00Added an answer on May 24, 2026 at 12:15 am

    Are you just trying to retrieve the category name and ID from the posted, $ delimited category_id field?

    If so, then this should do it

    $option = explode("$", $_POST['category_id']);
    $name = $option[0];
    $id   = $option[1];
    

    I would be more inclined to just set the ID in the <option> value attribute 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

    if (!preg_match('/^[a-zA-Z0-9]+\$\d+$/', $_POST['category_id'])) {
        // not valid
    }
    

    I wouldn’t attempt to filter out invalid characters on that field. Validation and error conditions are more concise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two integer arrays which contain numeric values. I want to look through
How can I change values in string from 0,00 to 0.00? - only numeric
How can I add a textbox so a user can enter numeric values into
The odata4j AppEngineConsumerExample demonstrates how to filter entities on string and numeric values with
I have a list of alpha-numeric values that I need to search through using
I have two unix files with numeric values only such as : File 1
I would like regex(es) that can parse right-justified numeric values in a fixed length
Possible Duplicate: Select TOP X (or bottom) percent for numeric values in MySQL How
How can I customize regular expression to allow alpha-numeric values,@ and dot. I want
What is the meaning of ORDER BY 1,2 Can we use numeric values in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.