Jump to content

conditionally increment a retrieved value


matthew_ellis24

Recommended Posts

Hello, I am using an HTML form to upload data to my MySQL database. The form automatically populates select dropdowns with existing categories and also provides a textbox to allow you to enter one if the category you want isn't on the list. The dropdown outputs an id number, the text box outputs the name. Both are stored in the database.

 

I think the code is correct so far, all I need to do now is figure out how to set subdiv_id if you enter info in the text field. It should be set by going into the database, finding the maximum current subdiv_id and adding one.

 

Cheers

Matt

 

/////
////get subdivision name from database or if no subdiv_id get from form /////////
if(!empty($_POST['subcat']))
{
$subdiv_id=$_POST['subcat'];
$query1= "select subdivision from speciescomplete where subdiv_id='$subdiv_id'";
$result1 = mysql_query ($query1);
While ($row1 = mysql_fetch_array($result1)) {
$subdivision = $row1[subdivision];
}
}else{
$subdivision = $_POST['subdiv'];
$subdiv_id = 
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.