<html>
<head><title><?php print date("m/d/Y");?></title></head>
<body>
<form action ="report2.php" method ="post">
<table align="CENTER%" width="100%" height="100%" border="1">
<tr>
<td width="25%">Grocery</td>
<td width="25%"><input type="text" name="grocery" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">Beverages</td>
<td width="25%"><input type="text" name="beverages" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">Beer</td>
<td width="25%"><input type="text" name="beer" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">Pack</td>
<td width="25%"><input type="text" name="pack" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">Tobacco</td>
<td width="25%"><input type="text" name="tobacco" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">Carton</td>
<td width="25%"><input type="text" name="carton" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">Candy</td>
<td width="25%"><input type="text" name="candy" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">Non-Food</td>
<td width="25%"><input type="text" name="nonfood" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">Paper</td>
<td width="25%"><input type="text" name="paper" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">Misc</td>
<td width="25%"><input type="text" name="misc" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">Stamp</td>
<td width="25%"><input type="text" name="food" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
</table>
<input type="submit" value="Submit" />
</form>
</body>
</html>
This the from that send the data to report2.php
here is the script for report2.php
<?php
include('connection.php');
$selectdb = mysql_select_db('dailyreport', $con);
if (!$selectdb){
print mysql_error();
}
$grocery = $_POST['grocery'];
$drinks = $_POST['beverages'];
$beer = $_POST['beer'];
$pack = $_POST['pack'];
$toba = $_POST['tobacco'];
$carton = $_POST['carton'];
$candy = $_POST['candy'];
$nonfood = $_POST['nonfood'];
$paper = $_POST['paper'];
$misc = $_POST['misc'];
$stamp = $_POST['food'];
$value ="INSERT INTO daily
(Grocery, Beverages, Beer, Pack, Tobacco, Carton, Candy, Nonfood, Paper, Misc, Foodstamp)
VALUES
($grocery, $drinks, $beer, $pack, $toba, $carton, $candy, $nonfood, $paper, $misc, $stamp)";
$results = mysql_query($value);
if(!$results){
print mysql_error();
}
?>
but that just post the data to database but i wanted to view the data from the database and i created this script but doesnt work as i wanted it
<?php
include('connection.php');
$selectdb = mysql_select_db('dailyreport', $con);
if (!$selectdb){
print mysql_error();
}
$query = mysql_query("select * FROM daily");
if (mysql_num_rows($query)){
print "<table width='100%' height='100%' border='1'>
<tr>
<td>id</td>
<td>Grocery</td>
<td>Beverages</td>
<td>Beer</td>
<td>Pack</td>
<td>Tobacco</td>
<td>Carton</td>
<td>Candy</td>
<td>Non-Food</td>
<td>Paper</td>
<td>Misc</td>
<td>Foodstamp</td>
</tr>";
while($row = mysql_fetch_array($query)){
extract($row);
print "<tr>
<td>$id</td>
<td>$Grocery</td>
<td>$Beverages</td>
<td>$Beer</td>
<td>$Pack</td>
<td>$Tobacco</td>
<td>$Carton</td>
<td>$Candy</td>
<td>$Nonfood</td>
<td>$Paper</td>
<td>$Misc</td>
<td>$Foodstamp</td>";
}
print "</table>";
}
?>
<form action="">
<select>
<option><?php $query1 = mysql_query('select id FROM daily');
while($row = mysql_fetch_array($query1)){
extract($row);
print $id;
}
?></option>
</select>
</form>
i created this script where it get the data but it prints it in column which i created that way but i wanted to print one id at time in the row and iwant to select that id too rather then displaying all at same time