PDA

View Full Version : مبتدی: ساخت جدول و لینک به استایل



smemamian
سه شنبه 07 خرداد 1392, 20:00 عصر
سلام دوستان
من از دیتابیسم یک گزارش می خوام بگیرم که از این کد استفاده می کنم :





<?php
mysql_connect("localhost", "root", "mypass") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
$data = mysql_query("SELECT * FROM users")
or die(mysql_error());
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th>Name:</th> <td>".$info['0'] . "</td> ";
Print "<th>Pass:</th> <td>".$info['1'] . "</td> ";
Print "<th>Email:</th> <td>".$info['2'] . " </td></tr>";
}
Print "</table>";
?>

که به ازای هر رکورد در دیتابیس یه سطر درست میشه !

حالا چطوری می تونم فایل css زیر رو لینک بدم که جدولم استایل زیر رو داشته باشه :

table {
width: 650px;
border:1px solid #000000;
border-spacing: 0px; }

table a, table, tbody, tfoot, tr, th, td {
font-family: Arial, Helvetica, sans-serif;
}

table caption {
font-size: 1.8em;
text-align: left;
text-indent: 100px;
background: url(images/bg_caption.gif) left top;
height: 40px;
color: #FFFFFF;
border:1px solid #000000; }

thead th {
background: url(images/bg_th.gif) left;
height: 21px;
color: #FFFFFF;
font-size: 0.8em;
font-family: Arial;
font-weight: bold;
padding: 0px 7px;
margin: 20px 0px 0px;
text-align: left; }

tbody tr { background: #ffffff; }

tbody tr.odd { background: #f0f0f0; }

tbody th {
background: url(images/arrow_white.gif) left center no-repeat;
background-position: 5px;
padding-left: 40px !important; }

tbody tr.odd th {
background: url(images/arrow_grey.gif) left center no-repeat;
background-position: 5px;
padding-left: 40px !important; }

tbody th, tbody td {
font-size: 0.8em;
line-height: 1.4em;
font-family: Arial, Helvetica, sans-serif;
color: #000000;
padding: 10px 7px;
border-bottom: 1px solid #800000;
text-align: left; }

tbody a {
color: #000000;
font-weight: bold;
text-decoration: none; }

tbody a:hover {
color: #ffffff;
text-decoration: underline; }

tbody tr:hover th {
background: #800000 url(images/arrow_red.gif) left center no-repeat;
background-position: 5px;
color: #ffffff; }

tbody tr.odd:hover th {
background: #000000 url(images/arrow_black.gif) left center no-repeat;
background-position: 5px;
color: #ffffff; }

tbody tr:hover th a, tr.odd:hover th a {
color: #ffffff; }

tbody tr:hover td, tr:hover td a, tr.odd:hover td, tr.odd:hover td a {
background: #800000;
color: #ffffff; }

tbody tr.odd:hover td, tr.odd:hover td a{
background: #000000;
color: #ffffff; }

tfoot th, tfoot td {
background: #ffffff url(images/bg_footer.gif) repeat-x bottom;
font-size: 0.8em;
color: #ffffff;
height: 21px;
}

smemamian
چهارشنبه 08 خرداد 1392, 11:18 صبح
بله ... بالا