Mercurial > hg > ywww
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/php/read/getAllSavedBooks.php Thu Feb 16 22:29:02 2017 +0000 @@ -0,0 +1,77 @@ +<?PHP + +if(isset($ret)) +{ + include "../../private/db.php"; +} +else +{ + include "../../../private/db.php"; +} + +$savedBooks = 0; + +//$UserID = $_GET['User']; + +if(isset($_GET['User'])){ + $UserID = $_GET['User']; +} +else{ + $UserID = 0; //default user is Bestseller +} + +$query = "CALL b_getAllSavedBooksByUser($UserID)"; +// $output .= $query; +$results = mysqli_query($link, $query) or exit( mysqli_error( $link )); + +$output = ""; + +$output .= "<?xml version=\"1.0\"?>"; +$output .= "<results>"; +$output .= "<UserID>" . htmlspecialchars(trim($UserID)) . "</UserID>"; + +$prevListName = ""; + +while($line = mysqli_fetch_assoc($results)) { + + $listName = htmlspecialchars(trim($line["SavedListName"])); + + if($listName != $prevListName) + { + if($savedBooks != 0) + { + $output .= "</ListDetails>"; + $output .= "</List>"; + } + $output .= "<List>"; + $output .= "<SavedListName>" . $listName . "</SavedListName>"; + $output .= "<ListDetails>"; + $prevListName = $listName; + } + + $output .= "<Book>"; + $output .= "<ISBN>" . htmlspecialchars(trim($line["ISBN"])) . "</ISBN>"; + $output .= "<PictureURL>" . htmlspecialchars(trim($line["PictureURL"])) . "</PictureURL>"; + $output .= "<BookTitle>" . htmlspecialchars(trim($line["BookTitle"])) . "</BookTitle>"; + $output .= "<SaveID>" . htmlspecialchars(trim($line["SaveID"])) . "</SaveID>"; + $output .= "</Book>"; + + $savedBooks++; +} + + if($savedBooks != 0) + { + $output .= "</ListDetails>"; + $output .= "</List>"; + } +$output .= "</results>"; + +if(isset($ret)) + return $output; +else + echo $output; + +mysqli_close($link); + + +?> \ No newline at end of file