View Single Post
  #4 (permalink)  
Old Apr 16th, 2008, 12:10
dab42pat dab42pat is online now
SuperMember

SuperMember
Join Date: Jun 2007
Location: uk
Posts: 459
Thanks: 0
Thanked 0 Times in 0 Posts
Re: HTML, css and php

Hmm!

Strange for some reason with your php code located where it is it will not see a doctype.

I have done a few alterations to the code but cant test the output for obvious reasons.

It will now see a doctype and validate. Can you check the output for me.

Pat

PHP: Select all

 <?php
session_start
();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--

h1, h2, h3 {color: red}
h1, h2, h3 {font-family: Arial, Helvitica, "sans-serif"}

h1 {text-transform: uppercase;
text-decoration: underline;
text-align: center}

body {font-family: Arial, Helvitica, "sans-serif"}
a {color: black;}
a:link {color: black;}
a:visited {color:blue;}
a:active {color: red;}

#navcontainer {background-color: rgb(139,179,220);
height: 32px; padding-bottom: 0px;}
ul #navlist {margin-left: 0; padding-left:0; white-space: nowrap; float:left;}
#navlist li {display: inline; list-style-type: none; padding-top: 12px;padding-right:20px;}

#navlist a:link, #navlist a:visited {color: black;
text-decoration : none; text-align: center;
text-transform: uppercase;font-size: 12px; font-weight: bold; letter-spacing: 1px;
min-width: 10px; border-right: rgb(206,222,238); border-right-width: 2px; padding: 8px 20px 10px 10px;}

#logo {padding-bottom: 12px;}



-->
</style>
<title>Categories</title>

</head>

<body bgcolor="#D0E0F1" link="#000000">
<?php
//connect to database
$conn mysql_connect("localhost""user","my_pass")
or die(
mysql_error());
mysql_select_db("products",$conn) or die(mysql_error());

$display_block "<h1>Products</h1>

<p>Select a category to view items.</P>"
;

//show categories

$get_cats "select id, cat_title, cat_desc from
product_categories"
;
$get_cats_res mysql_query($get_cats) or die(mysql_error());

if (
mysql_num_rows($get_cats_res) <1) {
$display_block "<P><em> There are no categories to browse.</em></P>";
} else {

while (
$cats mysql_fetch_array($get_cats_res)) {
$cat_id $cats[id];
$cat_title strtoupper(stripslashes($cats[cat_title]));
$cat_desc stripslashes($cats[cat_desc]);

$display_block .="<P><strong><a
href=\"$SERVER[PHP_SELF]?cat_id=$cat_id\">$cat_title</a></strong>
<br>$cat_desc</P>"
;

if (
$_GET[cat_id] ==$cat_id) {
//var_dump ($_GET[cat_id]);

//get items
$get_items ="select id, item_name, item_desc, item_thumb
from product_items
where cat_id = $cat_id order by item_name"
;

$get_items_res mysql_query($get_items) or die(mysql_error());
$num mysql_num_rows($get_items_res);

if(
mysql_num_rows($get_items_res) < 1) {
$display_block "<P><em>Sorry, no items in this category.</em></P>";

} else {

$cols = ($num/2);
$times 0;
$counter 0;

$display_block .= "

<table cellspacing=3 cellpadding=1 border=1 width=98%>
<tr>
<th>Product</th>
<th>Name</th>
<th>Description</th>
<th>Action</th>
</tr>"
;

while (
$items mysql_fetch_array($get_items_res)) {

$item_id $items['id'];
$item_title stripslashes($items['item_name']);
$item_desc substr($items['item_desc'],0,40);
$item_desc_brief = ($item_desc."...");
$item_thumb $items['item_thumb'];

$display_block .= "<tr>
<td valign=middle align=center><img src=\"$item_thumb \"
alt =\"Image not available\"></td>
<td align=center><strong>$item_title</strong></td>
<td valign=middle align=center>$item_desc_brief</td>
<td align=center>
<form method=post action= \"prod_display.php\">
<p><strong>Select Currency</strong><br><br>
<input type=\"radio\" name=\"curr\" value=\"us\"><strong>US Dollars</strong>
<br>
<input type=\"radio\" name=\"curr\" value=\"aus\"><strong>AU Dollars</strong>

<input type =\"hidden\" name=\"item_id\" value=\"$item_id\">
<p><input type =\"submit\" name=\"submit\" value=\"View\"></p>
</form>

</tr>"
;


}


}
}
}
}

?>
<div id="logo" align="center">
<img border="0" src="healthlogo.gif" alt="health secrets logo" width="746" height="174" align="center">
</div>

<div id="navcontainer">
<ul id="navlist">

<li><a href="http://localhost/healthsecrets_new/index.html">HOME</a></li>
<li><a href="http://localhost/healthsecrets/health_headings.php">HEALTH INFORMATION</a></li>
<li><a href="contact_us.html">CONTACT US</a></li>
</ul>
</div>


<?php echo $display_block?>
</body>
</html>
Reply With Quote