0

Hi,

I am creating an order form that brings data of the items and its price from a external .txt file. I am to add the number of items and get the total price of that product. Here is the code:

<form action="pay.php" method="post" name="form1">


<?php
$lines = file('list.txt');
$fnames = explode("|", $lines[0]);

for($i=1;$i<count($lines);$i++)  {
    $fvalues[] = explode("|", $lines[$i]);
}
?>


<?php
$j = 0;
foreach($fnames as $name){
?>

Product: 
<select>

<?php
for($k=0;$k<($i-1);$k++){
?>

<option><?=$fvalues[$k][$j];  ?></option>
<?php
}
?>
</select>

<?php
$j++;
}
?>

<br><br>

Number of Item : <input type="text" name="itemcount" size="20"/>

 <input type="submit" name='Order' value="order" />



</form>

Can someone help me on this?

Thanks

Edited by Reverend Jim: Fixed formatting

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by vingan
0

post your list.txt content.
Will give you exact code to create drop down from that file.

0

Hi,

Here is my list:


list;price
apple;$4.00
orange;$2.00
grapes;$3.00
banana;$5.00

Thanks

0

$fvalues is a single dimensional array only... not two dimensional array... And the value will be stored after explode as $fvalues[0]="apple" and $fvalues[1]=$4.00.. likewise... So, use it as single dimensional array..you will get it...

0

Hi,

I am not sure on how to handle that since I am new to php. Can you please help me on that? I have used arrays before but on in this case, where it has two items.

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.