Jump to content

joebudden

Members
  • Posts

    99
  • Joined

  • Last visited

    Never

Everything posted by joebudden

  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
  15. sending them to a flash swf
  16. i take what i'm trying to do is not possible so i fort of doing it this way... if i get the six players names into a string but separate each by a `:` can i use the list and explode functions to get each name into a separate variable?? so far iv implemented this code.. <?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($r = mysql_fetch_assoc($res)) { $name = $r['playersurname']; $string = $name.":"; } list($p1, $p2, $p3, $p4, $p5, $p6) = explode(":", $string); ?> but it doesn't work and i get this error message: Notice: Undefined offset: 5 in C:\p3t\public_php\__PHPManager__\form.php on line 153 Notice: Undefined offset: 4 in C:\p3t\public_php\__PHPManager__\form.php on line 153 Notice: Undefined offset: 3 in C:\p3t\public_php\__PHPManager__\form.php on line 153 Notice: Undefined offset: 2 in C:\p3t\public_php\__PHPManager__\form.php on line 153 does anyone know i can fix it ?? or fink of a better way thanx
  17. ok i see what you were trying to do with that Fert, but does that enable me to have each playername in its own variable.. because im trying to echo $name4 or $player4 and its saying undefined :S
  18. no that isnt what i need to do, im ok with that stuff , its getting each player into a separate variable which is my problem... here is what i have so far... <?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($r = mysql_fetch_assoc($res)) { $player1 = $r['playersurname']; $player2 = $r['playersurname']; } echo $player1; echo $player2; but this just gets the first playername for both variables.. see what i mean ??
  19. hi guys ok.. this is my problem i want to select 6 records from a table but have them all as different variables which i can then post using a form for example $player1 $player2 $player3 $player4 $player5 $player6 racking my brains trying to think how to do it so if anyone has a quick solution let me know!! thanx
  20. cheers dude il have a look in a bit
  21. hi guys im writing a php/flash application but keep getting this annoying error and annoying little symbol:  Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\p3t\public_php\__PHPManager__\training3.php:1) in C:\p3t\public_php\__PHPManager__\training3.php on line 3 Can anyone tell me what it means ?
  22. hi guys. right here is my php page i am trying to load variables from .. PHP <?php // connect to database include("connect.php"); // set the variables that have been posted isset($_POST['teamid']); isset($_POST['gameid']); // get a player query $query = "SELECT playersurname FROM player"; $result = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_assoc($result); // define variables $myteamid = $_POST["teamid"]; $gameid = $_POST["gameid"]; // flash variables echo "&myteamid=".urlencode($myteamid); echo "&gameid=".urlencode($gameid); echo "&player=".urlencode($row['playersurname']); ?> The variables myteamid and gameid were originally session variables but flash didnt seem to like the session_start so i decided to post them from the previous page. When i run the php page in a browser it displays all of the variables fine. But then when i view the flash file the variables myteamid and gameid are not displayed. However the other variable player displays fine as it is just a simple query. Why is this happening?? is it because flash doesnt know what value has been passed.. Can anyone think of another way round or solution ??? I could really do with a fast solution as all of my queries depend on these two variables. Im gonna try and implement them as GET variables but i have a suspicion that i will just get the same result. If anyone has any experience with using SESSION, POST or GET variables in queries to use in AS/Flash please please please please please post a reply Cheers dudes , thanx in advance.. JB ps. here is my action script... /* first create a new instance of the LoadVars object */ myVars = new LoadVars(); // call the load method to load my php page myVars.load("http://localhost:6789/pp33tt/__PHPManager__/flash/flash3.php", _root, "POST"); myVars.myteamid; myVars.gameid; myVars.player; myVars.onLoad = function (success) { if (success) { myteamid.text = myVars.gameid; player.text = myVars.player; gameid.text = this.myVars.gameid; trace (" variables loaded "); for( var test in this ) { trace (" key " + test + " = " + this[test]); } } else { trace (" Error loading variables "); } }
  23. hi guys , is there anyone out there who is familiar with using php in flash ??? the reason being i am writing a football manager game in PHP/mySQL but want to use flash to simulate the matches between two teams. i have written php pages to collect all of the required information into a mysql database. the problem i am having now is taking the data for each match into flash as the queries to get at the data uses a SESSION variable $gameid. These queries dont work as flash doesnt like the session, so i tried posting the variable to the page. this works but wen i run the flash file nuffin comes up. if anyone is familiar with using php/mysql in flash please message me coz im really stuck with this project my email address is mrjoeharrison@hotmail.com im on msn all the time cheers guys
  24. hey dude... well heres the way im doing it... PHP <?php //connect to database include("connect.php"); $randquery = "SELECT playersurname FROM player ORDER BY RAND() LIMIT 1"; $randomplayer = mysql_query($randquery) or die(mysql_error()); $row = mysql_fetch_assoc($randomplayer); $team1 ="team1"; $team2 ="team2"; $randplayer = $row['playersurname']; echo "&team1=".urlencode($team1); echo "&team2=".urlencode($team2); echo "&randplayer=".urlencode($randplayer); ?> AS /* first create a new instance of the LoadVars object */ myVars = new LoadVars(); // call the load method to load my php page myVars.load("http://localhost:6789/pp33tt/PHP_footbal_manager_with_flash/flash3.php"); myVars.team1; myVars.team2; myVars.randplayer; myVars.onLoad = function (success) { if (success) { team1.text = myVars.team1; team2.text = myVars.team2; randplayer.text = myVars.randplayer; trace (" variables loaded "); for( var test in this ) { trace (" key " + test + " = " + this[test]); } } else { trace (" Error loading variables "); } } this gets the variables fine... but like i say i wana use session variables in my queries... can u remember what ya need to do ???
×
×
  • 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.