PHP - Pokemon Team Help.
i need help i have this script....
Code: [Select] <?php // Connects to your Database include ('db.php'); $sql = "SELECT * FROM pokemon WHERE owner_id=$id and slot=1"; $sql2 = mysql_query($sql); $rows = mysql_fetch_array($sql2); $grab = mysql_fetch_array(mysql_query("SELECT * FROM types WHERE id = {$rows['type']}")); $typename = $grab['name']; $fetchthis = mysql_fetch_array(mysql_query("SELECT * FROM pokedex WHERE id = {$rows['pokedex_id']}")); $pokedexname = $fetchthis['name']; ?> <?php if($typename== Normal) { echo ""; } else { echo $typename; } echo $pokedexname; ?></b> <?php echo "<img src=images/Pokemon/"; echo $typename; echo "/"; echo $pokedexname; echo ".png"; echo ">"; ?> but if the user has no pokemon i want it to say empty slot, but not to sure how to do it, could anyone help me please? Similar TutorialsAlright first off, I don't know if this is a PHP or SQL problem. Second, I am not very knowledgeable in this subject at all the only reason I'm trying to get this to work is cause my buddy's computer is broken so he can't do much of anything (Would let him use mine but he lives half way across the country from me). So jumping right to the point we purchased this website about a month back cause it was going downhill and we thought this would be a great base to start from. So the following PHP script IS NOT written by us. Since i cant paste the script without it being a wall of text I'll have to tell you the issue BEFORE i post it. When you create the trade for example: Your Oddish His Squirtle It shows that but when you make ANOTHER separate trade for example: Your Lugia His Ho-Oh <-------------That's how it SHOULD look but it goes like this instead: Your Oddish Lugia His Squirtle Ho-Oh Now when you make the trade it adds into the SQL "traded" 1 instead of 0 so i was wondering if from the list of available Pokemon for trade if i could just have any Pokemon that has "Traded" as 1 to be removed from the list BUT NOT FROM THE GAME! Lol i tried DELETE FROM `poke_owned` WHERE `traded`='1' And lets just say that it didn't turn out well.... Now i don't know how much information your going to need so if you need more than just the trade script tell me. Code: [Select] <?php session_start(); require_once 'dbconf.php'; include("figg.php"); if(!isset($_SESSION['user'])){ ?> <script language="text/javascript"> alert('You are not logged in.'); </script><? header ("Location: login.php"); } else{ session_start(); $snorretje1 = mysql_query("SELECT * FROM `users` WHERE `username`='" . $_SESSION['user'] . "'"); $snorretje = mysql_fetch_object($snorretje1); $user1 = mysql_query("SELECT * FROM `users` WHERE `id`='$snorretje->id'"); $user = mysql_fetch_object($user1); require_once 'figg.php'; $pokemon1 = mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='$user->username' AND `party1`='1'"); $pokemon = mysql_fetch_object($pokemon1); $poke1 = mysql_query("SELECT * FROM `pokemon` WHERE `name`='$pokemon->name'"); $poke = mysql_fetch_object($poke1); $amo1= mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='$user->username'"); $amo=mysql_num_rows($amo1); $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'"); $trading=mysql_fetch_object($trading1); $traderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='" . $trading->username . "' ORDER BY `name` ASC"); $traderss=mysql_fetch_object($traderss1); $owntraderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='" . $user->username . "' ORDER BY `name` ASC"); $owntraderss=mysql_fetch_object($owntraderss1); $nummer=mysql_num_rows($traderss1); ?> <?include("leftmenu.php");?> <?if($_GET['q']==""){?> <div class="title">Trade pokemon</div> <div class="contentcontent"> <br> <center> <?if(!isset($_POST['mytrade'])){ if(!isset($_POST['othertrade'])){?> Please enter the number of the trainer you would like to trade with:<br> <br> <form name="form" action="trade5.php" method="get"> <input type="text" name="q" /> <input type="submit" name="Submit" value="Trade" class="button" /> </form> <?}}}?> <?if($_GET['q']!=""){ if ($user->id == $_GET['q']) { echo "<div class=\"contentcontent\"><p class=\"title\">Trade pokemon</p><br><center>You can't trade yourself... Silly buns...</center></div>"; include("rightmenu.php"); exit; } $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'"); $trading=mysql_fetch_object($trading1); $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'"); $num=mysql_num_rows($trading1); if($num==0){echo("<center><b>No user found with that ID.</b></center>");} if($num==1){ ?> <div class="contentcontent"><p class="title">Trade pokemon with trainer #<?=$_GET['q']?></p> <form action="/trade5.php?a=<?=$_GET['q']?>" method="POST"><table class="w100"><tr><td class="w50"><p class="center">Your Pokémon<br /><select name="mytrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pokémon)</option><?while($owntradert=mysql_fetch_object($owntraderss1)){?><option value="<?=$owntradert->id?>"><?=$owntradert->name?> <?=$owntradert->gender?> (Level:<?=$owntradert->level?>)</option><?}?></select></p></td> <td class="w50"><p class="center"><?=$trading->username?>'s Pokémon<br /><select name="othertrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pokémon)</option><?while($tradert=mysql_fetch_object($traderss1)){?><option value="<?=$tradert->id?>"><?=$tradert->name?> <?=$tradert->gender?> (Level:<?=$tradert->level?>)</option><?}?></select></p></td></table> <center><input type="submit" value="Trade"> <?}} $bs=2; if ($bs == 1) { ?> ' <? } if(isset($_POST[mytrade])){ { $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'"); $trading=mysql_fetch_object($trading1); $id1=mysql_query("SELECT * FROM `trade`"); $id=mysql_fetch_object($id1); $numbl=mysql_num_rows($id1); if($numbl==0) { $tradeid=0; } else { $tradeid=$id->tradeid+1; } $ytrade=$_POST[mytrade]; if($ytrade){ foreach ($ytrade as $y) mysql_query("INSERT INTO `trade` (`from`, `to`, `pokid`,`tradeid`,`owner`) values('" . $user->id . "','" . $_GET['a'] . "','" . $y . "','" . $tradeid . "','" . $user->id . "')")or die(mysql_error()); $theother1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'"); $theother=mysql_fetch_object($theother1); $error1=mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='" . $theother->username . "' AND `id`='" . $y . "' OR `trainer`='" . $user->username . "' AND `id`='" . $y . "'"); $error=mysql_num_rows($error1); if($error==0 && $y!=niks) { echo("Don't try to cheat!"); exit; } } if($ytrade){ foreach ($ytrade as $y) mysql_query("UPDATE poke_owned SET traded=1 WHERE id='" . $y . "'"); mysql_query("DELETE FROM `trade` WHERE `pokid`='niks'"); } { } } $otrade=$_POST[othertrade]; if($otrade){ foreach ($otrade as $o) mysql_query("INSERT INTO `trade` (`from`, `to`, `pokid`,`tradeid`, `owner`) values('" . $user->id . "','" . $_GET['a'] . "','" . $o . "','" . $tradeid . "','" . $_GET['a'] . "')")or die(mysql_error()); $theother1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'"); $theother=mysql_fetch_object($theother1); $error1=mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='" . $theother->username . "' AND `id`='" . $o . "' OR `trainer`='" . $user->username . "' AND `id`='" . $y . "'"); $error=mysql_num_rows($error1); if($error==0 && $o!=niks) { echo("Don't try to cheat!"); exit; } } if($otrade){ foreach ($otrade as $o) mysql_query("UPDATE poke_owned SET traded=1 WHERE id='" . $o . "'"); mysql_query("DELETE FROM `trade` WHERE `pokid`='niks'"); } unset($_POST[mytrade]); unset($_POST[othertrade]); ?><meta http-equiv="Refresh" content="0; url=/traded.php"><? } ?> <br> <p> </p> <p class="center"> </p> </div> <?include("rightmenu.php");?> </html> <?}?>
I would like to generate team by their seniority based on the available members.
$result = mysqli_query($con, "SELECT * FROM `members` ORDER BY DOJ,DOB"); $perteam =10; $teamstart=1; $teams=15; $required=$perteam*$teams; $data = array(); while( $row = mysqli_fetch_array($result)) { $data[]=$row; } foreach($data as $fetch){ echo $fetch["empname"].'<br>'; }
I used the above code to fetch the members in seniority . Now I want to add another coumns Team and Designation as follows; Hello again: I would like to see if someone can either show me some code, or point me in the direction of a good article about uploading a file (meaning a photo, .JPG, .GIF, etc) via PHP. I have only done this with ASP. My searches on GOOGLE are only showing me ways to upload a file INTO the database, and I don't believe that is the proper way to do it. I have always stored the file (.JPG) in a folder called "uploads" and stored the file name (myPhoto.JPG) in the database. So, if I want to make a Team bio list with a photo, a title, and a description what is the proper way to do that? Meaning, I click "Add Player" and a form with title, description, and a photo upload field appear. The data is filled out, "Submit" is clicked, and the photo is uploaded to "uploads" and all other data is inserted into the database. I had wanted to be able to modify, delete, or make inactive each player, and use a dropdown SELECT menu to choose what player to edit. Any ideas how to accomplish this? I would appreciate the help! This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=318011.0 |