Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <tr>
- <th>Name</th>
- <th>Type</th>
- <th>DateOfBirth</th>
- <th>Description</th>
- <th>Photo</th>
- <th>Available</th>
- <th>Owner</th>
- <th>Adopt</th>
- <tr>
- <?php
- error_reporting(E_ALL ^ E_DEPRECATED);//put in place due to previous error: Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO.
- $hostname="localhost"; //local server name default localhost
- $username="root"; //mysql username default is root.
- $password=""; //blank if no password is set for mysql.
- $database="dc2410"; //database name which you created
- mysql_connect($hostname, $username, $password);
- mysql_select_db($database);
- $sql=mysql_query("SELECT * FROM `animal` WHERE `available` = 'Yes'");
- while($animal=mysql_fetch_assoc($sql)){
- echo"<tr>";
- $animal['animalID'];
- echo "<td>".$animal['name']."</td>";
- echo "<td>".$animal['type']."</td>";
- echo "<td>".$animal['dateofbirth']."</td>";
- echo "<td>".$animal['description']."</td>";
- echo "<td>"?> <img src="<?php echo $animal['photo'] ?>" width="100px" height="100px"/> <?php "</td>";
- echo "<td>".$animal['available']."</td>";
- echo "<td>".$animal['owner']."</td>";
- ?>
- <td><form><input type="submit" value="Adopt" name="adopt" onClick="
- <?php
- $req=mysql_query("INSERT INTO adoptionrequest(userID, animalID, approved) VALUES ('1','".$animal['animalID']."','Awaiting Approval')");
- ?>
- " ></form></td>
- <?php
- echo"<tr>";
- }
- ?>
- </table>
- $sub = intval($_POST['sub']);
- $selected = intval($_POST['selected']);
- if ($sub == 1){
- mysql_query("INSERT INTO adoptionrequest(`userID`, `animalID`, `approved`) VALUES ('1','$selected','Awaiting Approval')");
- if(mysql_errorno() > 0){echo mysql_error();}
- }
- echo '<form action="#" method="post" ><input type="hidden" name="sub" value="1"><table>';
- $results = mysql_query("SELECT `animalID`, `name`,`type`,`dateofbirth`,`description`,`photo`,`available`,`owner` FROM `animal` WHERE `available` = 'Yes'");
- while($animal=mysql_fetch_assoc($results, MYSQL_NUM)){
- echo <<<EOT
- <tr><td>$animal[0]</td>
- <td>$animal[1]</td>
- <td>$animal[2]</td>
- <td>$animal[3]</td>
- <td>$animal[4]</td>
- <td><img width="100px" height="100px" src="$animal[5]" alt="$animal[1]"/></td>
- <td>$animal[6]</td>
- <td>.$animal[7]</td>
- <td><button type="submit" name="selected" value="$animal[0]"/></td></tr>
- EOT;
- }
- die("Couldn't enter data: ".$conn->error);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement