MVC功能没有给出结果

时间:2017-05-11 15:20:50

标签: php mysql model-view-controller software-design

最近我试图为我的软件工程课程项目做一个模型视图控制器。我的设备模型函数都工作正常,除了函数listallmydevices()idk whats正在进行并且没有错误可见。

注意我已将我的功能从另一个类更改为另一个列表功能,并且除了设备

之外它的工作正常

<html>
        
<head>
    <head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
</head>
    
  <style>
.dropdown-submenu 
      {
    position: relative;
     }

.dropdown-submenu .dropdown-menu 
{
    top: 0;
    left: 100%;
    margin-top: -1px;
}
</style>
    
   

<form action="../prototype/mvc/DeviceController.php" method="post" enctype="multipart/form-data">
    
    
<label for="id">ID:</label>
<input type="text" name="ID" >
 <br><br>
                                                                             
<label for="username">Device Name:</label>
<input type="text" id="un" name="Name">
<br><br>
    
<label for="lastname">Date:</label>
<input type="text" name="Date">
<br><br>
    
<label for="fs">Amount:</label>
<input type="text"  name="Amount">
<br><br> 
    
<label for="ls">Price:</label>
<input type="text" name="Price">
<br><br>
    
<label for="mail">Brand:</label>
<input type="mail" name="Brand">
<br><br> 
    
<label for="password">MarketingToolsID:</label>
<input type="password" name="MTID">
<br><br> 
    
<label for="password">Tochange: </label>
<input type="password" name="edit">
<br><br>

    <label for="password">Tochange: </label>
    <select name="Cateogry">
    
    <option>Price </option>
    <option>Amount </option>
    <option> Name</option>
    <option> </option>
    <option> </option>
    
    
    
    </select>
    <br>
    
        <input type="submit" name="DELETEDEVICE" value="DELETE DEVICE">
        <input type="submit" name="ADDDEVICE" value="ADD DEVICE" >
        <input type="submit" name="VIEWALLDEVICES" value="VIEW ALL DEVICES" >
        <input type="submit" name="EDITDEVICE" value="Edit  DEVICES" >
        

    
    </form>



-->
    

    
   
    
    

public static function listalldevices()
{
 $conn = mysqli_connect("localhost", "root", "", "bioster");

 $sql="Select * from device order by DeviceID";

 $devicequery= mysqli_query($conn,$sql) or die(mysqli_error($conn));

 $i=0;
 $result;

 while($row= mysqli_fetch_array($devicequery))
 {
     $devobj=new device($row["DeviceID"]);

     $result[$i]=$devobj;

     $i++;
 }
 return $result;


}

设备控制器

if(isset($_POST['VIEWALLDEVICES']))
 {

    $array= Device::listalldevices();

    echo "All devices";

    for($i=0; $i<count($array); $i++)
    {

        echo $array[$i]->DeviceID;
        echo $array[$i]->Name;
        echo $array[$i]->Date;
        echo $array[$i]->Amount;
        echo $array[$i]->Price;
        echo $array[$i]->Brand;
    }



} //check this not wotking

0 个答案:

没有答案