Jump to content

Drop down data all on the same line


msebar
Go to solution Solved by msebar,

Recommended Posts

When I look at my page in source view the <br> are in the drop down but not working. Here is my php code along with the view source.

 

This is the main page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Water Analysis Data(WAD)</title>
<style type="text/css"></style>
</head>

<body>

<p align="center"><a href="../test/index.html">Home</a> | <a href="../test/register.php">Register</a> | <a href="../test/login.php">Login</a> | <a href="../test/tank.php">Add Tank</a> | <a href="../test/fish.php">Add Fish</a> | <a href="../test/water_test.php">Add Water Test</a></p>
<p align="center"> </p>

<table width="810" border="2" align="center">
  <tr>
    <td><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td align="center" bgcolor="#FFFFFF" scope="col"><h2><b>Water Analysis Data(WAD)</b></h2></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF">
          <form id="form1"  method="POST" action="/include/waterparameters/water-parameters.inc.php">
              <table border="2" align="center" cellpadding="0">
                <tr>
                  <td><div align="left"><b>Tank Name: </b> </div></td>
                  <td><div align="left">
                      <select id="tankname" type='text' name="tankname">
                        <option>
<?php    
include_once '/include/dropdowns/water-parameters-dd.inc.php';
?>
                        </option>
                      </select>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>Test Date: </b> </div></td>
                  <td><div align="left">
                      <input id="date" type="text" name="date" size=25>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>Temperature: </b> </div></td>
                  <td><div align="left">
                      <input id="temperature" type="text" name="temperature" size=25>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>pH: </b> </div></td>
                  <td><div align="left">
                      <input id="ph" type="text" name="ph" size=25>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>Ammonia: </b> </div></td>
                  <td><div align="left">
                      <input id="ammonia" type="text" name="ammonia" size=25>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>Nitrite: </b> </div></td>
                  <td><div align="left">
                      <input id="nitrite" type="text" name="nitrite" size=25>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>Nitrate: </b> </div></td>
                  <td><div align="left">
                      <input id="nitrate" type="text" name="nitrate" size=25>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>phosphate: </b> </div></td>
                  <td><div align="left">
                      <input id="phosphate" type="text" name="phosphate" size=25>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>GH: </b> </div></td>
                  <td><div align="left">
                      <input id="gh" type="text" name="gh" size=25>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>KH: </b> </div></td>
                  <td><div align="left">
                      <input id="kh" type="text" name="kh" size=25>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>Iron: </b> </div></td>
                  <td><div align="left">
                      <input id="iron" type="text" name="iron" size=25>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>Potassium: </b> </div></td>
                  <td><div align="left">
                      <input id="potassium" type="text" name="potassium" size=25>
                    </div></td>
                </tr>
                <tr>
                  <td><div align="left"><b>Notes: </b> </div></td>
                  <td><div align="left">
                      <p>
                        <textarea id="notes" name="notes" cols="50" rows="10"></textarea>
                      </p>
                    </div></td>
                </tr>
                <tr>
                  <th colspan=2><p>
                      <input type="submit" value="Submit"id="submit1" class="submit"  name="submit" />
                    </p></th>
                </tr>
              </table>
            </form></td>
        </tr>
        <tr>
          <td align="center" valign="top" bgcolor="#FFFFFF"><div align="center"><font size=2> © 2014 <a href="http://www.pctechtime.com">PC TECH TIME</a> </font> </div></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>

This is the include for the page (the echo line for <br> shows in the source but doesn't produce the break

<?php
include_once "/include/db/db.inc.php";

$result = mysqli_query($con,"SELECT tankname FROM tank");

while($row = mysqli_fetch_array($result)) {
  echo $row['tankname'];
  echo "<br>";
}

mysqli_close($con);
?>

Here is the source when you bring the file up in a browser

<select id="tankname" type='text' name="tankname">
  <option>
     Tank 1<br>Tank 2<br>Tank 3<br>
  </option>
</select>
   

 

 

 

 

 

Link to comment
Share on other sites

Well, that's not valid HTML for your <select> dropdown. each one needs to be it's own option, not separated by <br>.

 

Each option needs to look like:

<option value="what gets sent with the form">Text to display in dropdown</option>

 

So change this:

while($row = mysqli_fetch_array($result)) {
echo $row['tankname'];
echo "<br>";
}

to

while($row = mysqli_fetch_array($result)) {

  echo '<option value="' . $row['tankname'] . '">' . $row['tankname'] . '</option>';
}

and then remove the

<option>

</option>

from the <select> in the HTML so it's just:

<select id="tankname" type='text' name="tankname">
<?php include_once '/include/dropdowns/water-parameters-dd.inc.php'; ?>
</select>
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.