Jump to content

[solved user get a book]select list with array.


redarrow

Recommended Posts

Hello all advance thank you..

I was showing a person how to create a select list with a array and i got told it's wrong am i going mad cheers.

[code]
<?php

$eq=($_POST['eq']);

if($_POST['submit']) {

echo $eq;
}

echo"<form method='POST' action='".$_SERVER['PHP_SELF']."'>";

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

$list=array("computers","motherboard","ram","case","monitor");

foreach($list as $eq){

echo"<option value='$eq'>$eq</option>";

}

echo"</select>";

echo"<input type='submit' name='submit' value='send'>";

?>

[/code]
It's nothing to do with php, it's to do with HTML, and there's nothing wrong with that.

Links to check the syntax of both [url=http://www.w3schools.com/tags/tag_select.asp]<select>[/url] and [url=http://www.w3schools.com/tags/tag_option.asp]<option>[/url]

[code]
<select name="model">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>
[/code]

Regards
Huggie

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.