Jump to content

willwill100

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

willwill100's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [code] if ($cycling=="RANDOM TEAM!"){ srand((float) microtime() * 10000000); $putin = "SELECT * FROM teams"; $mallow = mysql_query($putin) or die(mysql_error()); $cap = mysql_fetch_array($mallow) or die (mysql_error()); print_r($cap); $rand_keys = array_rand($cap, 1); echo $cap[$rand_keys[0]] . "\n"; }[/code] i have a table `teams` with (ID, team, rating) columns. i just want a random team to be outputted but not a lot is happening, wats wrong?
  2. Nice! It works. Thanks for all your help, top man!
  3. i think we posted at the same time again, could you look back two posts and i did put the backticks around sail number, just incase u missed it
  4. okay, ive put the backticks in but i still am getting an error when i query the db: [code]$sql = "SELECT e.`Name`, SUM(r.`Position`) as Score FROM `$compl` e INNER JOIN `$compres` r ON e.`Sail Number` = r.`Sail Number` GROUP BY e.`Name` ORDER BY Score DESC"; [/code] i don't get a mysql error but it just has a list of the same participent going up to 8126 or something and in score column it said "Array"!!?? what's going on?
  5. ok, here's my error message [code]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\sailing\displayres.php on line 79 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''topper main points' e INNER JOIN 'topper main points results' r ON e.Sail Numbe' at line 1SELECT e.Name, SUM(r.Position) as Score FROM 'topper main points' e INNER JOIN 'topper main points results' r ON e.Sail Number = r.Sail Number GROUP BY e.Name ORDER BY Score DESC[/code] hope u can help...
  6. does no one know why my script doesn't work?
  7. still getting an error: [code] SELECT e.Name, SUM(r.Position) as Score FROM 'topper main points' e INNER JOIN 'topper main points results' r ON e.Sail Number = r.Sail Number GROUP BY e.Name ORDER BY Score DESC Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\Will\My Documents\xampp\htdocs\sailing\displayres.php on line 79 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\Will\My Documents\xampp\htdocs\sailing\displayres.php on line 69[/code] any ideas?
  8. ok, still got problems [code]SELECT e.Name, SUM(r.Position) as Score FROM 'topper main points' e INNER JOIN topper main points results r ON e.Sail Number = r.Sail Number GROUP BY e.Name ORDER BY Score DESC Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\Will\My Documents\xampp\htdocs\sailing\displayres.php on line 78 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\Will\My Documents\xampp\htdocs\sailing\displayres.php on line 69[/code]
  9. hi mb81, I found i havent declared all variables ill post results in a sec
  10. here's the code concerned: [code] /////code, if table submitted then display else dont// $willitgo = $_REQUEST['display']; if ($willitgo=="Submit"){ ?> <!-- Display table data --> <table width="100%" border="1"> <tr> <td>Position</td> <td>Name</td> <td>Sail Number</td> <td>Class</td> <td>Score</td> </tr> <?php $q= "SELECT * FROM `$comp` ORDER BY `score` ASC";     $result = mysql_query ($q) or die('Problem with query: ' . $q . '<br />' . mysql_error()); $count = 1; while ($row = mysql_fetch_assoc($result)){     $name=$row['Name'];     $snum=$row['Sail Number'];     $class=$row['Class']; $sql = "SELECT e.Name, SUM(r.Position) as Score FROM '$compl' e INNER JOIN $compres r ON e.Sail Number = r.Sail Number GROUP BY e.Name ORDER BY Score DESC";          $result = mysql_query($sql); $score= mysql_fetch_array($result); echo ("<tr>" . "<td>" . $count . "</td>" . "<td>" . $name . "</td>" . "<td>" . $snum . "</td>" . "<td>" . $class . "</td>" . "<td>" . $score . "</td></tr>"); $count = $count + 1; } ?> </table> <?php }?> [/code] it's the inner join part in the middle that's confusing me... anyways, i get this error: [code] Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\Will\My Documents\xampp\htdocs\sailing\displayres.php on line 74 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\Will\My Documents\xampp\htdocs\sailing\displayres.php on line 66 [/code] (my code started on line 46) the following tables are concerned: "topper main points results" [img src=\"http://i7.photobucket.com/albums/y254/willwill100/tmpr.gif\" border=\"0\" alt=\"IPB Image\" /] "topper main points" [img src=\"http://i7.photobucket.com/albums/y254/willwill100/tmp.gif\" border=\"0\" alt=\"IPB Image\" /] what i want is for all the results from the same sail number to be added together and then take the equivalent name and class(that is type of boat) and then put all these details into a results table with a results column with ascending positions. Thanks for your time, Will
  11. this way has actually worked well, thanx for the help. more help needed tho... [code]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''topper main points' e INNER JOIN topper main points Results r ON e.Sail Number ' at line 1[/code] with the code: [code]$sql = "SELECT e.Name, SUM(r.Position) as Score FROM '$compl' e INNER JOIN $compres r ON e.Sail Number = r.Sail Number GROUP BY e.Name";[/code] could you explain what the code does? does it take all the results from a certain sail number, add them together and then shuv them into score in the main table?(coz thats what i want to happen,lol) thanx again guys
  12. sorry, i dont have time to restructure my table. what you suggested would mean that I could not display individual results which I dont want to do. There are going to be several number of race columns eventually. In other words i am going to have unlimited number of "race_result"s and so you code does not account for that. I have several tables with the same structure as the one in my first post but they are for separate competitions. Your code would work fine if I only had one compeition and one result, unfortunately I have an unlimited number of each.... Is there a way that i can select all columns except: "Name | sail_number | classs | score " and then add the data in them and then insert that value into 'score' I cannot consider a restructure at this point, can anyone hink of a workaround.
  13. i have a table which is structured as follows: [img src=\"http://i7.photobucket.com/albums/y254/willwill100/structure.gif\" border=\"0\" alt=\"IPB Image\" /] the thing is that users will create new race columns; basically I can have unlimited number of race columns. these 'race columns' will have positions in them, i want the database to lookup all the 'race columns' add all their values together and them insert that value into score. is there a way of selecting all the column names using the LIKE function or something like that? or is this impossible? Thanks in advance
×
×
  • 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.