Jump to content

tooNight

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tooNight's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Just wondering if anyone can help me, what I am trying to do is to here. I currently have two drop down menus the first one with countries and then the second one changes depending on which country is selected to display counties. This works fine, now what I want to do is have it so when it county is selected it shows all the squash clubs that are in that county below the drop downs. Would be great if someone could help me out. Javascript [code]<script language=JavaScript> function reload(form){ var val=form.country.options[form.country.options.selectedIndex].value; self.location='<?php echo $_SERVER['PHP_SELF']; ?>?country=' + val; } </script>[/code] Php [code]<?php         $quer2=mysql_query("SELECT countries.countryID, countries.countryName FROM countries") or die(mysql_error());         if(isset($country) and strlen($country) > 0){     $quer=mysql_query("SELECT countyID, countyName FROM counties WHERE cCountryID=$country");     }else{$quer=mysql_query("SELECT countyName, countyID FROM counties");} echo "<form method=post name=f1 action=''>"; /// Add your form processing page address to action in above line. Example action=dd-check.php//// ////////// Starting of first drop downlist ///////// echo "<select name='country' onchange=\"reload(this.form)\">Select one"; while($row2 = mysql_fetch_array($quer2)) { if($row2['countryID']==$country){echo "<option selected value='$row2[countryID]'>$row2[countryName]"." ";} else{echo "<option value='$row2[countryID]'>$row2[countryName]";} } echo "</select>"; ////////////////// This will end the first drop down list /////////// ////////// Starting of second drop downlist ///////// echo "<select name='county'>Select one"; while($row = mysql_fetch_array($quer)) { echo "<option value='$row[countyID]'>$row[countyName]"; } echo "</select>"; ////////////////// This will end the second drop down list /////////// echo "</form>"; //My Attempt at fetching club where cCounty & cCountry both in club table are the same as $county and $country. $p2=mysql_query("SELECT club.clubID, club.cClubName FROM club WHERE cCounty = $countyID AND cCountry = $country") or die(mysql_error()); echo "<ol>"; while($row=mysql_fetch_assoc($p2)) { echo "<li><a href=\"clubDetails.php?clubID=$row[clubID]\">$row[cClubName]</a></li>\r\n"; } echo "</ol>"; ?>[/code]
  2. Yes works a treat, thanks matey. Had to close the ] on the pRankingScore of the IF statement but apart from that it was fine. Thanks alot
  3. Hi there in my ladder I want to display a up arrow if playerRankings.pRankingScore is great than playerRankings.pPrevRankingScore or down arrow if less & if the values are the same the display the yellow no change diamond. I would like to display the image in <th>Points +/-</th> column. I have saved the images below to my server and they are in /images under the same filenames. Just wondering if anybody could help me out with this simple if statement? [img src=\"http://contact14.ics.uci.edu/virus/images/down-arrow-red.gif\" border=\"0\" alt=\"IPB Image\" /] [img src=\"http://www.westpoint.ltd.uk/example-reports/reports/files/static/arrow-up-green.png\" border=\"0\" alt=\"IPB Image\" /] [img src=\"http://www.westpoint.ltd.uk/example-reports/reports/files/static/arrow-none.png\" border=\"0\" alt=\"IPB Image\" /] [code] <?php require('library/db_connect.php');    // database connect script. ?> <?php include 'library/header.inc'; ?> <?php     $query  = "SELECT playerRankings.pRankingsID, playerRankings.pRankingScore, playerRankings.pPrevRankingScore, users.username, users.playerName                          FROM playerRankings, users                WHERE (playerRankings.pRankingsID = users.username)                ORDER BY playerRankings.pRankingScore DESC";                    $result = mysql_query($query) or die('Error : ' . mysql_error());     print "<table border=1>\n<tr><th>Rank</th><th>Name</th><th>Score</th><th>Prev Score</th><th>Points +/-</th></tr>\n";            $rank = 1;     while ($row = mysql_fetch_assoc($result)) {     print "<tr><td>{$rank}</td><td><a href=\"playerDetails.php?username=$row[username]\">$row[playerName]</a></td><td>{$row['pRankingScore']}</td><td>{$row['pPrevRankingScore']}</td><td></td><tr>\n";     $rank++;     }          print "</tr>" .           "</table>";                        $db_object->disconnect(); ?> <?php include 'library/footer.inc'; ?> [/code]
  4. Still trying to get this to work can get the list of players [a href=\"http://www.squashcommunities.com/players.php\" target=\"_blank\"]here[/a] with the code below. Just cannot get playerDetails.php to display the player that I have just clicked. Whenever I click on a player it takes me to playerDetails.php but I get the message no such username. Just wondering where I am going wrong? players.php [code] <?php include 'library/config.php'; include 'library/opendb.php';          $p2=mysql_query("SELECT users.username, users.playerName FROM users") or die(mysql_error()); echo "<ol>"; while($row=mysql_fetch_assoc($p2)) { echo "<li><a href=\"playerDetails.php?$row[username]=$row[username]\">$row[playerName]</a></li>\r\n"; } echo "</ol>"; include 'library/closedb.php';     ?> [/code] playerDetails.php [code] <?php include 'library/config.php'; include 'library/opendb.php'; $username = $_REQUEST['username']; //this bunch of code will get you the id of the player you are looking for //The following code will get the details from mysql table $sql = "SELECT * FROM users WHERE username='$username'"; $query = mysql_query($sql); if (mysql_num_rows($query) > 0) { $row = mysql_fetch_array($query); $name = $row['playerName']; $town = $row['town']; $email = $row['email']; } else { echo "No Such username"; exit; } echo "Player Name: $name <br> Town: $town <br> Email: $email"; ?> [/code]
  5. Just wondering if anbody could point me in the right direction What I currently have is list of players what I want to do is make each player a hyperlink to a page with their details on. The hyperlink would be like this [a href=\"http://www.mydomain.com/playerDetails.php?playerID=1\" target=\"_blank\"]www.mydomain.com/playerDetails.php?playerID=1[/a] and it would display the player with playerID 1. I have seen this on lots of sites and would like to know how this is done, can anybody recommend me any tutorials or write me a short script to do this. Would be a great help if somebody could point me in the right direction :D table players: players('playerID,playerName,country,email) Cheers Leon
  6. Thanks this code should could in handy though fixed my code by changing: so this: [code]echo "<option value=$row[countryID] {if($form->value("country") == "$row[countryID]"){ echo "selected"; }}>$row[countryName]</option>"; } [/code] becomes: [code]echo "<option value=$row[countryID] ".(($form->value('country')==$row['countryID'])?'selected':'').">$row[countryName]</option>"; } [/code] But think your way is more efficient, so maybe will implement it later if I have time. Thanks
  7. Hi there, Trying to have a selectbox that queries the database which contains two fields countryID and countryName and outputs countryID. I can get it to work ok but not when I put [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]if($form->value("country") == "$row[countryID]"){ echo "selected"; }[/quote] which needs to be in to write the value to my procedures. If someone would be so kind to point me in the right direction and tell me what syntax mistake I am making it would be a great help. Thanks very much The code below works but I need to insert if($form->value("country") == "$row[countryID]"){ echo "selected"; } where it says HERE, what is the best way of doing this? [code] <?php $p2=mysql_query("SELECT countries.countryID, countries.countryName FROM countries") or die(mysql_error()); echo "<select name=country>"; while($row=mysql_fetch_assoc($p2)) { echo "<option value=$row[countryID]HERE>$row[countryName]</option>"; } echo "</select>"; ?> [/code] My shocking attempt at it which I keep getting errors with. [code] <?php $p2=mysql_query("SELECT countries.countryID, countries.countryName FROM countries") or die(mysql_error()); echo "<select name=country>"; while($row=mysql_fetch_assoc($p2)) { echo "<option value=$row[countryID] {if($form->value("country") == "$row[countryID]"){ echo "selected"; }}>$row[countryName]</option>"; } echo "</select>"; ?> [/code]
  8. Yep that works a treat, thank you very much :D
  9. Hi there struggling with IF statements, I have a form where players can insert their results against another players. The players submit their results e.g. 3-0, 3-1, 3-2, 0-3, 1-3, 2-3, . The if statement is below is very sketchy php & pseudo code, just wondering if anybody could correct my if statement or tell me a better way to do it. I have a table called indResults and when a player submits a result I want to put the words "WIN" or "LOSS" in the table recording the results. depending on which player got to 3 games first and won. At the moment the form submits but does not submit values for $pWL1, $pWL2 which I have tried to work out in the IF statement. Please could somebody help me please as I am tearing my hair out here, would be great if you could! Many Thanks Leon P.S. [a href=\"http://www.squashcommunities.com/inputresults.php\" target=\"_blank\"]Here is the webpage to get an idea of the scores[/a] [code] <?php require 'library/db_connect.php';    // database connect script. ?> <?php if (isset($_POST['submit'])) { // if form has been submitted   /* check they filled in what they supposed to,   passwords matched, username   isn't already taken, etc. */ //Big IF statement is below which I am having trouble with.      $win = "WIN";   $loss = "LOSS";   if(!$_POST['player1Score']== "3" && !$_POST['player2Score'] == "0")   {       $pWL1 = $win;       $pWL2 = $loss;   }      elseif(!$_POST['player1Score'] == "3" && $_POST['player2Score'] == "1")   {   $pWL1 == $win;   $pWL2 == $loss;   }      elseif(!$_POST['player1Score'] == "3" && $_POST['player2Score'] == "2")   {   $pWL1 == $win;   $pWL2 == $loss;   }   elseif(!$_POST['player1Score'] == "0" && $_POST['player2Score'] == "3")   {   $pWL1 == $loss;   $pWL2 == $win;   }   elseif(!$_POST['player1Score'] == "1" && $_POST['player2Score'] == "3")   {   $pWL1 == $loss;   $pWL2 == $win;   }   elseif(!$_POST['player1Score'] == "2" && $_POST['player2Score'] == "3")   {   $pWL1 == $loss;   $pWL2 == $win;   }   elseif(!$_POST['player1Score'] == "2" && $_POST['player2Score'] == "2")   {     die ('Only Completed Matches Count');   }    elseif(!$_POST['player1Score'] == "1" && $_POST['player2Score'] == "1")   {     die ('Only Completed Matches Count');   }    elseif(!$_POST['player1Score'] == "0" && $_POST['player2Score'] == "0")   {     die ('Only Completed Matches Count');   }    include 'library/header.inc'; $insertScore = "INSERT INTO indMatch (                             indMatchID,                             player1ID,                             player2ID,                             player1Sco,                             player2Sco,                                                         p1WinLoss,                                                         p2WinLoss)                             VALUES (                 NULL,                 '".$_POST['pID']."',               '".$_POST['player2']."',               '".$_POST['player1Score']."',               '".$_POST['player2Score']."',               $pWL1,               $pWL2)"; $add_result = $db_object->query($insertScore); include 'library/footer.inc' ?> <?php     } else {    // if form hasn't been submitted ?> <?php include 'library/header.inc'; ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">      <?php $findName = "SELECT playerID, playerName, email FROM players WHERE (email = '".$_SESSION['emailusername']."')"; $findPlayer = mysql_query($findName) or die(mysql_error()); while($row=mysql_fetch_assoc($findPlayer)) { echo "$row[playerName]"; echo "<input type=hidden name=pID value=$row[playerID]>"; } ?> <select name=player1Score> <option value=3>3</option> <option value=2>2</option> <option value=1>1</option> <option value=0>0</option> </select> <?php $p2=mysql_query("SELECT players.playerID, players.playerName FROM players") or die(mysql_error()); echo "<select name=player2>"; while($row=mysql_fetch_assoc($p2)) { echo "<option value=$row[playerID]>$row[playerName]</option>"; } echo "</select>"; ?> <select name="player2Score"> <option value="3">3</option> <option value="2">2</option> <option value="1">1</option> <option value="0">0</option> </select> <input type="submit" name="submit" value="Confirm Result"> </form> <?php include 'library/footer.inc'; ?> <?php $db_object->disconnect(); ?> <?php } ?>  [/code]
  10. Works a treat thatnks, been tearing my hair out for the past few days trying to do this. Thanks alot :)
  11. Hi there, Got a simple problem, i have two tables one for players and one for playerRankings and from these table i want to select the followng fields: [b]players:[/b] playerID, playerName [b]playerRankings:[/b] pRankingsID, pRplayerID, pRankingScore, pPrevRankingScore So i devised this SQL query to pick them up [code] SELECT playerRankings.pRankingsID, playerRankings.pRplayerID, playerRankings.pRankingScore,     playerRankings.pPrevRankingScore, players.playerID, players.playerName FROM playerRankings, players WHERE (playerRankings.pRankingsID = players.playerID) [/code] I think this is correct, if not could you tell me whats wrong with it. I then tried to enumerate this in php to try and get it to display the ranking list with the points and player names beside them and I cannot do this. So I would like some help in how to fix this. My code is below it would be great if someone could tell me where I am going wrong and how to fix it. [code] <?php require('db_connect.php');    // database connect script. ?> <?php     $query  = "SELECT playerRankings.pRankingsID, playerRankings.pRplayerID, playerRankings.pRankingScore, playerRankings.pPrevRankingScore, players.playerID, players.playerName                          FROM playerRankings, players                WHERE (playerRankings.pRankingsID = players.playerID)";                    $result = mysql_query($query) or die('Error : ' . mysql_error());             if (mysql_num_rows($result) == 0) {     //No rows } else {     //Start enumerating     while ($row = mysql_fetch_object($result)) {         print "<div>" .         "<p>" . $x_pPrevRankingScore = $row["pPrevRankingScore"] . "</p>" .         "<p>" . $x_playerID = $row["playerID"] . "</p>" .         "<p>" . $x_playerName = $row["playerName"] . "</p>" .         "<p>" . $x_pRankingsID = $row["pRankingsID"] . "</p>" .         "<p>" . $x_pRankingScore = $row["pRankingScore"] . "</p>" .         "</div>";     } }                    echo $x_pPrevRankingScore;     echo $x_playerID;     echo $x_playerName;     echo $x_pRankingsID;     echo $x_pRankingScore;                        $db_object->disconnect(); ?> [/code]
  12. Hi there, I am creating a login page where racket players can sign up to the site and then be placed on a world rankings website. I am trying when the players sign up and inout information in the players table that the playerID created can then be used in playerRankings so that playerRankingsID and pRplayerID can be the same number. Player ID is auto incrementing, did some reserach on the internet and found mysql_insert_id() which needs to be put directly below the insert query. The only problem is when i echo $pID it is always 0 and the query $insertIntoRankings does not run and no fields are created in this table but the $insert query above works correctly. Just wondering if anyone could give me some feedback and tell me where I am going wrong, I am a relative newcomer to php and enjoying it so far. Cheers Leon [a href=\"http://www.squashcommunities.com/library/register.php\" target=\"_blank\"]Registration Page Here[/a] register.php [code=php:0]<?php require('db_connect.php'); // database connect script. ?> <?php if (isset($_POST['submit'])) { // if form has been submitted /* check they filled in what they supposed to, passwords matched, username isn't already taken, etc. */ if (!$_POST['emailU'] | !$_POST['passwd'] | !$_POST['passwd_again'] ) { die('You did not fill in a required field.'); } // check if username exists in database. if (!get_magic_quotes_gpc()) { $_POST['emailU'] = addslashes($_POST['emailU']); } $name_check = $db_object->query("SELECT email FROM players WHERE email = '".$_POST['emailU']."'"); if (DB::isError($name_check)) { die($name_check->getMessage()); } $name_checkk = $name_check->numRows(); if ($name_checkk != 0) { die('Sorry, the email address: <strong>'.$_POST['emailU'].'</strong> is already taken, please make sure you havent already registered'); } // check passwords match if ($_POST['passwd'] != $_POST['passwd_again']) { die('Passwords did not match.'); } // check e-mail format if (!preg_match("/.*@.*..*/", $_POST['emailU']) | preg_match("/(<|>)/", $_POST['emailU'])) { die('Invalid e-mail address.'); } // no HTML tags in username, website, location, password $_POST['emailU'] = strip_tags($_POST['emailU']); $_POST['passwd'] = strip_tags($_POST['passwd']); // check show_email data if ($_POST['show_email'] != 0 & $_POST['show_email'] != 1) { die('Nope'); } // now we can add them to the database. // encrypt password $_POST['passwd'] = md5($_POST['passwd']); if (!get_magic_quotes_gpc()) { $_POST['passwd'] = addslashes($_POST['passwd']); $_POST['emailU'] = addslashes($_POST['emailU']); } $regdate = date('d m, Y'); $insert = "INSERT INTO players ( playerID, email, password, regdate, playerName, address1, address2, town, county, postcode, country, telephoneNum, show_email, last_login) VALUES ( NULL, '".$_POST['emailU']."', '".$_POST['passwd']."', '$regdate', '".$_POST['name']."', '".$_POST['address1']."', '".$_POST['address2']."', '".$_POST['town']."', '".$_POST['county']."', '".$_POST['postCode']."', '".$_POST['country']."', '".$_POST['teleNum']."', '".$_POST['show_email']."', 'Never')"; $pID = mysql_insert_id(); $insertIntoRankings = "INSERT INTO playerRankings ( pRankingsID, pRplayerID, pRankingScore) VALUES ( ".$pID.", ".$pID.", 0, 0)"; $add_member = $db_object->query($insert); $add_to_rankings = $db_object->query($insertIntoRankings); if (DB::isError($add_member)) { die($add_member->getMessage()); } $db_object->disconnect(); ?> <h1>Registered</h1> <p>Thank you, your information has been added to the database, you may now <a href="login.php" title="Login">log in</a>.</p> <?php } else { // if form hasn't been submitted ?> <html> <head> <script type="text/javascript" src="countrysAndCounties.js"></script> <title>Register</title> </head> <body> <h1>Register</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table align="center" border="1" cellspacing="0" cellpadding="3"> <tr><td>Email*:</td><td> <input type="text" name="emailU" maxlength="100"> </td></tr> <tr><td>Password*:</td><td> <input type="password" name="passwd" maxlength="50"> </td></tr> <tr><td>Confirm Password*:</td><td> <input type="password" name="passwd_again" maxlength="50"> </td></tr> <tr><td>Name</td><td> <input type="text" name="name" maxlength="100"> </td></tr> <tr><td>address1</td><td> <input type="text" name="address1" maxlength="150"> </td></tr> <tr><td>address2</td><td> <input type="text" name="address2" maxlength="150"> </td></tr> <tr><td>Town</td><td> <input type="text" name="town" maxlength="150"> </td></tr> <tr><td>Post Code</td><td> <input type="text" name="postCode" maxlength="150"> </td></tr> <tr><td>Country</td><td> <select id='countrySelect' name='country' onchange='populateState()'></select> </td></tr> <tr><td>County</td><td> <select id='stateSelect' name='county'></select> <script type="text/javascript">initCountry('US');</script> </td></tr> <tr><td>telephoneNum</td><td> <input type="text" name="teleNum" maxlength="150"> </td></tr> <tr><td>Show E-Mail?</td><td> <select name="show_email"> <option value="1" selected="selected">Yes</option> <option value="0">No</option></select> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Sign Up"> </td></tr> </table> </form> </body> </html> <?php } ?>[/code] db_connect.php [code=php:0]<?php //require the PEAR::DB classes. require_once 'DB.php'; $db_engine = 'mysql'; $db_user = '*******'; $db_pass = '**********'; $db_host = '***************'; $db_name = '***********'; $datasource = $db_engine.'://'. $db_user.':'. $db_pass.'@'. $db_host.'/'. $db_name; $db_object = DB::connect($datasource, TRUE); /* assign database object in $db_object, if the connection fails $db_object will contain the error message. */ // If $db_object contains an error: // error and exit. if(DB::isError($db_object)) { die($db_object->getMessage()); } $db_object->setFetchMode(DB_FETCHMODE_ASSOC); // we write this later on, ignore for now. include('check_login.php'); ?>[/code]
×
×
  • 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.