Jump to content

php form modify page


jenneke

Recommended Posts

hello all, this is my first entry in the forum.  i am making an cms to add and modify entries into a database.  everything is going well except the modify page.  the page gets the id of the entry, the text area but when it tries to collect the list/menu, it displays them as one long line, not as a drop down menu.  does anyone know what could be the problem?

 

code below with problem area in red:

 

 

<h3>Links</h3>

<form name="form1" method="post" action="links_update.php?id='.$id.'>

  <p>

  <br>

  <select name="area" size="1">

<option selected>' . $row["area"] . '</option>

    <option>Footprint calculators</option>

    <option>Water saving</option>

    <option>Energy saving</option>

    <option>Home</option>

    <option>Garden</option>

    <option>Directory services</option>

    <option>At work</option>

    <option>Environmental labelling</option>

    <option>Recycling</option>

    <option>Investment</option>

    <option>Food</option>

    <option>Shopping</option>

    <option>Travel</option>

    <option>For the Kids</option>

    <option selected>Green groups</option>

<option selected>Miscellaneous</option>

    </select>

<br>

    <input name="website" type="text" size="53" value="'.htmlentities($row['website']).'">

    : Website <br>

    </p>

  <p>

    <textarea name="details" cols="40" rows="5">' . $row["details"] . '</textarea>

    : Details<br>

Link to comment
Share on other sites

Thanks for the quick response.

It still doesn't work.  The selected value does appear at the start of the row, so that doesn't seem to be the problem. It looks like it is having trouble recognising the drop down menu as a drop down menu.  Any other suggestions?

Thanks again

Link to comment
Share on other sites

Can u show the complete code with mysql query.

Also select one value from one dropdown menu, u r selecting multiple items.remove that, select only one.

It depends on ur mysql query if u r geting the rows from db.

Link to comment
Share on other sites

Here is the code with only one field selected.

Thank you for your time,

Jenneke

 

$result=mysql_query("SELECT * FROM links WHERE id='$id'");

if ($row=mysql_fetch_array($result)) {

  echo '

 

  <br><br><br>

<h3>Links</h3>

<form name="form1" method="post" action="links_update.php?id='.$id.'>

  <p>

  <br>

  <select name="area">

<option selected>' . $row["area"] . '</option>

    <option>Footprint calculators</option>

    <option>Water saving</option>

    <option>Energy saving</option>

    <option>Home</option>

    <option>Garden</option>

    <option>Directory services</option>

    <option>At work</option>

    <option>Environmental labelling</option>

    <option>Recycling</option>

    <option>Investment</option>

    <option>Food</option>

    <option>Shopping</option>

    <option>Travel</option>

    <option>For the Kids</option>

    <option>Green groups</option>

<option>Miscellaneous</option>

    </select>

 

 

 

  <br><br>

    <input name="website" type="text" size="53" value="'.htmlentities($row['website']).'">

    : Website <br>

    </p>

  <p>

    <textarea name="details" cols="40" rows="5">' . $row["details"] . '</textarea>

    : Details<br>

    <br>    <p>

          <input type="submit" name="Submit" value="Submit">

        </p>

        </form>

  ';

}

 

else {

  echo '<br><br>sorry, this entry does not exist<br><br>';

}  mysql_close();

include('footer.html');

?>

Link to comment
Share on other sites

$sql="select * from links where id='$id'";
                       $result = mysql_query($sql) or die(mysql_error());
                       while($row= mysql_fetch_object($result)){
                      
echo  "<option value='{$row->area}' selected='selected'>{$row->area}</option>";}

 

Modify ur code to this way.

Link to comment
Share on other sites

The change in code you suggested does call up the correct value from the database but when i view the form, the other options still appear in one long line instead of as a drop down menu.

 

Example:

Miscellaneous Footprint calculators Water saving Energy saving Home Garden Directory services At work Environmental labelling Recycling Investment Food Shopping Travel For the Kids Green groups Miscellaneous

 

Note that the selected value 'miscellaneous' has appeared at the start indicating that the code you (mmarif4u) suggested worked.

 

But how can I make it appear as a drop down menu instead of this long line of text?

 

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.