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

  • SEARCH
  • Home
  • 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 6969607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:36:11+00:00 2026-05-27T16:36:11+00:00

my html form is bellow and process this page with add_post_process.php. In this page

  • 0

my html form is bellow and process this page with add_post_process.php. In this page i insert the data to mysql database in table name “user_post”

Well, i can insert the all data to mysql database but can’t insert cat_id. How can i get this cat_id from my html form? if you need add_post_process.php code then i’ll post this. Thanks.

“user_post” table structure:

post_id
user_id
subject
image
img_name
message
cat_id
cat_name
comment_count
poster
date

<form action="add_post_process.php" method="post" name="addpost" 
enctype="multipart/form-data"> 
<select name="cat_name" class="tdpost">
<?php   
while($row = mysql_fetch_assoc($sql))
{
$cat_name = $row['cat_name'];
$cat_id = $row['cat_id'];
echo "<option value='$cat_name'>$cat_name</option>";
}
?>  
</select></td>
</tr>    
<td>&nbsp;</td>
<td><input type="submit" name="submit" value="Add Post" class="submit" />&nbsp;&nbsp;
<input type="reset" name="clear" value="Clear" class="submit" /></td>
</tr>
</table>
</form>
  • 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-27T16:36:12+00:00Added an answer on May 27, 2026 at 4:36 pm

    It’s the value of the HTML form element that is submitted – I guess you wanted to write echo "<option value='$cat_id'>$cat_name</option>";. Below you can find shorter and cleaner code:

    <?php while($row = mysql_fetch_assoc($sql)) : ?>
       <option value="<?php echo $row['cat_id'] . '|' . $row['cat_name'] ?>"><?php echo $row['cat_name'] ?></option>
    <php endwhile ?> 
    

    You end up with select like this:

    <select name="cat_name">
       <option value="1|category1">category1</option>
       <option value="2|category2">category2</option>
       <option value="3|category3">category3</option>
    </select>
    

    Because the whole x|categoryx value will be posted, it’s enough to split it by |
    Then in your add_post_process.php file do like this:

    $cats = explode("|", $_POST['cat_name']);
    echo $cats[0]; // cat_id
    echo $cats[1]; // cat_name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML form - with PHP, I am sending the data of
Currently I'm able to send some form data from an HTML page to a
I have a simple form with some plain html input like bellow using ASP.NET
My goal was to call this page with a queryString parameter (http://localhost:8080/page.html?scrapeU ... ://cnn.com
I am in the process of creating a PHP contact form and all I
In an HTML form post what are valid characters for creating a multipart boundary?
I have a an HTML form which contains the YAHOO rich text editor on
I am developing a HTML form designer that needs to generate static HTML and
I have a basic HTML form that gets inserted into a server side div
I am creating an HTML form with some radio button options. I'd like to

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.