msebarmsebar South Florida

I am missing something from my code and I don't know how to make it work. I may have programed it wrong and that could be giving me my troubles. I am new at php and things have been going slowly. please understand that the code my not be organized as it should be. After creating about 12 pages of code I found out that I should be using mysqli or pod. Once I get everything working that will be the next project. Enough said here is my issue. I was able to populate my drop down box and there shows no errors on the page. Also all the data does get inserted into the database except for the section made on the drop down box. Here is my code. I will leave out all of the input fields except the drop down.

<?php {$userid = $getuser[0]['username'];} // this is processed when the form is submitted // back on to this page (POST METHOD) if ($_SERVER['REQUEST_METHOD'] == "POST") { # escape data and set variables $tank = addslashes($_POST["tank"]); $date = addslashes($_POST["date"]); $temperature = addslashes($_POST["temperature"]); $ph = addslashes($_POST["ph"]); $ammonia = addslashes($_POST["ammonia"]); $nitrite = addslashes($_POST["nitrite"]); $nitrate = addslashes($_POST["nitrate"]); $phosphate = addslashes($_POST["phosphate"]); $gh = addslashes($_POST["gh"]); $kh = addslashes($_POST["kh"]); $iron = addslashes($_POST["iron"]); $potassium = addslashes($_POST["potassium"]); $notes = addslashes($_POST["notes"]); // build query // # setup SQL statement $sql = " INSERT INTO water_parameters "; $sql .= " (id, userid, tank, date, temperature, ph, ammonia, nitrite, nitrate, phosphate, gh, kh, iron, potassium, notes) VALUES "; $sql .= " ('', '$userid', '$tank', '$date', '$temperature', '$ph', '$ammonia', '$nitrite', '$nitrate', '$phosphate', '$gh', '$kh', '$iron', '$potassium', '$notes') "; // #execute SQL statement $result = mysql_query($sql); // # check for error if (mysql_error()) { print "Database ERROR: " . mysql_error(); } print "<h3>New Water Parameters Were Added"; } ?>

Here is the drop down

<tr><td><div align="left"><b>Tank Name: </b> </div></td><td><div align="left">
     echo "<select>";

                $result = mysql_query("SELECT tank FROM tank WHERE userid = '$userid'");

                while($row = mysql_fetch_array($result))
    echo "". $row["tank"] . "";
        echo "";


  • IcepickleIcepickle Germany
    edited August 2014

    your select needs a name so it could at its output into the post data, i guess the name should be "tank"

    so, you would need to edit it as

    echo "<select name='tank'>";

    also, you are not closing the select tag in the end,

    and your select should use

    echo "<option>".$row["tank"]."</option>";

    try to generate correct html when you are parsing your own controls

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion