comparison php/read/getAllSavedBooks.php @ 6:077b0a0a3e6d

remaining originals according to dependency walk
author Robert Boland <robert@markup.co.uk>
date Thu, 16 Feb 2017 22:29:02 +0000
parents
children 385ddd7c4b55 d606320ec331
comparison
equal deleted inserted replaced
5:55445b456ad0 6:077b0a0a3e6d
1 <?PHP
2
3 if(isset($ret))
4 {
5 include "../../private/db.php";
6 }
7 else
8 {
9 include "../../../private/db.php";
10 }
11
12 $savedBooks = 0;
13
14 //$UserID = $_GET['User'];
15
16 if(isset($_GET['User'])){
17 $UserID = $_GET['User'];
18 }
19 else{
20 $UserID = 0; //default user is Bestseller
21 }
22
23 $query = "CALL b_getAllSavedBooksByUser($UserID)";
24 // $output .= $query;
25 $results = mysqli_query($link, $query) or exit( mysqli_error( $link ));
26
27 $output = "";
28
29 $output .= "<?xml version=\"1.0\"?>";
30 $output .= "<results>";
31 $output .= "<UserID>" . htmlspecialchars(trim($UserID)) . "</UserID>";
32
33 $prevListName = "";
34
35 while($line = mysqli_fetch_assoc($results)) {
36
37 $listName = htmlspecialchars(trim($line["SavedListName"]));
38
39 if($listName != $prevListName)
40 {
41 if($savedBooks != 0)
42 {
43 $output .= "</ListDetails>";
44 $output .= "</List>";
45 }
46 $output .= "<List>";
47 $output .= "<SavedListName>" . $listName . "</SavedListName>";
48 $output .= "<ListDetails>";
49 $prevListName = $listName;
50 }
51
52 $output .= "<Book>";
53 $output .= "<ISBN>" . htmlspecialchars(trim($line["ISBN"])) . "</ISBN>";
54 $output .= "<PictureURL>" . htmlspecialchars(trim($line["PictureURL"])) . "</PictureURL>";
55 $output .= "<BookTitle>" . htmlspecialchars(trim($line["BookTitle"])) . "</BookTitle>";
56 $output .= "<SaveID>" . htmlspecialchars(trim($line["SaveID"])) . "</SaveID>";
57 $output .= "</Book>";
58
59 $savedBooks++;
60 }
61
62 if($savedBooks != 0)
63 {
64 $output .= "</ListDetails>";
65 $output .= "</List>";
66 }
67 $output .= "</results>";
68
69 if(isset($ret))
70 return $output;
71 else
72 echo $output;
73
74 mysqli_close($link);
75
76
77 ?>