Jump to content

joebudden

Members
  • Posts

    99
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

joebudden's Achievements

Member

Member (2/5)

0

Reputation

  1. cheers for the help guys but i dont think these solutions help me. what i have, is lets say 100 names, in a table and it scrolls a long way down the page. Just wondered if there was a way of having 10 names then stop and create a new table next to that and so on.
  2. hi guys, Iv got a table that displays each record from a query. The problem is theres a lot of records and I just wondered if there was a way of creating a 3 tables side by side to make the information displayed more compact but not using separate queries ?? here is the code so far <?php // get players A - J $getPlayersSQL = "SELECT playerId,playerName,playerSurname FROM player ORDER BY playerSurname ASC"; $getPlayersRES = mysql_query($getPlayersSQL); ?> <form action="createMyTeamConfirm.php" method="post"> <input type="submit" name="submit" value="Continue"><br /><br /> <input type="hidden" name="teamId" value="<?php echo $teamId ?>" /> <input type="hidden" name="leagueId" value="<?php echo $teamId ?>" /> <table width="200px" border="1" align="center" cellpadding="0" cellspacing="0"> <tr><td></td><td>Player Name</td></tr> <?php while($players = mysql_fetch_assoc($getPlayersRES)) { // hold the players details in variables $playerId = $players["playerId"]; $playerName = $players["playerName"]; $playerSurname = $players["playerSurname"]; // create the table rows echo "<tr>"; echo "<td align=\"center\"><input type=\"checkbox\" name=\"add_players[]\" value=\"$playerId\" /></td>"; echo "<td align=\"center\">"; ?> <a href="javascript:openWindow('playerInformation.php?playerId=<?php echo $playerId;?>', 500, 400, 200, 200)"> <?php echo $playerName."<b> "; echo $playerSurname."</b>"; ?> </a> <?php echo "</td>"; echo "</tr>"; } ?> </table> </form>
  3. <?php // get players A - J $getPlayersSQL = "SELECT DISTINCT playerId,playerName,playerSurname FROM player ORDER BY playerSurname ASC"; $getPlayersRES = mysql_query($getPlayersSQL); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table width="200px" border="1" align="center" cellpadding="0" cellspacing="0"> <tr><td></td><td>Player Name</td></tr> <?php while($players = mysql_fetch_assoc($getPlayersRES)) { // hold the players details in variables $playerId = $players["playerId"]; $playerName = $players["playerName"]; $playerSurname = $players["playerSurname"]; // create the table rows echo "<tr>"; echo "<td align=\"center\"><input type=\"checkbox\" name=\"add_players[]\" value=\"$playerId\" /></td>"; echo "<td align=\"center\">"; ?> <a href="javascript:openWindow('playerInformation.php?playerId=<?php echo $playerId;?>', 500, 400, 200, 200)"> <?php echo $playerName."<b> "; echo $playerSurname."</b>"; ?> </a> <?php echo "</td>"; } echo "</tr>"; } ?> </table> </form>
  4. hi guys, Iv got a query which returns a list of players names that are displayed in a table. What I want to do is have these in 3 separate tables so they dont run right down the page.. Does anyone know of a way i could do this with using separate queries ??? cheers also does anyone know what this means -->  i get it on all of my pages and its quite annoying lol
  5. hi guys i have this php script and want to run it 7 times to create 7 random teams.. anyone know how i wud achieve this thanx // random team generation // // generate first random team // random team id variable $teamidRAND = rand(1,1000000); // update tournament table SQL $tournamentSQL = "INSERT INTO tournament(tournamentid,teamid) VALUES ($gameid,$teamidRAND)"; mysql_query($tournamentSQL) or die (mysql_error()); // update draw table SQL $drawSQL = "INSERT INTO $draw(teamid,tournamentid) values ($teamidRAND,$gameid)"; mysql_query($drawSQL) or die (mysql_error()); // SQL to select 5 random player Ids $playerSQL = "SELECT playerId FROM $temp ORDER BY RAND() LIMIT 5"; $playerRES = mysql_query($playerSQL) or die(mysql_error()); //check if there is data to be added if (mysql_num_rows($playerRES) == 5) { while($row = mysql_fetch_assoc($playerRES)) { // random playsfor variables $fitnessRAND = rand(6,10); $trainingRAND = rand(1,5); $tacticsRAND = rand(1,5); $teamtalkRAND = rand(1,5); $moraleRAND = rand(6,10); $mediaRAND = rand(1,5); // random player Id $randomPlayer = $row["playerId"]; // update playsfor table with players SQL $playsforSQL = "INSERT INTO playsfor ( playerId, teamid, playerCaptain, playerStarting, playerFitness, playerTraining, playerTactics, playerTeamTalk, playerMorale, playerMedia ) VALUES ( $randomPlayer, $teamidRAND, 0, 0, $fitnessRAND, $trainingRAND, $tacticsRAND, $teamtalkRAND, $moraleRAND, $mediaRAND )"; mysql_query($playsforSQL) or die (mysql_error()); // delete from temp table SQL $delPlayerSQL = "DELETE FROM $temp WHERE playerId=$randomPlayer"; mysql_query($delPlayerSQL) or die (mysql_error()); } // end of while to get players // SQL to select random captain $captainSQL = "SELECT playerId FROM $temp ORDER BY RAND() LIMIT 1"; $captainRES = mysql_query($captainSQL) or die(mysql_error()); while($row = mysql_fetch_assoc($captainRES)) { $randomCaptain = $row["playerId"]; // update playsfor table with captain SQL $playsforSQL = "INSERT INTO playsfor ( playerId, teamid, playerCaptain, playerFreeKicks, playerPenalties, playerStarting, playerFitness, playerTraining, playerTactics, playerTeamTalk, playerMorale, playerMedia ) VALUES ( $randomCaptain, $teamidRAND, 1, 1, 1, 0, $fitnessRAND, $trainingRAND, $tacticsRAND, $teamtalkRAND, $moraleRAND, $mediaRAND )"; mysql_query($playsforSQL) or die (mysql_error()); // delete from temp table SQL $delCaptainSQL = "DELETE FROM $temp WHERE playerId=$randomCaptain"; mysql_query($delCaptainSQL) or die (mysql_error()); } // end of while to get captain // get a players name from that team $getPlayerSQL = "SELECT playerSurname FROM player,playsfor WHERE player.playerId = playsfor.playerId AND teamid=$teamidRAND AND playerCaptain='1' ORDER BY RAND() LIMIT 1"; $getPlayerRES = mysql_query($getPlayerSQL); $getPlayerARR = mysql_fetch_assoc($getPlayerRES); $getPlayerSTR = $getPlayerARR["playerSurname"]; $letter = $getPlayerSTR{0}; $getNameSQL = "SELECT randomName FROM randomNames WHERE randomName LIKE '$letter%' ORDER BY RAND() LIMIT 1 "; $getNameRES = mysql_query($getNameSQL); $getNameARR = mysql_fetch_assoc($getNameRES); $getNameSTR = $getNameARR["randomName"]; if(mysql_num_rows($getNameRES) != 0) { // concatenate random team name $randTeamName = $getPlayerSTR."\'s ".$getNameSTR; } else { // get an alternative team name $alternativeSQL = "SELECT randomName FROM randomNames ORDER BY RAND() LIMIT 1"; $alternativeRES = mysql_query($alternativeSQL); $alternativeARR = mysql_fetch_assoc($alternativeRES); $alternativeSTR = $alternativeARR["randomName"]; // concatenate random team name $randTeamName = $getPlayerSTR."\'s ".$alternativeSTR; } // random team variables $teamTrainingRAND = rand(1,5); $teamTacticsRAND = rand(1,5); $teamTeamTalkRAND = rand(1,5); $teamMediaRAND = rand(1,5); // get a manager $managerSQL = "SELECT managerName FROM manager ORDER BY RAND() LIMIT 1"; $managerRES = mysql_query($managerSQL); $managerARR = mysql_fetch_assoc($managerRES); $managerName = $managerARR["managerName"]; // get an assistant manager $assManSQL = "SELECT managerName FROM manager WHERE managerName NOT IN ('$managerName') ORDER BY RAND() LIMIT 1"; $assManRES = mysql_query($assManSQL); $assManARR = mysql_fetch_assoc($assManRES); $assManName = $assManARR["managerName"]; // update team table SQL $teamSQL = "INSERT INTO team (teamid,teamname,manager,assManager,training,tactics,teamtalk,media) VALUES ( $teamidRAND, \"$randTeamName\", \"$managerName\", \"$assManName\", $teamTrainingRAND, $teamTacticsRAND, $teamTeamTalkRAND, $teamMediaRAND )"; mysql_query($teamSQL) or die (mysql_error()); // end of team generation
  6. just used this $string = "1,2,3"; $count = substr_count($string,", ");
  7. yer .. i think iv found what im looking for in the manual
  8. is there any way to count the occurences of a certain character into a variable ??? $string = (1,2,3,4,5); $test = explode(",", $string); in this example there are 4 commas any help please
  9. how can i get the first letter of a string into a variable ??? $var = "variable"; then get the first letter into a variable $v = "v"; any help appreciated
  10. thanks again barand... before you go tho, can you see anything wrong with this ? <?php // get opponent players $opsql = "SELECT playersurname FROM player,playsfor WHERE player.playerid = playsfor.playerid and teamid = '$oppositionid'"; $opres = mysql_query($opsql) or die (mysql_error()); while($r = mysql_fetch_assoc($opres)) { $z[] = $r['playersurname']; echo $r['playersurname']; } $z1 = $z[0]; $z2 = $z[1]; $z3 = $z[2]; $z4 = $z[3]; $z5 = $z[4]; $z6 = $z[5]; ?>
  11. hehe they both work, thanks a million dude, u dont know how much that means to me!!! just for my information though, which is better to use ?? or which would u use ?? thanx again !!
  12. ok heres what iv got is this correct barand?? <?php // get my players $sql = "SELECT playersurname FROM player,playsfor WHERE player.playerid = playsfor.playerid and teamid = '$teamid'"; $res = mysql_query($sql) or die (mysql_error()); while($row = mysql_fetch_assoc($res)) { foreach ($row as $k=>$n) { $var = "p$k"; $$var = $n ; } } echo $var1; echo $var2; echo $var3; ?> because it says undefined variable when i run it so how could i just pass $p[0], $p[1] etc ?? coz when i implemented that it was the same player name whatever number i put in the []'s ?? please help
  13. well that allows me to display the 6 rows but that wasn't what i asked... i need to have each row in its own variable so i can send each variable separately to FLASH
  14. hi guys.. right this is my query.. $sql = "SELECT playersurname FROM player,playsfor WHERE player.playerid = playsfor.playerid and teamid = '$teamid'"; .. it returns 6 rows.. what i want to do i have each row as a separate variable... ($p1, $p2, $p3 etc etc) ... so i can them pass them to FLASH this is my code so far... <?php $res = mysql_query($sql) or die (mysql_error()); while(list($playername) = mysql_fetch_array($res)) { for ($i=0;$i<6;$i++) { $p{$i} = $playername; } } echo $p1; echo $p2; echo $p3; ?> I've tried several different variations of $p{$i} but keep getting errors... can anyone fix it please ?? thanx
×
×
  • 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.