add/edit the inputline to the data
hi, I want design the dynamic document so I add lines containing data to the table. But, when i want run it, output doesn't appear! the code to edit the inputlines to the data, i refer from a book-javasricpt,but i don't know what this code function and where is store my data?
<a href="javascript:document.forms[0].submit()">Add</a>
how i want create and connect to the dbase use MySQL with this pages?
attach code:
<?php
#generating session and session id
session_start();
$sid = session_id();
include("html.php");
#dislaying HTML header
echo $head;
#unserializing data
$stocka = unserialize($stocks);
$qtya = unserialize($qtys);
$uoma = unserialize($umos);
$pricea = unserialize($prices);
$amounta = unserialize($amounts);
#checking, if data has been pased to the form
if (strlen($bill) > 0)
{
$sbill = $bill;
session_register("sbill");
}
if (strlen($ship) > 0)
{
$sship = $ship;
session_register("sship");
}
if (strlen($invno) > 0)
{
$sinvno = $invno;
session_register("sinvno");
}
if ($newstock && ($newstock != ''))
{
$count++;
session_register("count");
$stocka[$count] = $newstock;
$stocks = serialize($stocka);
session_register("stocks");
$qtya[$count] = $newqty;
$qtys = serialize($qtya);
session_register("qtys");
$uoma[$count] = $newuom;
$uoms = serialize($uoma);
session_register("uoms");
$pricea[$count] = $newprice;
$prices = serialize($pricea);
session_register("prices");
$amounta[$count] = $newamount;
$amounts = serialize($amounta);
session_register("amounts");
}
# drawing the table
drawlines($count, $stocka, $qtya, $uoma, $pricea, $amounta);
# generate an input line
inputline();
# displaying end of HTML code
echo $tail;
# add lines containing data to the table
function drawlines($count, $stocka, $qtya, $uoma, $pricea, $amounta)
{
for ($i = 1; $i <= $count; $i++)
{
echo "<tr><td>$i</td><td>".$stocka[$i]."</td>";
echo "<td>".$qtya[$i]."</td><td>".$uoma[$i]."</td>";
echo "<td>".$pricea[$i]."</td>";
echo "<td>".$amounta[$i]."</td></tr>\n";
}
}
# edit the inputline to the data
function inputline()
{
echo '<tr><td>
<a href="javascript:document.forms[0].submit()">Add</a>
</td>
<td><textarea name="newstock" style="HEIGHT: 60px; WIDTH: 415px"></TEXTAREA></td>
<td><input type="text" name="newqty" style="HEIGHT: 50px; WIDTH: 150px"></td>
<td><input type="text" name="newuom" style="HEIGHT: 50px; WIDTH: 150px"</td>
<td><input type="text" name="newsprice" style="HEIGHT: 50px; WIDTH: 150px"</td>
<td><input type="text" name="newsamount" style="HEIGHT: 50px; WIDTH: 150px"></td>
';
}
?>
thanks a lot
|