kingpoiuy
May 2nd, 2008, 02:46 PM
Ok, so I've been trying to get a useful database webpage up and running. I am using PHP & MySQL. I know a little bit about php but haven't been using it for a long time. I have one webpage with checkboxes and I want it to only display the selected colums when I click the button.
Anyone know why the following displays a blank table?
Here is the php/mysql page:
<?php
include 'config.php';
include 'opendb.php';
include 'serialdbindex.php';
$query = "SELECT '$_POST[computer]','$_POST[user]','$_POST[windows]',
'$_POST[office]','$_POST[antivirus]','$_POST[description]' FROM main" ;
$result = mysql_query($query) or die('Error, query failed');
echo "<table border='1' align='center'>
<tr>
<th>Computer</th>
<th>User</th>
<th>Windows</th>
<th>Office</th>
<th>Anti-Virus</th>
<th>Description</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['computer'] . "</td>";
echo "<td>" . $row['user'] . "</td>";
echo "<td>" . $row['windows'] . "</td>";
echo "<td>" . $row['office'] . "</td>";
echo "<td>" . $row['antivirus'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "</tr>";
}
echo "</table>";
include 'closedb.php';
?>
Here is the webpage to call for it:
<html>
<body>
<?php
include 'serialdbindex.php'
?>
<table align='center'>
<form action="viewtable.php" method="post" >
<tr>
<td>
<input type="checkbox" name="computer" >
Computer
</td>
</tr>
<form action="viewtable.php" method="post" >
<tr>
<td>
<input type="checkbox" name="user" >
User
</td>
</tr>
<form action="viewtable.php" method="post" >
<tr>
<td>
<input type="checkbox" name="windows" >
Windows
</td>
</tr>
<form action="viewtable.php" method="post" >
<tr>
<td>
<input type="checkbox" name="office" >
Office
</td>
</tr>
<form action="viewtable.php" method="post" >
<tr>
<td>
<input type="checkbox" name="antivirus" >
Anti-Virus
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" >
</td>
</tr>
</form>
</body>
</html>
I have made this page which just display's everything and it works fine:
<?php
include 'config.php';
include 'opendb.php';
include 'serialdbindex.php';
$query = "SELECT * FROM main" ;
$result = mysql_query($query) or die('Error, query failed');
echo "<table border='1' align='center'>
<tr>
<th>Computer</th>
<th>User</th>
<th>Windows</th>
<th>Office</th>
<th>Anti-Virus</th>
<th>Description</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['computer'] . "</td>";
echo "<td>" . $row['user'] . "</td>";
echo "<td>" . $row['windows'] . "</td>";
echo "<td>" . $row['office'] . "</td>";
echo "<td>" . $row['antivirus'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
}
echo "</table>";
include 'closedb.php';
?>
Any ideas? I've looked around at alot of tutorials and varous pages but can't seem to find the solution.
Thanks!
Anyone know why the following displays a blank table?
Here is the php/mysql page:
<?php
include 'config.php';
include 'opendb.php';
include 'serialdbindex.php';
$query = "SELECT '$_POST[computer]','$_POST[user]','$_POST[windows]',
'$_POST[office]','$_POST[antivirus]','$_POST[description]' FROM main" ;
$result = mysql_query($query) or die('Error, query failed');
echo "<table border='1' align='center'>
<tr>
<th>Computer</th>
<th>User</th>
<th>Windows</th>
<th>Office</th>
<th>Anti-Virus</th>
<th>Description</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['computer'] . "</td>";
echo "<td>" . $row['user'] . "</td>";
echo "<td>" . $row['windows'] . "</td>";
echo "<td>" . $row['office'] . "</td>";
echo "<td>" . $row['antivirus'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "</tr>";
}
echo "</table>";
include 'closedb.php';
?>
Here is the webpage to call for it:
<html>
<body>
<?php
include 'serialdbindex.php'
?>
<table align='center'>
<form action="viewtable.php" method="post" >
<tr>
<td>
<input type="checkbox" name="computer" >
Computer
</td>
</tr>
<form action="viewtable.php" method="post" >
<tr>
<td>
<input type="checkbox" name="user" >
User
</td>
</tr>
<form action="viewtable.php" method="post" >
<tr>
<td>
<input type="checkbox" name="windows" >
Windows
</td>
</tr>
<form action="viewtable.php" method="post" >
<tr>
<td>
<input type="checkbox" name="office" >
Office
</td>
</tr>
<form action="viewtable.php" method="post" >
<tr>
<td>
<input type="checkbox" name="antivirus" >
Anti-Virus
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" >
</td>
</tr>
</form>
</body>
</html>
I have made this page which just display's everything and it works fine:
<?php
include 'config.php';
include 'opendb.php';
include 'serialdbindex.php';
$query = "SELECT * FROM main" ;
$result = mysql_query($query) or die('Error, query failed');
echo "<table border='1' align='center'>
<tr>
<th>Computer</th>
<th>User</th>
<th>Windows</th>
<th>Office</th>
<th>Anti-Virus</th>
<th>Description</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['computer'] . "</td>";
echo "<td>" . $row['user'] . "</td>";
echo "<td>" . $row['windows'] . "</td>";
echo "<td>" . $row['office'] . "</td>";
echo "<td>" . $row['antivirus'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
}
echo "</table>";
include 'closedb.php';
?>
Any ideas? I've looked around at alot of tutorials and varous pages but can't seem to find the solution.
Thanks!