- Code: Select all
view.php
<?php
//Get database credentials
require 'config.php';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
//select the database
mysql_select_db($dbname) or die('Cannot select database');
require 'header.php';
$query = "SELECT * FROM table1;";
$result = mysql_query($query) or die(mysql_error());
//Count the number of rows returned
$count = mysql_num_rows($result);
//Table header
echo "<div><table id=\"tableheader\" bgcolor=\"#4382b5\">\n";
echo "<tr>\n";
echo "<td> Column 1:</td>\n";
echo "<td> Column 2:</td>\n";
echo "<td> Column 3:</td>\n";
echo "<td> Column 4:</td>\n";
echo "<td> Column 5:</td>\n";
echo "</tr>";
echo "</table></div>";
if ($count !== 0) {
while($row = mysql_fetch_array($result)) {
echo "<div class=\"addform\"><form method='get' action=\"update.php\">\n";
echo " <input type=\"text\" value=\"".$row[column1]."\" name=\"column1\">\n";
echo " <input type=\"text\" name=\"column2\" value=\"".$row[column2]."\"/>\n";
echo " <input type=\"text\" name=\"column3\" value=\"".$row[column3]."\"/>\n";
echo " <input type=\"text\" name=\"column4\" value=\"".$row[column4]."\"/>\n";
echo " <input type=\"text\" name=\"column5\" value=\"".$row[column5]."\"/>\n";
echo " <input type=\"image\" src=\"images/update.png\" alt=\"Update Row\" class=\"update\" title=\"Update Row\">\n";
echo "<a href=\"delete.php?column1=".$row[column1]."\"><img title='Delete Row' alt=\"Delete\" class='del' src='images/delete.png'/></a></form></div>\n";
}
echo "</table><br />\n";
} else {
echo "<b><center>NO DATA</center></b>\n";
}
echo "<div>Add Row:</div>\n";
echo "<div class=\"addform\"><form method='get' action=\"add.php\">\n".
" <input type=\"text\" name=\"column1\"/>\n".
" <input type=\"text\" name=\"column2\"/>\n".
" <input type=\"text\" name=\"column3\"/>\n".
" <input type=\"text\" name=\"column4\"/>\n".
" <input type=\"text\" name=\"column5\"/>\n".
" <input type=\"image\" src=\"images/add.png\" alt=\"Add Row\" class=\"update\" title=\"Add Row\">\n".
"</form></div>";
?>
<div>
<br />
<b>Legend:</b>
<br />
<img alt="Add" src="images/add.png"> Add a row after entering the correct information.<br />
<img alt="Update" src="images/update.png"> Update a row after editing it.<br />
<img alt "Delete" src="images/delete.png"> Delete a row.<br />
</div>
</body>
</html>
- Code: Select all
Style.css
body
{
color: black;
background-color: #FFFFFF;
font-family: Verdana, sans-serif;
font-size: 10pt;
font: bold 11px/1.5em Verdana;
}
table
{
width: 690px;
border-collapse: collapse;
padding: 0px 0px 0px 0px;
font-size: 10pt;
color: white;
}
td
{
padding: 1px 0px 0px 0px;
text-decoration: none;
font-size: 10pt;
width: 150px;
}
input
{
position: relative;
left: 4px;
font-family: Verdana, sans-serif;
padding: 0px 0px 0px 0px;
text-decoration: none;
font-size: 10pt;
width: 130px;
}
a, img
{
padding: 0px;
color: black;
text-decoration: none;
border-width: 0px;
font-family: Verdana;
font-size: 10pt;
}
.del
{
position: relative;
top: 2px;
left: 6px;
padding: 0px;
border: 0px;
margin: 0px;
}
.update
{
position: relative;
top: 2px;
left: 6px;
padding: 0px;
border: 0px;
margin: 0px 3px 0 0;
height: 16px;
width: 16px;
}
.add
{
margin: 5px 5px 5px 0px;
width: 110px;
}
.button
{
width: 60px;
}
.addform
{
width: 720px;
margin-bottom: -14px;
padding: 0px 0 0 0;
}
.empnum
{
width: 60px
}
h1 {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:16px;
font-weight:bold;
margin:0;
padding:0;
}
hr {
border:none;
border-top:1px solid #CCCCCC;
height:1px;
margin-bottom:25px;
}
#tabs {
float:left;
width:100%;
background:#efefef;
font-size:93%;
line-height:normal;
border-bottom:1px solid #666;
}
#tabs ul {
margin:0;
padding:10px 10px 0 50px;
list-style:none;
}
#tabs li {
display:inline;
margin:0;
padding:0;
}
#tabs a {
float:left;
background:url("tableft.gif") no-repeat left top;
margin:0;
padding:0 0 0 4px;
text-decoration:none;
}
#tabs a span {
float:left;
display:block;
background:url("tabright.gif") no-repeat right top;
padding:5px 15px 4px 6px;
color:#666;
}
/* Commented Backslash Hack hides rule from IE5-Mac \*/
#tabs a span {float:none;}
/* End IE5-Mac hack */
#tabs a:hover span {
color:#FFF;
}
#tabs a:hover {
background-position:0% -42px;
}
#tabs a:hover span {
background-position:100% -42px;
}
Again thanks in advance
Kyle


whats going on? Stupid piece of code!