Advertisement
Sparkster

Untitled

Jul 25th, 2013
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.10 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4.  
  5. $pdo = new PDO("mysql:host=localhost;dbname=_fantapc", '_fpcroot', '');
  6.  
  7. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
  8.  
  9. $query = $pdo->prepare("SELECT * FROM cards WHERE id=:id");
  10. $query->bindValue(":id", $_GET['card_id'], PDO::PARAM_INT);
  11. $query->execute();
  12. $card = $query->fetch();
  13.  
  14. $query = $pdo->prepare("SELECT * FROM users WHERE username=:username");
  15. $query->bindValue(":username", $_SESSION['username'], PDO::PARAM_STR);
  16. $query->execute();
  17. $user = $query->fetch();
  18.  
  19. $query = $pdo->prepare("SELECT * FROM prices WHERE card_id=:card_id");
  20. $query->bindValue(":card_id", $_GET['card_id'], PDO::PARAM_INT);
  21. $query->execute();
  22. $price = $query->fetch();
  23.  
  24. $query = $pdo->prepare("SELECT AVG(te_price), AVG(pot_price), AVG(luna_price),
  25.     MIN(te_price), MIN(pot_price), MIN(luna_price), MAX(te_price), MAX(pot_price),
  26.     MAX(luna_price) FROM prices WHERE card_id=:card_id GROUP BY card_id");
  27. $query->bindValue(":card_id", $_GET['card_id'], PDO::PARAM_INT);
  28. $query->execute();
  29. $average = $query->fetch();
  30.  
  31.  
  32.  
  33. if(isset($_POST['formsub'])) {
  34.     echo "I FIRE!";
  35.     $te = $_POST['te_price'];
  36.     $pot = $_POST['pot_price'];
  37.     $luna = $_POST['luna_price'];
  38.     // $user = $_POST($user['id']);
  39.     // $cardid = $_POST($_GET['card_id']);
  40.  
  41.     $query = $pdo->prepare("INSERT INTO prices(te_price,pot_price,luna_price, user_id, card_id) VALUES (:te_price,:pot_price,:luna_price,:user_id,:card_id)");
  42.     $query->bindValue(":te_price", $te, PDO::PARAM_INT);
  43.     $query->bindValue(":pot_price", $pot, PDO::PARAM_INT);
  44.     $query->bindValue(":luna_price", $luna, PDO::PARAM_INT);
  45.     $query->bindValue(":user_id", $user['id'], PDO::PARAM_INT);
  46.     $query->bindValue(":card_id", $_GET['card_id'], PDO::PARAM_INT);
  47.     $query->execute();
  48.  
  49. }
  50.  
  51. echo "<h1>" . "<img src={$card['img_avatar']} />" . $card['name'] . "</h1>";
  52.  
  53. ?>
  54.  
  55. <table class="table table-striped">
  56.     <tr>
  57.         <td></td><td><strong>TE Value</strong></td><td><strong>Pot Value</strong></td><td><strong>Luna Value</strong></td>
  58.     </tr>
  59.         <tbody>
  60.         <tr><td><strong>Min</strong></td><td><? echo $average['MIN(te_price)']; ?></td><td><? echo $average['MIN(pot_price)']; ?></td><td><? echo $average['MIN(luna_price)']; ?></td></tr>
  61.         <tr><td><strong>Average</strong></td><td><? echo $average['AVG(te_price)']; ?></td><td><? echo $average['AVG(pot_price)']; ?></td><td><? echo $average['AVG(luna_price)']; ?></td></tr>
  62.         <tr><td><strong>Max</strong></td><td><? echo $average['MAX(te_price)']; ?></td><td><? echo $average['MAX(pot_price)']; ?></td><td><? echo $average['MAX(luna_price)']; ?></td></tr>
  63.  
  64. </tbody>
  65. </table>
  66. <br />
  67.  
  68. <?php
  69.  
  70. echo "<form action='index.php?page=card_details&card_id={$_GET['card_id']}' method='post'>";
  71.  
  72. ?>
  73.  
  74.     te value: <input type="text" name="te_price"><br>
  75.     pot value: <input type="text" name="pot_price"><br>
  76.     luna value: <input type="text" name="luna_price"><br>
  77. <?php
  78.     echo "<input type='hidden' name='formsub'>";
  79.     echo "<input type='hidden' name='formsub'>";
  80. ?>
  81.     <input type="hidden" name="formsub" value="1">
  82.     <input type="image" src="img/send.png" alt="Submit Form" />
  83.     </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement