Hi, can anyone help, sorry its a mess, im trying to design a page that works like a till, the user enters a barcode which is then found from the database and the products details are added to an array, the only way i have found to be able to constantly add products is to use self submit and use files and add each new product then read it in again the only problem is i cant get it to write the file does any one have any ideas, heres the source code i know its long and messy but gives an idea of what im trying to do, thanks in advance
<?
if (IsSet($VarSource))
{
mysql_connect("localhost");
mysql_select_db("stocklist");
$result = mysql_query ("SELECT * FROM newone WHERE barcode='$item'");
$row = mysql_fetch_array($result);
if ($row["barcode"] > 0)
{
$counter = $counter +1;
$prods[$counter][0] = $row["barcode"];
$prods[$counter][1] = $row["prod"];
$prods[$counter][2] = $row["stock"];
$prods[$counter][3] = $row["price"];
$allprods=explode("\n",$prods);
$fileupdate = fopen
("productssold.txt",'w+');
fwrite($fileupdate,$prods);
)
else
{
print ("No Matching Product");
}
}
else
{print ("No Products");
(integer) $counter = 0;
}
?>
<FORM METHOD=POST>
<ACTION="<? print $PHP_SELF?>$VarSource=Get">
<INPUT TYPE=text name="item" VALUE="0">
<INPUT TYPE=HIDDEN NAME=VarSource VALUE=<? print("$item");?>>
<INPUT TYPE=HIDDEN NAME=test VALUE=item<? print("$counter");?>>
<INPUT TYPE=HIDDEN NAME=counter VALUE=<? print("$counter");?>>
Products<br>
<?
$prods = file("productssold.txt");
$t=sizeof($prods);
if ($row["barcode"] > 0)
{
(integer) $relay = 0;
$relay = $t;
$counter = 1;
while ($counter <= $relay)
{
print ($counter);
print ($prods[$counter][0]);
print ($prods[$counter][1]);
print ($prods[$counter][2]);
print ($prods[$counter][3]);
$counter = $counter + 1;
?> <br> <?
}
}
else
{
print ("No Products Found");
}
?>