select for php / mysql中的case语句

时间:2012-01-16 01:56:05

标签: phpmyadmin

下午好 我有一张桌子 客户ID,名称,计算机,笔记本电脑,等等,等等等等 1,John Doe,Acer,1,blah,blah,blah

现在我必须在所有其他select语句和连接中使用select case语句,但是我收到此错误“ 未定义的索引:第81行的D:\ WebShare \ Students \ Term \ 2LateFall \ PHP \ CombsW \ Index.php中的IsLaptop

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php

echo '<h1>Customers:</h1>';


require_once ('mysqli_connect.php');

$q = "SELECT CONCAT(left(FirstName,1),left(MiddleName,1),LastName) AS UserName,
      CONCAT(LastName, ', ', FirstName, ' ', MiddleName) AS Name,
      (NewCustomerID) AS customerid,
      (OldCustomerID) AS oldcustomerid,
      (birthmonth.Description) as birthmonth,
      (cars.Description) AS cartype,
      (carcolor.Description) AS carcolor,     
      (computers.Description) AS computer,
      (race.Description) AS race,
      (residence.Description) AS residence,
      (IsLaptop) AS IsLaptop




  FROM customer
    INNER JOIN cars ON(customer.CarID = cars.CarID)
    INNER JOIN birthmonth ON(customer.BirthMonthID = birthmonth.BirthMonthID)
    INNER JOIN carcolor ON (customer.CarColorID = carcolor.CarColorID)
    INNER JOIN computers ON (customer.ComputerID = computers.ComputerID)
    INNER JOIN race ON(customer.RaceID = race.RaceID)
    INNER JOIN residence ON(customer.ResidenceID = residence.ResidenceID)

WHERE (NewCustomerID) >= 500 and (NewCustomerID) <= 600
order by LastName, FirstName

       "; 
$r = mysqli_query ($dbc, $q ); if(!$r){die(mysqli_error($dbc));}
$num = mysqli_num_rows($r);

if ($num >0) {
    echo "<p> There are currently $num of customers.</p><br/>";


    echo '<table  border="1">
              <tr>
                <td>Customer ID</td>
                <td>Old Customer ID</td>
                <td>Customer Name</td>
                <td>UserName</td>
                <td>Car</td>
                <td>Car Color</td>
                <td>Birth Month</td>
                <td>Computer Brand</td>
                <td>Laptop</td>
                <td>Race</td>
                <td>Residence</td>



              </tr>';

        while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
        echo   '<tr>
                <td>' . $row['customerid']. '</td>
                <td>' . $row['oldcustomerid']. '</td>
                <td>' . $row['Name'].'</td>
                <td>' . $row['UserName'].'</td>
                <td>' . $row['cartype'].'</td>
                <td>' . $row['carcolor'].'</td>
                <td>' . $row['birthmonth'].'</td>
                <td>' . $row['computer'].'</td>
                <td>' . $row['IsLaptop'].'</td>
                <td>' . $row['race'].'</td>
                <td>' . $row['residence'].'</td>


                </tr>'; }

        echo '</table>';
            mysqli_free_result ($r);
} else {
    echo '<p class="error">There are currently no records to show</p>';
}
mysqli_close($dbc);

?>




</body>
</html>

1 个答案:

答案 0 :(得分:0)

islaptop应该是我认为的变量?,在php那个

$islaptop