
Apr 16th, 2008, 06:26
|
|
SuperMember
|
|
Join Date: Apr 2007
Location: Brisbane, Australia
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Re: HTML, css and php
Quote:
Originally Posted by dab42pat
Can you show us one of your php pages you are having problems with the doctype, I suspect your problem may be that the php code is starting after your doctype giving you a "headers already sent" error.
As for the styling, until we see the code not much we can do.
HTH
Pat
|
Here is the code for a php page:
- PHP: Select all
<?php session_start();
//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>";
}
} } } }
?> <HTML> <HEAD> <STYLE> <!--
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> <body bgcolor="#D0E0F1" link="#000000">
<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>
Last edited by saltedm8; Apr 17th, 2008 at 10:00.
Reason: added [php] tags
|