I dont know if this is possible or not . But, maybe someone can let me know because I really need to solve this dilemma.
I have a list box that I need to pas multiple values from but I dont mean multiple select with ctrl key. Here is a simple flow of what i want to do.
select f1, f2, f3, f4 from mysql table
select name = x
while rows
<option value=f1 f2 f3 and f4 >selection 1 </option>
...
...
<option value=f1 f2 f3 and f4 >selection 10 </option>
done
my problem is that using one list box, i want to pass the value of f1, f2, f3, and f4 to another script But i cant figure out how to do it.
Question regarding arrays and list box using php
Moderator: General Moderators
-
sureshmaharana
- Forum Commoner
- Posts: 30
- Joined: Thu Jul 03, 2008 4:20 am
- Contact:
Re: Question regarding arrays and list box using php
Hey,
You can do it by array.
Like:
while rows
$temp = arry();
$temp['f1']= f1;
$temp['f2']= f2;
$temp['f3']= f3;
$temp['f4']= f4;
<option value=$temp >selection 1 </option>
while END
You can do it by array.
Like:
while rows
$temp = arry();
$temp['f1']= f1;
$temp['f2']= f2;
$temp['f3']= f3;
$temp['f4']= f4;
<option value=$temp >selection 1 </option>
while END
Re: Question regarding arrays and list box using php
I have tried various ways using your suggestion and it does not work. Here is the actual code.
Code: Select all
if( isset($_REQUEST['samplelink'])) {
$samplelink = $_REQUEST['samplelink'];
echo $samplelink[model];
exit;
}
$query = "SELECT s.brand, s.category, s.model, b.brand FROM samples s, brands b WHERE " .
"s.active = 1 AND b.brandid = s.brand GROUP BY s.brand, s.category, s.model, b.brand ORDER BY s.brand, s.model";
$result = mysql_query($query, $connectstring);
echo "<form method='post' action='linkeditems2.php'>";
echo "<table class='transparent' cellspacing='5' >";
echo "<tr>";
echo "<td>";
echo "<select name='samplelink' >";
while ( $row = mysql_fetch_row($result) ) {
$brandid = $row[0];
$typeid = $row[1];
$model = $row[2];
$brand = $row[3];
$samplelink = array();
$samplelink[brandid] = $brandid;
$samplelink[typeid] = $typeid;
$samplelink[model] = $model;
echo "<OPTION VALUE='$samplelink'>$brand $model</OPTION>";
}
echo "</select>";
echo "</td>";
echo "<td>";
echo "<input type = 'submit' value ='Submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</form>";