我有這個代碼,從一個MySQL表獲取所有記錄,並執行開關stateform:的mysql_query返回0元
<?php
$DB_host = 'localhost';
$DB_user = 'user';
$DB_password = 'pwf';
$DB_name = 'dbname';
$connessione = mysql_connect($DB_host, $DB_user, $DB_password);
$db_obj = mysql_query("SELECT * FROM `dbname`.`table`")or die("Query not valid: " . mysql_error());
$i = 0;
foreach ($db_obj as $dato) {
$i++;
switch ($dato->turno) {
case 0:
$desc = 'Mattina';
$col = 'bg-color-redLight';
break;
case 1:
$desc = 'Pomeriggio';
$col = 'bg-color-greenLight';
break;
case 2:
$desc = 'Notte';
$col = 'bg-color-blueLight';
break;
case 3:
$desc = 'Smonto Notte';
$col = 'bg-color-yellow';
break;
case 4:
$desc = 'Riposo';
$col = 'bg-color-orange';
break;
}
}
?>
爲什麼結果是$ db_obj是empy?在表中有3條記錄.. 你能幫我嗎?
唉... **的mysql _ *** – 2014-09-28 16:59:45