Guest User

Untitled

a guest
Jan 18th, 2016
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2.     //if(!isset($_SESSION)) header("location:../board.php");
  3.     $servername = "localhost";
  4.     $username = "root";
  5.     $password = "pass";
  6.     $dbname = "chat";
  7.     $cto=new PDO("mysql:host=$servername;dbname=$dbname",$username,$password);
  8.     switch($_POST['why']){
  9.         case "gclass":
  10.             $csql=$cto->prepare("SELECT * FROM class");
  11.             $csql->execute();
  12.             $col=[];
  13.             $cls=[];
  14.             while($r=$csql->fetch()){
  15.                 $col[]=$r['color'];
  16.                 $cls[]=$r['classes'];
  17.             }
  18.             $return=[
  19.                 'color'=>$col,
  20.                 "class"=>$cls,
  21.             ];
  22.             echo json_encode($return);
  23.             $cto=null;
  24.             die();
  25.         break;
  26.     }
  27. ?>>
Add Comment
Please, Sign In to add comment