-
Notifications
You must be signed in to change notification settings - Fork 4
/
BrowsingPage.php
executable file
·70 lines (59 loc) · 1.61 KB
/
BrowsingPage.php
1
<html><head> <title>Sharing Object Browsing Page</title> </head><body><table><tr> <td colspan="2" style="background-color:#FFB6C1;"><h1> Find your item</h1></td> </tr><?php$dbconn = pg_connect("host=localhost port=5432 dbname=Sharing user=postgres password=12345678") or die('Could not connect: ' . pg_last_error());?><tr><td style="background-color:#eeeeee;">Go to <a href="/AccountPage.php">Account Page</a></td></tr><tr><td style="background-color:#eeeeee;"><form> Item name: <input type="text" name="itemName" id="itemName"> <input type="submit" name="formSubmit" value="Search" > <input type="button" value="Add Item" onclick="document.location.href='StuffSharingObject.php'"/></form><?phpif(isset($_GET['formSubmit'])){ $query = "SELECT itemname, description, price FROM object WHERE itemName like '%".$_GET['itemName']."%'"; echo "<b>SQL: </b>".$query."<br><br>"; $result = pg_query($query) or die('Query failed: ' . pg_last_error()); echo "<table border=\"1\" > <col width=\"50%\"> <col width=\"25%\"> <col width=\"25%\"> <tr> <th>itemName</th> <th>description</th> <th>price</th> </tr>"; while($row = pg_fetch_row($result)){ echo "<tr>"; echo "<td>" . $row[0] . "</td>"; echo "<td>" . $row[1] . "</td>"; echo "<td>" . $row[2] . "</td>"; echo "</tr>"; } echo"</table>"; pg_free_result($result);}?></td> </tr><?phppg_close($dbconn);?> <tr><td colspan="2" style="background-color:#FFB6C1; text-align:center;"> Copyright © CS2102</td> </tr></table></body></html>