Location: PHPKode > scripts > php virtual table > phpvirtualtable-beta-0.10/vt/example1-vt.php
<?php
//filename: example1-vt.php
include_once "vt.php";
?>

<html>
<body>
<?php
$vt=new VirTable("","Item","Quantity","Unit Price","Total");
if($_POST["post_req"]=="true" && $_POST["item"]!="" && $_POST["unit_price"]!="" && $_POST["quantity"]!="")
	{
		$price=0;
		$price=$_POST["unit_price"] * $_POST["quantity"];
		$vt->add_row('1',$_POST["item"],$_POST["quantity"],$_POST["unit_price"],$price);
	}
?>
<form method="POST" name="frm_product" action="">
<input type="hidden" name="post_req" value="true">
<table><tr><td>Select Item</td><td>
<select style="align:right;width:200px" name="item">
	<option selected>Not Selected</option>
	<option>Pen</option>
	<option>Paper</option>
	<option>Clip</option>
	</select></td><tr><td>Unit Price</td><td>
<select style="width:200px" name="unit_price">
	<option selected>Not Selected</option>
	<option>50</option>
	<option>100</option>
	<option>150</option>
	</select></td><tr><td>Quantity</td><td>
<input type="text" name="quantity" value="" style="width:200px">
</td></tr><tr><td align="right" colspan=2>
<input type="submit" name="submit" value="Add This Item">
</td></tr></table>
<?php $vt->link_to_form();?>
</form>

<?php 
$vt->set_font_family("courier");
$vt->set_border_type("solid");
$vt->set_border_width("1px");
$vt->set_header_bgcolor("#8B6914");
$vt->set_even_row_color("#FFCD70");
$vt->show();
echo "<strong>Total =".$vt->sum(4)." Taka</strong><br/>";
//echo $vt->usage();

//use the following function to save data in MySQL format
//echo $vt->fetch_rows_as_mysql_data();
?>
</body>
</html>
Return current item: php virtual table