Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- $pdo = new PDO("mysql:host=localhost;dbname=_fantapc", '_fpcroot', '');
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
- $query = $pdo->prepare("SELECT * FROM cards WHERE id=:id");
- $query->bindValue(":id", $_GET['card_id'], PDO::PARAM_INT);
- $query->execute();
- $card = $query->fetch();
- $query = $pdo->prepare("SELECT * FROM users WHERE username=:username");
- $query->bindValue(":username", $_SESSION['username'], PDO::PARAM_STR);
- $query->execute();
- $user = $query->fetch();
- $query = $pdo->prepare("SELECT * FROM prices WHERE card_id=:card_id");
- $query->bindValue(":card_id", $_GET['card_id'], PDO::PARAM_INT);
- $query->execute();
- $price = $query->fetch();
- $query = $pdo->prepare("SELECT AVG(te_price), AVG(pot_price), AVG(luna_price),
- MIN(te_price), MIN(pot_price), MIN(luna_price), MAX(te_price), MAX(pot_price),
- MAX(luna_price) FROM prices WHERE card_id=:card_id GROUP BY card_id");
- $query->bindValue(":card_id", $_GET['card_id'], PDO::PARAM_INT);
- $query->execute();
- $average = $query->fetch();
- if(isset($_POST['formsub'])) {
- echo "I FIRE!";
- $te = $_POST['te_price'];
- $pot = $_POST['pot_price'];
- $luna = $_POST['luna_price'];
- // $user = $_POST($user['id']);
- // $cardid = $_POST($_GET['card_id']);
- $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)");
- $query->bindValue(":te_price", $te, PDO::PARAM_INT);
- $query->bindValue(":pot_price", $pot, PDO::PARAM_INT);
- $query->bindValue(":luna_price", $luna, PDO::PARAM_INT);
- $query->bindValue(":user_id", $user['id'], PDO::PARAM_INT);
- $query->bindValue(":card_id", $_GET['card_id'], PDO::PARAM_INT);
- $query->execute();
- }
- echo "<h1>" . "<img src={$card['img_avatar']} />" . $card['name'] . "</h1>";
- ?>
- <table class="table table-striped">
- <tr>
- <td></td><td><strong>TE Value</strong></td><td><strong>Pot Value</strong></td><td><strong>Luna Value</strong></td>
- </tr>
- <tbody>
- <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>
- <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>
- <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>
- </tbody>
- </table>
- <br />
- <?php
- echo "<form action='index.php?page=card_details&card_id={$_GET['card_id']}' method='post'>";
- ?>
- te value: <input type="text" name="te_price"><br>
- pot value: <input type="text" name="pot_price"><br>
- luna value: <input type="text" name="luna_price"><br>
- <?php
- echo "<input type='hidden' name='formsub'>";
- echo "<input type='hidden' name='formsub'>";
- ?>
- <input type="hidden" name="formsub" value="1">
- <input type="image" src="img/send.png" alt="Submit Form" />
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement