|
|
|
ช่วยดู code หน่อยค่ะ ว่ามันผิดตรงไหน เรื่อง สลับสีตาราง |
|
|
|
|
|
|
|
//code
<?
$intRows = 0;
$sql = "SELECT * FROM user_mst ORDER BY user_id ";
$result = mysql_db_query($dbname,$sql);
$num = mysql_num_rows($result);
$rcolor="#FFFFFF";
while($rs = mysql_fetch_array($result))
{
$intRows++;
if($intRows%2=0)
{
$rcolor="#F5F5F5";
}
else
{
$rcolor="#FFFFFF";
}
$user_id = $rs[user_id];
$user_name = $rs[user_username];
$fname = $rs[user_fname];
$lname = $rs[user_lname];
$create_date = $rs[user_createdate];
$last_log = $rs[user_lastlogindate];
$last_update = $rs[user_updatedate];
$user_type = $rs[user_usertype_id];
?>
<tr bgcolor="<?=$rcolor?>">
<td valign="top" align="right"></td>
<td valign="top"><?=$user_id?></td>
<td valign="top"><?=$user_name?></td>
<td valign="top"><?=$fname?> <?=$lname?></td>
<td valign="top"><?=$create_date?></td>
<td valign="top"><?=$last_log?></td>
<td valign="top"><?=$last_update?></td>
<td valign="top"><?=$user_type?></td>
<td valign="top"><?=$user_status?></td>
<td valign="top" align="center"><input type="checkbox" name="del_all" /></td>
</tr>
<?
}
?>
<tr>
<td valign="top"></td>
<td valign="top"></td>
<td valign="top"></td>
<td valign="top"></td>
<td valign="top"></td>
<td valign="top"></td>
<td valign="top"></td>
<td valign="top"></td>
<td valign="top"></td>
<td align="center" valign="top"><input type="button" name="del_all" value="Delete Select" /></td>
</tr>
</table>
|
|
|
|
|
Date :
18 ส.ค. 2551 18:43:56 |
By :
@W_IN |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากค่ะ คุณ @W_IN
|
|
|
|
|
Date :
18 ส.ค. 2551 19:01:21 |
By :
sakura |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
</tr>
<?
$i=0;
while($objResult = mysql_fetch_array($objQuery))
{
$i++;
if($i%2==0)
{
$bg = "#CCCCCC";
}
else
{
$bg = "#FFFFFF";
}
?>
<tr bgcolor="<?=$bg;?>">
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
</body>
</html>
|
|
|
|
|
Date :
2009-05-28 18:30:45 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|