Advertisement
Guest User

Untitled

a guest
Nov 16th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php
  2. $Set_ID = $_POST['Set_ID'];
  3. $dbhost = 'localhost';
  4. $dbuser = 'id104366_stashcardrw';
  5. $dbpass = 'stashcarddb';
  6.  
  7.  
  8. // Create connection
  9. $mysqli = new mysqli($dbhost, $dbuser, $dbpass, "id104366_stashcards");
  10. if ($mysqli->connect_errno) {
  11. echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
  12. }
  13.  
  14.  
  15. $sql = "SELECT BackText, creator, Set_ID, FrontText, Set_Rating FROM Cards WHERE Set_ID = $User_Set_ID";
  16.  
  17. if(!$result = $mysqli->query($sql)){
  18. die('There was an error running the query [' . $conn->error . ']');
  19. }
  20.  
  21. $result = $mysqli->query($sql);
  22. $json = array();
  23.  
  24. while($row = $result->fetch_assoc()) {
  25. $bus = array(
  26. 'BackText' => $row['BackText'];
  27. 'Creator' => $row['creator'];
  28. 'Set_ID' => $row['Set_ID'];
  29. 'FrontText' => $row['FrontText'];
  30. 'Set_Rating' => $row['Set_Rating'];
  31. );
  32. array_push($json, $bus);
  33. }
  34.  
  35. $json_result = json_encode($json);
  36.  
  37. echo " " . $json_result ;
  38. $conn->close();
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement