August 20, 200917 yr <select name="existing"> <option value="0">Select One</option> <?php //retrive all catagories and add to pull down menu $sql = 'SELECT * FROM category'; $r = mysqli_query($dbc,$sql); if (mysqli_num_rows($r)) { while ($row = mysqli_fetch_array($r)) { echo "<option value=\"{$row['id']}\">{$row['cat_name']}</option>"; } } else { echo '<option>Please add and new category</option>'; } mysqli_close($dbc); //close connection ?> </select><br /> That is the code for my dynamic drop down box, although, it will not work unless the page has been submitted, but this php code isn't in an if(isset($_POST['submitted'])){ if on this page it clean out of it, any ideas what is going wrong?
August 21, 200917 yr It would help if we could see the whole code. What errors do you get when it does not work? Since i cannot see a database connection anywhere I can only assume that the connection function is within an if statement that only executes when you post? - That's just a wild guess. Let's see the whole script and I will take a look.
August 21, 200917 yr I can't see anything in there that will give an indication of why this is happening. Perhaps you could show some more of the code to give a better idea of what is going on? Paul
August 21, 200917 yr Author It would help if we could see the whole code. What errors do you get when it does not work? Since i cannot see a database connection anywhere I can only assume that the connection function is within an if statement that only executes when you post? - That's just a wild guess. Let's see the whole script and I will take a look. You triggered a brain strom, i had my database connections in the if(isset($_POST['submitted'] if statement, moved it out of it and it worked first time, Thank you. I can't see anything in there that will give an indication of why this is happening. Perhaps you could show some more of the code to give a better idea of what is going on? Paul As stated above, it was in an if that required a page submit, thanks again. Ben
Create an account or sign in to comment