matthew_ellis24 Posted October 4, 2007 Share Posted October 4, 2007 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 = } Quote Link to comment https://forums.phpfreaks.com/topic/71801-conditionally-increment-a-retrieved-value/ Share on other sites More sharing options...
Barand Posted October 4, 2007 Share Posted October 4, 2007 If subdiv_id is auto_incrementing, insert the new category and call mysql_insert_id() to get the new subdiv_id value. Quote Link to comment https://forums.phpfreaks.com/topic/71801-conditionally-increment-a-retrieved-value/#findComment-361895 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.