Web Design and Development Forums

HTML, css and php

This is a discussion on "HTML, css and php" within the HTML Forum section. This forum, and the thread "HTML, css and php are both part of the Design Your Website category.

Old Apr 15th, 2008, 06:58   #1 (permalink)
New Member
 
Join Date: Apr 2007
Location: Brisbane, Australia
Posts: 7
Question HTML, css and php

Hi, I am building an on-line shop website which has php scripts to handle the shopping functions, also HTML pages. With the HTML pages, I am using linked css, but have not been able to do this with the php scripts, although they have HTML code. Consequently, the formatting in the menu bars looks different on different pages. I can insert styles in the HTML sections of the individual php pages, but still can't get the appearance identical. Also, the php pages do not like a "DOCTYPE" declaration. Can anyone help or direct me to any resources regarding this problem.
Thanks in advance.
gecko is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 15th, 2008, 08:41   #2 (permalink)
 
Join Date: Jun 2007
Location: uk
Posts: 459
Re: HTML, css and php

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
dab42pat is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 16th, 2008, 06:26   #3 (permalink)
New Member
 
Join Date: Apr 2007
Location: Brisbane, Australia
Posts: 7
Re: HTML, css and php

Quote:
Originally Posted by dab42pat View Post
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
gecko is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 16th, 2008, 12:10   #4 (permalink)
 
Join Date: Jun 2007
Location: uk
Posts: 459
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>
dab42pat is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 17th, 2008, 07:44   #5 (permalink)
New Member
 
Join Date: Apr 2007
Location: Brisbane, Australia
Posts: 7
Re: HTML, css and php

Thanks Pat,
I altered the code as you suggested. The display is OK, but if I try linking to the external style sheet rather than using embedded style, it still won't work. However, after fiddling with the styles in both locations, the display is close (but not identical) on the html and php pages.

Thanks for your help.
Gecko
gecko is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re-write rule to ensure that a .html is added to the end of all static html pages.? jonbey Apache and IIS 1 Mar 31st, 2008 08:36
Help with HTML cewgirl HTML Forum 6 Jun 7th, 2007 17:12
Help with HTML kaz HTML Forum 6 Aug 9th, 2006 19:13
Can I do this with html or anything else??? Petey_ HTML Forum 2 May 31st, 2006 21:04
PHP within HTML stickywicket PHP Forum 0 Dec 6th, 2005 19:05



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 19:09.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59