Display script output in html page.
Posted: Sat Feb 27, 2010 2:04 am
I have a php script which outputs a table as a result of an sql query. I would like to display the result in an html page in a specific position alongside two forms.
The output will always be a standard matrix in terms of rows and columns.
I can create the html page and the php script could someone please advise how to intigrate the two?
Thanks
Dave
php script.
<?php
$Day = $_POST['Day'];
$Year =$_POST['Year'];
$Month =$_POST['Month'];
print "Day: {$_POST['Day']}<br />";
print "Year:{$_POST['Year']}<br/>";
print "Month:{$_POST['Month']}<br/>";
;
$username="user";
$password="pwd";
$database="my_db";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM courttimes1 Where Day2='$Day' AND Year1='$Year' AND Month1='$Month'";
if($result=mysql_query($query))
{
if($num=mysql_numrows($result) > 0)
{
}
else
{
echo "No Rows Returned";
}
}
else
{
echo "Query Error";
echo $query;
echo mysql_error();
}
$result=mysql_query($query);
$num=mysql_numrows($result);
echo "<b><center>Database Output</center></b><br><br>";
echo "<table border='1'>
<tr>
<th>Day1</th>
<th>FullDate</th>
<th>Court1 Time</th>
<th>Player1</th>
<th>Player2</th>
<th>Court2 Time</th>
<th>Player3</th>
<th>Player4</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Day1'] . "</td>";
echo "<td>" . $row['FullDate'] . "</td>";
echo "<td>" . $row['Court1 Time'] . "</td>";
echo "<td>" . $row['Player1'] . "</td>";
echo "<td>" . $row['Player2'] . "</td>";
echo "<td>" . $row['Court2 Time'] . "</td>";
echo "<td>" . $row['Player3'] . "</td>";
echo "<td>" . $row['Player4'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
The output will always be a standard matrix in terms of rows and columns.
I can create the html page and the php script could someone please advise how to intigrate the two?
Thanks
Dave
php script.
<?php
$Day = $_POST['Day'];
$Year =$_POST['Year'];
$Month =$_POST['Month'];
print "Day: {$_POST['Day']}<br />";
print "Year:{$_POST['Year']}<br/>";
print "Month:{$_POST['Month']}<br/>";
;
$username="user";
$password="pwd";
$database="my_db";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM courttimes1 Where Day2='$Day' AND Year1='$Year' AND Month1='$Month'";
if($result=mysql_query($query))
{
if($num=mysql_numrows($result) > 0)
{
}
else
{
echo "No Rows Returned";
}
}
else
{
echo "Query Error";
echo $query;
echo mysql_error();
}
$result=mysql_query($query);
$num=mysql_numrows($result);
echo "<b><center>Database Output</center></b><br><br>";
echo "<table border='1'>
<tr>
<th>Day1</th>
<th>FullDate</th>
<th>Court1 Time</th>
<th>Player1</th>
<th>Player2</th>
<th>Court2 Time</th>
<th>Player3</th>
<th>Player4</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Day1'] . "</td>";
echo "<td>" . $row['FullDate'] . "</td>";
echo "<td>" . $row['Court1 Time'] . "</td>";
echo "<td>" . $row['Player1'] . "</td>";
echo "<td>" . $row['Player2'] . "</td>";
echo "<td>" . $row['Court2 Time'] . "</td>";
echo "<td>" . $row['Player3'] . "</td>";
echo "<td>" . $row['Player4'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>