Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 22nd, 2006, 10:30 AM
Authorized User
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Formatting php with css

Hi!
I got stuck with a problem I hope you can help me with.
When using simple php nested in html my stylesheets works fine, but when using more advance code like dataretriving from mysql nothing works. What I want is to format my table with the data from my database. Ive tried with adding font-face to body, table, tr, td but nothing works.

Code:
<html>
<head>
<title>Untitled</title>
</head>
<link href='res/mall.css' type='text/css' rel='stylesheet'>

<body>

<?php
include 'connect.php';

# Här kan man trixa med databasen
// HTML-tabellens formatering - tabellstart
echo "<table id='historik_table'>";
echo "<tr bgcolor='#cccccc'><td>Transnr</td><td>Datum</td><td>typ</td><td>Antal</td><td>Sign</td><td>Referens</td></tr>";

# Hämtar all info från artikel
$artikel = mysql_query("SELECT * FROM historik ORDER BY transnr ASC") or die(mysql_error());
while($row = mysql_fetch_array( $artikel ))
    {
        #skriver ut innehÃ¥ller radvis
        echo "<tr><td>"; 
        echo $row['transnr'];
        echo "</td><td>";
        echo $row['datum'];
        echo "</td><td>";
        echo $row['typ'];
        echo "</td><td>";
        echo $row['antal'];
        echo "</td><td>";
        echo $row['sign'];
        echo "</td><td>";
        echo $row['referens'];
        echo "</td></tr>"; 
        #echo "<BR />";
    }


# stänger ner databaskopplingen
mysql_close($opendb);
?>
Datum
datum 

</body>
</html>
mall.css
Code:
/* CSS Document */
<STYLE type="text/css">
{
body
    {
    font-family: Verdana;
    font-size: 10px;
    padding: 0;
    margin: 0;
    }
td
    {
    font-family: Verdana;
    font-size: 10px;
    }

tr
    {
    font-family: Verdana;
    font-size: 10px;
    }
It still shows the default font and size.
Can anyone help me??
Cant see anything wrong...

Regards, and a merry christmas!!
/Hylsan

 
Old December 23rd, 2006, 08:14 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello hylsan,

  try to close your CSS code

try like this:
/* CSS Document */
<STYLE type="text/css">
{
body
    {
    font-family: Verdana;
    font-size: 10px;
    padding: 0;
    margin: 0;
    }
td
    {
    font-family: Verdana;
    font-size: 10px;
    }

tr
    {
    font-family: Verdana;
    font-size: 10px;
    }
</style>

 or what if you will use internal cascading like this:

<html>
<head>
<title>Untitled</title>
<STYLE type="text/css">
{
body
    {
    font-family: Verdana;
    font-size: 10px;
    padding: 0;
    margin: 0;
    }
td
    {
    font-family: Verdana;
    font-size: 10px;
    }

tr
    {
    font-family: Verdana;
    font-size: 10px;
    }
</style>
</head>
<body>

<?php
include 'connect.php';

# Här kan man trixa med databasen
// HTML-tabellens formatering - tabellstart
echo "<table id='historik_table'>";
echo "<tr bgcolor='#cccccc'><td>Transnr</td><td>Datum</td><td>typ</td><td>Antal</td><td>Sign</td><td>Referens</td></tr>";

# Hämtar all info från artikel
$artikel = mysql_query("SELECT * FROM historik ORDER BY transnr ASC") or die(mysql_error());
while($row = mysql_fetch_array( $artikel ))
    {
        #skriver ut innehÃ¥ller radvis
        echo "<tr><td>";
        echo $row['transnr'];
        echo "</td><td>";
        echo $row['datum'];
        echo "</td><td>";
        echo $row['typ'];
        echo "</td><td>";
        echo $row['antal'];
        echo "</td><td>";
        echo $row['sign'];
        echo "</td><td>";
        echo $row['referens'];
        echo "</td></tr>";
        #echo "<BR />";
    }

  or visit this link---> http://www.w3schools.com/css/default.asp

_________________________________________
.::If you quit you loss, If you survive you win::.

.::JHANNY::.

 
Old December 25th, 2006, 04:48 AM
Authorized User
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My bad, I didnt copy all of it, I do have closed the css-code properly. Just before I went home I got it to work. As long as I had the css inside the html it worked, but nothing happend when using external linking. I use the same css-template in other documents so there shouldnt be any wrong there.

Thanks!
/Hylsan

 
Old December 25th, 2006, 07:16 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

  i think your localhost can't find where your css external file have been saved..
or maybe is just and error coding....

try like this:

<link rel="stylesheet" type="text/css"
href="res/mall.css" />

__________________________________________
.::If you quit you loss, If you survive you win::.

.::JHANNY::.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Css formatting problem beetle_jaipur CSS Cascading Style Sheets 2 June 5th, 2009 07:16 AM
CSS HELP:! CSS EXPANDIBLE BACKGROUND FOR TITLE phpuser2000 CSS Cascading Style Sheets 2 December 19th, 2007 12:36 AM
Rich's new CSS book: Beginning CSS 2nd Edition jminatel BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 0 June 15th, 2007 11:55 AM
CSS formatting LoneStar1 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 April 10th, 2006 09:16 AM
PHP formatting input text shahchi1 Pro PHP 2 June 9th, 2004 04:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.