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 = 
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.