Jump to content

willwill100

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Everything posted by willwill100

  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
  14. thanx for the help, it works now
  15. 22/03/06 Race 1 i have used it in phpmyadmin and it returns a positive result any more ideas?
  16. with the code you gave me i get the error: [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 'points SET 22/03/06 Race 1 = '1' WHERE Name = 'Will Williams'' at line 1[/code] No, im not creating a new column im just inserting into a column that was just created. It's a sailing system that is supposed to transfer what I have in temp into the proper results table with the corrects positions etc..
  17. BUMP I really need help with this, I have to have the system working by tomoro! Could someone give this query some time? Thanks in advance Will
  18. i have declared '$compl' earlier, thats not the problem wickning1, my col names and table name have been changed to the `` and it has made some progress. Now when i send $name to be "Stewart Brown" i get this error: [code]Unknown column 'Stewart Brown' in 'where clause'[/code] i dont see why it should do this since i am declaring '$colnom' as the column name. Heres my latest full code: [code]$comp = $_REQUEST['comp']; $tdate = date('j/m/y');//Get todays date $raceno = $_REQUEST['raceno']; $compl = strtolower($comp); $colnom = ($tdate . " Race " . $raceno); //Find Name for column echo ($colnom); $q= "SELECT `Name` , `Position` FROM `temp`"; $result = mysql_query ($q) or die('Problem with query: ' . $q . '<br />' . mysql_error()); while ($row = mysql_fetch_assoc($result)){          $name=$row['Name'];     $pos=$row['Position'];      $query = mysql_query("UPDATE `$compl` SET `$colnom` = `$pos` WHERE `Name`=`$name`") or die(mysql_error() . $query); echo ("Updated sailor: " . $name . "<br>"); } [/code] any ideas as to the problem??
  19. my update query will not work: [code]$q= "SELECT `Name` , `Position` FROM `temp`"; $result = mysql_query ($q) or die('Problem with query: ' . $q . '<br />' . mysql_error()); while ($row = mysql_fetch_assoc($result)){          $name=$row['Name'];     $pos=$row['Position'];      $query = mysql_query("UPDATE '$compl' SET '$colnom' = '$pos' WHERE `Name`='$name'") or die(mysql_error() . $query); echo ("Updated sailor: " . $name . "<br>"); }[/code] it just returns the error: [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' '22/03/06 Race 1' = '2' WHERE CONVERT( `Name` USING utf8 ) ' at line 1[/code] what could be wrong with the query?
  20. thats great, thanx for the help guys!
  21. okay that makes sense but i still get the error. any ideas, im really stuck on how to get my table to check if there is already a user in it and enter one if the user is not in the table.....
  22. ok, ive ammended my code but i still get a negative result: [code]////if their name does not already exist in the REAL table, insert it//// $q = "SELECT COUNT(*) FROM `$compl` WHERE `Sail Number`='$snum'"; echo ("<pre>" . $q . "</pre>"); $rs = mysql_query($q) or die('Problem with query: ' . $q . '<br>' . mysql_error()); if (mysql_fetch_assoc($rs)==0){     $b = "INSERT INTO `$compl` ( `Name` , `Sail Number` , `Class`) VALUES ( '$name', '$snum', '$boattype')";    }else{ echo ("<br>No user updated!"); }[/code] I have inputted $q into phpmyadmin and a value of "0" is returned, why then is the "if statement" taken to be false and "No user updated!" outputted??
×
×
  • 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.