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

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

Hi,

Here is my list:


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

Thanks

$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...

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.