如何將sql資料撈出來後顯示在網頁table裡面

edited 三月 2014 in 資料庫
希望能夠做成像這樣
http://model.win-e.com.tw/multi_filter_select.php

我的程式碼
不知道是不是有哪邊沒有寫好,資料一直沒辦法顯示出來
<?php
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL connection');
    mysql_query("SET NAMES 'utf8'");
    mysql_select_db($dbname);
    $sql = "SELECT count(*) FROM `addbuy`;";
    $result = mysql_query($sql) or die('MySQL query error');
    $row = mysql_fetch_array($result);    
    $count= $row[0];

    for ( $i=0; $i<$count; $i++ )
	{
		if($i!=0)
		{
			list($KEYSERIAL1, $PRODUCT1, $EXPIREDAY1, $CHECKDAY1, $KEYLOCK1, $SETTIME1) = mysql_fetch_row($result);
		}
		else
		{
			$KEYSERIAL1=$row['KEYSERIAL'];
			$PRODUCT1=$row['PRODUCT'];
			$EXPIREDAY1=$row['EXPIREDAY'];
			$CHECKDAY1=$row['CHECKDAY'];
			$KEYLOCK1=$row['KEYLOCK'];
			$SETTIME1=$row['SETTIME'];
		}
			  switch($PRODUCT1)//轉換成中文顯示
	  {
		  case "PT_SMP":
		  $PRODUCT1 = "專業版";
		  break;
		  
		  case "PT_SMD":
		  $PRODUCT1 = "加購版";
		  break;
		  
		  case "PT_SMQ":
		  $PRODUCT1 = "精華版";
		  break;
		  
		  case "PT_SMS":
		  $PRODUCT1 = "菁英版";
		  break;
	  }  
		echo "<tr class='gradeC'>";
        echo "<td>";
        echo $KEYSERIAL1;
		echo "</td>";
        echo "<td>";
        echo $PRODUCT1;
		echo "</td>";
        echo "<td>";
        echo $EXPIREDAY1;
		echo "</td>";
        echo "<td>";
        echo $CHECKDAY1;
		echo "</td>";
        echo "<td>";
        echo $KEYLOCK1;
		echo "</td>";
        echo "<td>";
        echo $SETTIME1;
		echo "</td></tr>";
    }
echo "</tbody>";
?>

評論

Sign In or Register to comment.