Jump to content


Photo

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


  • Please log in to reply
4 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 October 2006 - 12:06 PM

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.

<?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'>";

?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 12 October 2006 - 12:13 PM

What were you told was wrong about it, it looks OK to me.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 October 2006 - 12:15 PM

I was told it not the correct way in php to do a select form but i think it's correct.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 12 October 2006 - 12:21 PM

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 <select> and <option>

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

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 October 2006 - 12:27 PM

thanks mate.

i get the inpression they dont understand php or html my code is bang on cheers huggie mate.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users