Jump to content

geatzo

Members
  • Posts

    32
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

geatzo's Achievements

Member

Member (2/5)

0

Reputation

  1. because a person add the pokemon up for trade then other users can make offers on that pokemon. So i thought it was best to have 1 table of whats up for trade and 1 table of the offers on them pokemon.
  2. So im trying todo a mass update for each row with the same tid $getUsers = $db->prepare("SELECT * FROM offer_pokemon WHERE tid=?"); $getUsers->execute([$tid]); $users = $getUsers->fetchAll(); foreach ($users as $user) { print_r($user); die; $sqlll5 = "INSERT INTO user_pokemon (uid,name,level,exp,move1,move2,move3,move4,type) VALUES (?, ?,?,?,?,?,?,?,?)"; $qq5 = $db->prepare($sqlll5); $qq5->execute(array($_SESSION["userid"],$user['name'],$user['level'],$user['exp'],$user['move1'],$user['move2'],$user['move3'],$user['move4'],$user['type'])); } for some reason it will grab the 1 result but not them both. Im trying to move the results from 1 table to another. print r is showing Array ( [id] => 1453 [0] => 1453 [tid] => 1011 [1] => 1011 [oid] => 1 [2] => 1 [uid] => 8 [3] => 8 [name] => Caterpie [4] => Caterpie [exp] => 500 [5] => 500 [level] => 5 [6] => 5 [move1] => Ember [7] => Ember [move2] => Ember [8] => Ember [move3] => Ember [9] => Ember [move4] => Ember [10] => Ember [type] => Normal [11] => Normal [idofpokemon] => 24332 [12] => 24332 ) a user can make a offer on a pokemon the offer id is the tid so this person has offered 2 pokemon so if the user accepts i have to insert these 2 pokemon into the users account then remove them from the offer table. I have coded futher down which gives the other person the pokemon ( they can offer on 1 pokemon ) so in this case this person has offered 2 pokemon for 1 of the other users ive coded it so it gives the 1 to this users but can;t get the for each to work to give the 2 to the other user. I have off course added the die to see what it prints out.
  3. ive edited my post $sql = "SELECT t1.oid, t1.offer_from, t2.name, t2.type, t2.level, t2.exp, t2.move1, t2.move2, t2.move3, t2.move4, t3.id FROM trade_offers t1 JOIN user_pokemon t2 ON t1.pokemon_id = t2.id JOIN pokemon t3 ON t2.name = t3.name WHERE t1.offer_on = ? ORDER BY t1.oid DESC LIMIT ?,?"; it looks like your trying to grab the level exp and moves from the offer table when these are stored in the trade table
  4. <b>Fatal error</b>: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''400','50'' at line 9 in /var/www/vhosts/geatzo.com/ascensionrpg.net/offered.php:143 Stack trace: #0 /var/www/vhosts/geatzo.com/ascensionrpg.net/offered.php(143): PDOStatement-&gt;execute() #1 {main} thrown in <b>/var/www/vhosts/geatzo.com/ascensionrpg.net/offered.php</b> on line <b>143</b><br /> seems has tho its not getting the id i noticed you used $offerid = intval(trim($_GET['id']??0)); im guessing you didnt mean to put the ??0 so i fixed that but still the same error on $stmt->execute([$offerid,$start,$limit ]); ive been looking though this $sql = "SELECT t1.oid, t1.offer_from, t2.name, t2.type, t2.level, t2.exp, t2.move1, t2.move2, t2.move3, t2.move4, t3.id FROM trade_offers t1 JOIN user_pokemon t2 ON t1.pokemon_id = t2.id JOIN pokemon t3 ON t2.name = t3.name WHERE t1.offer_on = ? ORDER BY t1.oid DESC LIMIT ?,?"; t2.name, t2.type, t2.level, t2.exp, t2.move1, t2.move2, t2.move3, t2.move4, t3.id isnt in trade_offers
  5. Im still trying to work out how id go about it using my code. My weak point has always been the foreach function. In the muti websites i have ive avoided it at all cost
  6. i dont understand this part ? I think you have worked out what id like todo which is great. So id do a select to grab all the oid then use the foreach i just dont understand where im getting there $ from?
  7. I have a trade table where users can add pokemon for trade. I then have a offer table where other users can make offers on this pokemon from the trade table. So i have a trade table then another trade for offer. In the offer table the user can offer muti of there pokemon for the pokemon in the trade table. So i can offer 2 - 3 of my pokemon for there 1 pokemon. I have made a column called oid for each trade. I then print out the offers for the pokemon from the trade table which works but i would like to group them. So all offers from oid would show in 1 box then the next box would be the next oid and so on. Instead it just shows all . So at the moment there are 3 offers in the table offer 4,5,6 (oid) so id like it to show 3 boxes with each offer(oid) with each result for that offer (oid) inside the table. I really hope this makes sense. <?php $password = mysqli_real_escape_string($link,$_GET['id']); $offerid = strip_tags($password); $limit = 50; $s = $db->prepare("SELECT * FROM trade_offers WHERE offer_on = ? "); $s->execute(array($offerid)); $allResp = $s->fetchAll(PDO::FETCH_ASSOC); // echo '<pre>'; // var_dump($allResp); $total_results = $s->rowCount(); $total_pages = ceil($total_results/$limit); echo $total_results ; if (!isset($_GET['page'])) { $page = 1; } else{ $page = $_GET['page']; } $start = ($page-1)*$limit; $stmt = $db->prepare("SELECT * FROM trade_offers WHERE offer_on = ? ORDER BY oid DESC LIMIT $start, $limit"); $stmt->execute(array($offerid)); // set the resulting array to associative $stmt->setFetchMode(PDO::FETCH_OBJ); $results = $stmt->fetchAll(); // var_dump($results); $no = $page > 1 ? $start+1 : 1; ?> <div id="scroll" style="overflow-x: visible;"> <div id="content"> <div id="loading" style="height: 1133px; width: 800px; visibility: hidden;"><p style="text-align: center; margin-top: 150px;"><b>Loading</b><br><img src="./Pokémon Vortex - Trade Station_files/pokeball_loading.gif" width="50" height="50"></p></div> <div id="ajax"> <h2 class="heading-maroon no-bot-border-rad margin-bottom-3">Trading Station</h2> <?php require_once 'sections/tradenav.php'; ?> <?php foreach($results as $result){ $stmt = $db->prepare("SELECT * FROM user_pokemon WHERE id=?"); $stmt->execute([$result->pokemon_id]); $user = $stmt->fetch(); $stmt2 = $db->prepare("SELECT * FROM pokemon WHERE name=?"); $stmt2->execute([$user['name']]); $user2 = $stmt2->fetch(); ?> <table class="table-striped width-100 text-center" cellpadding="10"> <tbody> <tr><th></th> <th class="text-left width-200px">Pokémon</th> <th>Level</th> <th>Experience</th> <th>Moves</th> <th>Offer By:</th> <th>Offered On</th> </tr> <tr> <td class="pokeball-small"> <img src="https://ascensionrpg.net/img/pokemon/<?= $user['type']; ?>/<?= $user2['id']; ?>.png"> </td> <td class="text-left"> <b> <a href="" onclick="pokedexTab(&#39;pid=48575929&#39;, 1); return false;"> <?= $user['name']; ?> <i class="ion-male male"></i> </a> </b> </td> <td> <?= $user['level']; ?> </td> <td> <?= $user['exp']; ?> </td> <td> <?= $user['move1']; ?><br> <?= $user['move2']; ?><br> <?= $user['move3']; ?><br> <?= $user['move4']; ?> </td> <td><?= $result->offer_from ; ?></td> <td> <p> <?php $stmt22 = $db->prepare("SELECT * FROM trade WHERE id=?"); $stmt22->execute([$offerid]); $user22 = $stmt22->fetch(); $stmt222 = $db->prepare("SELECT * FROM pokemon WHERE name=?"); $stmt222->execute([$user22['pokemon_name']]); $user222 = $stmt222->fetch(); ?> <a class="tooltip" href="" onclick="pokedexTab(&#39;pid=4627030&#39;, 1); return false;"> <img src="https://ascensionrpg.net/img/pokemon/<?= $user22['pokemon_type']; ?>/<?= $user222['id']; ?>.png"> <span class="text-center"><?= $user22['pokemon_name']; ?> </span> </a> </p> <form method="post" onsubmit="get(&#39;/trade/remove-offer/4627030/1714855885/&#39;,&#39;&#39;); disableSubmitButton(this); return false;"> <input type="submit" class="button-small button-maroon" value="Remove"> </form> <form method="post" onsubmit="get(&#39;/trade/remove-offer/4627030/1714855885/&#39;,&#39;&#39;); disableSubmitButton(this); return false;"> <input type="submit" class="button-small button-maroon" value="Accept"> </form> </td></tr> <?php } ?> </tbody></table>
  8. so like this $stmt = $db->prepare("SELECT count(*) FROM trade_offers WHERE offer_on = ? GROUP BY offer_on"); $stmt->execute([$result->id]); $count = $stmt->fetchColumn(); which shows 2 results still instead of the 1 i am doing a while loop to display all the users items i then display how many offers are on each item inside the while loop.
  9. $query2 = mysqli_query($link,"SELECT * FROM `trade_offers` WHERE `offer_on`='{$result->id}' GROUP BY `offer_on`"); $numOffers = mysqli_num_rows($query2); This does what i need it todo buts its mysql and id like to use pdo
  10. Im trying to build a trading script ive coded the listing part just fine and the offering part i am now trying to display how many offers there are on each item. The offer on is what they are offering on so i have a table with all the items in then in the offer table i store the id of the offered on item $stmt = $db->prepare("SELECT count(*) FROM trade_offers WHERE offer_on = ?"); $stmt->execute([$result->id]); $count = $stmt->fetchColumn(); so i would like to group by offer_on so atm my code would show 2 results but there is only 1 offer with 2 items. So the person has offered 2 items in exchange for item with id 1
  11. im getting this error Uncaught ReferenceError: changeAvi is not defined at HTMLSelectElement.onchange I have the script working on another website which works fine ive simply tried to add it to my new website and getting this error I have the script at the top of the page <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> <script src="https://pkmnhelios.com/membersarea_files/button.e7f9415a2e000feaab02c86dd5802747.js.download"></script> <script src="exponential.js"></script> <script type="text/javascript"> function changeAvi(){ var image = document.getElementById('avatarchange'); var dropd = document.getElementById('Avatar'); image.src = dropd.value; }; </script> <br> <input type="submit" name="update" id="button"/> </form> <p> <script type="text/javascript"> function changeAvi(){ var image = document.getElementById('avatarchange'); var dropd = document.getElementById('Avatar'); image.src = dropd.value; }; </script> Then i run some php oose your avatar <br><?php echo '<img id=avatarchange src=images/trainers/000.png />'; ?> <?php echo '<select name="avatar" id="Avatar" onChange="changeAvi()"">'; $sql6=mysqli_query($link,"SELECT * FROM avatars"); while ($row6=mysqli_fetch_array($sql6)){ echo "<option value='".$row6['Image']."'>".$row6['Name']."</option>"; ?> <?php } echo '</select>'; And yes im gonna update it to pdo again this script works on another page inside my site but not a blank page
  12. Thank you i understand now
  13. I am working on a pokemon battle script ive pretty much done it all but ive got stuck on a hp bar. https://prnt.sc/6b4PeawglS2t Has you can see from the screenshot i have a hp bar to show users how much health is left. I work out what the hp should be by timing there level by 6 so i have a variable called $fullhp which is what the full hp should be then im storing the current hp in a database and grabbing it with $ current so $fullhp could be 60 $current = 10 i am stuck on how to work out the maths the bar uses a % <div id="pokemon_life" role="progressbar" style="width: 45%;" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100" class="hp_progress"></div> I have to edit the bar with the width: 45%
  14. i used this for the coding https://www.bootdey.com/snippets/view/Update-user-profile#preview ive just edited it to fit my site but not even the preview does not function ? It loads but the tabs on the left don't work ? So maybe its my browser?
  15. My template to my site is coded in bootstrap so i include it in the header file so all the drop downs etc work just not these buttons....
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.