rgb192
asked on
do many form inputs with one input statement (repeated by a loop)
this code has the desired output
desired html output
but I want to have less lines because there is only text input
maybe do the foreach loop with only one input
$arr = array("first_name","last_n ame","emai l","addres s1","city" ,"country" ,"state"," postalcode ","phone", "creditcar d","cvv2") ;
foreach ($arr as &$colname) {
first_name input name is css id firstlastname
last_name input name is css id firstlastname
email input name is css id pass1
address1 input name is css id pass1
<style>
#firstlastname {
margin: auto;
width: 200px;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 27px;
font-style: bold;
padding: 5px;
color: #FFFFFF;
background-color: #000000;
padding-top: 4px;
padding-bottom: 4px;
margin-top: 4px;
margin-bottom: 4px;
border: none;
}
#pass1 {
margin: auto;
width: 440px;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 27px;
font-style: bold;
padding: 5px;
color: #FFFFFF;
background-color: #000000;
padding-top: 4px;
padding-bottom: 4px;
margin-top: 4px;
margin-bottom: 4px;
border: none;
}
</style>
<?php
$myArray[0]["first_name"] = "firstname";
$myArray[0]["last_name"] = "lastname";
$myArray[0]["email"] = "address";
$myArray[0]["pass1"] = "pass1";
$myArray[1]["first_name"] = "firstname";
$myArray[1]["last_name"] = "lastname";
$myArray[1]["email"] = "address";
$myArray[1]["pass1"] = "pass1";
for($i=0;$i<count($myArray);$i++){
echo '
<br>Organization<br>
<input name="organization" type="text" id="pass1" title="organization" />
<br>Email<br>
<input name="email" type="text" id="$myArray[$i]["address"]" title="email" />
<br>Address Line 1<br>
<input name="address1" type="text" id="pass1" title="address1" />
<br>Address Line 2<br>
<input name="address2" type="text" id="pass1" title="address2" />
<br>City/Country<br>
<input name="city" type="text" id="firstlastname" title="city" />
<input name="country" type="text" id="firstlastname" title="country" />
<br>State Region/Postal Zip Code<br>
<input name="state" type="text" id="firstlastname" title="state region" />
<input name="postalcode" type="text" id="firstlastname" title="postal zip code" /
>';
}
desired html output
<br>Organization<br>
<input name="organization" type="text" id="pass1" title="organization" />
<br>Email<br>
<input name="email" type="text" id="pass1" title="email" />
<br>Address Line 1<br>
<input name="address1" type="text" id="pass1" title="address1" />
<br>Address Line 2<br>
<input name="address2" type="text" id="pass1" title="address2" />
<br>City/Country<br>
<input name="city" type="text" id="firstlastname" title="city" />
<input name="country" type="text" id="firstlastname" title="country" />
<br>State Region/Postal Zip Code<br>
<input name="state" type="text" id="firstlastname" title="state region" />
<input name="postalcode" type="text" id="firstlastname" title="postal zip code" /
but I want to have less lines because there is only text input
maybe do the foreach loop with only one input
$arr = array("first_name","last_n
foreach ($arr as &$colname) {
first_name input name is css id firstlastname
last_name input name is css id firstlastname
email input name is css id pass1
address1 input name is css id pass1
can u explain again what u want to achieve?
ASKER
many html lines of text input
with just one line of <input> in php code repeated with a foreach loop
with just one line of <input> in php code repeated with a foreach loop
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
this will loop through all the values
thanks
thanks