Jump to content

Archived

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

redarrow

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

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]

Share this post


Link to post
Share on other sites
I was told it not the correct way in php to do a select form but i think it's correct.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
thanks mate.

i get the inpression they dont understand php or html my code is bang on cheers huggie mate.

Share this post


Link to post
Share on other sites

×

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.