Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Set up all this stupid business
- $host="localhost"; // Host name
- $username = "dnieto"; // Mysql username
- $password = ""; // Mysql password
- $db_name = "csci4970_fall11_team1_dev"; // Database name
- $tbl_name = "books_approved"; // Table name
- // Connect to server and select databse.
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- //This gets hte title of the book from the value we submitted as 'booktitle'
- // hence GET['booktitle]
- $booktitle = $_GET['booktitle'];
- //where the SQL statement goes, easy enough
- $sql = "SELECT * FROM $tbl_name WHERE ISDN = '$booktitle'";
- //store the result in a variable
- $result=mysql_query($sql);
- //count to see if there is results
- $count=mysql_num_rows($result);
- //if there are any books find create the table, this is easily modified to look nicer
- //just proof of concept
- if($count > 0)
- {
- echo '<table>';
- while($row = mysql_fetch_array($result))
- {
- echo '<tr>';
- echo "<td>" . $row['Title'] . "</td><td>" . $row['Professor'] . "</td>";
- echo '</tr>';
- }
- echo '</table>';
- }
- //otherwise no books found etc
- else
- {
- echo "ham sandwhich";
- }
- ?>
Add Comment
Please, Sign In to add comment