-
Notifications
You must be signed in to change notification settings - Fork 1
/
getAccountListings.php
49 lines (42 loc) · 1.22 KB
/
getAccountListings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<table>
<?php
/*
Written by Bud Linville and Weston Hack
Tested by Bud Linville and Weston Hack
Debugged by Bud Linville and Weston Hack
5/1/17
PHP script for user account age to get only
their posted listings
*/
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
$mysqli = new \mysqli("mysql.eecs.ku.edu", "alinvill", "lacrosse2", "alinvill");
if ($mysqli->connect_errno) {
printf("Error connecting to SQL server");
exit();
}
$userName = $_COOKIE["user"];
$query = "SELECT UserID FROM Users WHERE Username = '$userName'";
if ($result = $mysqli->query($query)) {
while ($row = $result->fetch_assoc()) {
$userID = $row["UserID"];
}
}
$query = "SELECT Address, City, State, Zip, numBedrooms, numBathrooms, Rent ".
"FROM Listings WHERE UserID = '$userID' ";
$offset = (int) $_GET["offset"];
//TODO get the user's preferences for number of rows returned, ORDER BY
$query .= "LIMIT $offset,20";
$rows = array();
if ($result = $mysqli->query($query))
while ($row = $result->fetch_assoc()) { ?>
<tr>
<?php foreach ($row as $column) { ?>
<td>
<?php echo $column ?>
</td>
<?php } ?>
</tr>
<?php } ?>
</table>
<?php $mysqli->close(); ?>