Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 22nd, 2006, 10:30 AM
Authorized User
 
Join Date: Dec 2006
Location: , , Sweden.
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

Reply With Quote
  #2 (permalink)  
Old December 23rd, 2006, 08:14 AM
Authorized User
 
Join Date: Oct 2006
Location: , , .
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::.

Reply With Quote
  #3 (permalink)  
Old December 25th, 2006, 04:48 AM
Authorized User
 
Join Date: Dec 2006
Location: , , Sweden.
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

Reply With Quote
  #4 (permalink)  
Old December 25th, 2006, 07:16 AM
Authorized User
 
Join Date: Oct 2006
Location: , , .
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::.


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:28 PM.


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