Jump to content

annihilate

Members
  • Posts

    63
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.newenigma.com

Profile Information

  • Gender
    Male
  • Location
    UK

annihilate's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This line: if(mysql_num_rows($players >= 1)){ Needs changing to: if (mysql_num_rows($players) >= 1) {
  2. You need to use mysql_connect function if you're connecting to a MySQL database. http://php.net/manual/en/function.mysql-connect.php
  3. $az = range('a', 'z'); $current_letter = 'f'; $current_key = array_search($current_letter, $az); $next_letter = ($current_key !== false && $current_key < (count($az) - 1)) ? $az[++$current_key] : ''; echo $next_letter; // prints g Would obviously need some work to handle what happens if the current letter isn't found in the array or when the letter is z. Currently will just assign next letter to be an empty string in these circumstances.
  4. Take a look at subdate: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_subdate In your case, you could do the following and end the query with: WHERE rdate > SUBDATE(SYSDATE(), 1)
  5. If I understand the question correctly, you would need to change your order by to distance instead of pb. This is only going to work as you expect if all the distances are in the database in the same unit. eg 100 and 3000 mean 100 metres and 3000 metres. If you have entries like 100 metres and 3K, then its not going to work as expected.
  6. You have a comma in your insert statement after member5 which shouldn't be there. Remove the comma and try running the query again.
  7. Try this: <?php $cont = load_template("main-content"); $contid = $_GET['content_id'] == "" ? "about" : $_GET['content_id']; ?>
  8. Hi there, I have just switched over to php5 and so have started making the variables in my classes private and then greating a public function which gets them. Previously, I had this code in a page: echo $movies_base->cert_array[$movie['cert']]; cert_array is a var in the movies base class, and it is an array. Under php5, I have made cert_array private, and added a getter for it. So now I have echo $movies_base->get_cert_array()[$movie['cert']]; The above line is not valid code. My question is: is it possible to do what I need in one line or do I have to something like the following: $cert_array = $movies_base->get_cert_array(); echo $cert_array[$movie['cert']]; Thanks Colin
  9. That's right. Could also add an exit() statement just in case something goes wrong. <?php $email_address = $_GET['address']; // email address passed in query string header("Location: http://www.notcool.com/welcome.php?email=".$email_address); // the redirect exit(); ?>
  10. On your welcome.php page: (needs to go before any output) $email_address = $_GET['address']; // email address passed in query string header("Location: http://www.notcool.com/welcome.php?email=".$email_address); // the redirect Are you doing anything else on the welcome.php page, or just the redirect, because if its just the redirect, it seems a bit redundant. You might as well handle the redirect beforehand where you add the email address to the database etc.
  11. Do you want an automatic redirection from your cool.com/welcome.php page to the nocool.com/welcome.php page or does a link need to be clicked first to go to the nocool.com site?
  12. I'm not too sure exactly what you are after, but if you want to read the parameters in the query string, on the page you can just do: $email_address = $_GET['email']; So on your welcome.php page, that bit of code will give you the value of the email address that is in the query string.
  13. Hi, have actually just got this fixed. Someone over at Devshed posted the correct query to use, which ended up being this: SELECT tv_show_names.show_id, tv_show_names.show_name, tv_seasons.season, tv_seasons.season_id, tv_seasons.episodes as total_episodes, tv_seasons_watched.episodes as watched FROM tv_show_names LEFT JOIN tv_seasons ON tv_show_names.show_id = tv_seasons.show_id LEFT JOIN tv_seasons_watched ON tv_seasons.season_id = tv_seasons_watched.season_id AND tv_seasons_watched.user_id = 3 LEFT JOIN tv_shows_tracked ON tv_seasons.show_id = tv_shows_tracked.show_id WHERE tv_shows_tracked.user_id = 3 ORDER BY show_name, season The addition of the AND clause was basically the fix, and the query has been tidied up/rearraged as well.
  14. Basically, currently, I have 28 TV shows in the tv_show_names table. I have 32 seasons added in the tv_seasons table, as some TV shows have more than one season. I log in as user_id 1 and select the TV shows I want to track out of the possible 28. I select them all, so I am now tracking all shows. So when I ran that query for the first time, it returned 32 rows (as expected, since there are 32 seasons added and I am tracking every show), the value for num_watched was NULL (also correct so far). I then updated what episodes I had watched. So for example, I have show_id with value 2. This has 6 seasons associated with it. I update it so that the tv_seasons_watched table has 6 entries in it saying user_id 1 has watched 24 episodes of season_id's 3, 4, 5, 6, 7, and 8. I then log out of that user and log in as someone else. user_id 3. I select the TV shows I want to track. I select only one show, show_id 2. Both user_id 1 and user_id 3 are now tracking this TV show. I then run that query and it returns me 6 rows. Again, this is the correct number of rows, since show_id 2 has 6 seasons associated with it. (season_id's 3,4,5,6,7 and 8 ). However, the problem is that the num_watched value is returning 24 for all 6 episodes. This is what user_id 1 has watched, however, user_id 3 has not watched any episodes and has no rows in the tv_seasons_watched table, and therefore should be returning NULL for num_watched. Hope that explains it. Thanks Colin
  15. Hi MySQL server version is: 4.1.22 I am having some trouble writing a query. First off, I will show the table structure: Table: tv_seasons Fields: season_id, show_id, season, episodes season_id is a primary key, auto increment value. show_id corresponds with an id from the tv_show_names table. season is the season number, and episodes is the total number of episodes for that season. Table: tv_seasons_watched Fields: season_id, episodes, user_id season_id corresponds to a season_id from the tv_seasons table. episodes is the number of epsidoes the user has watched of that season. user_id is the user_id of the person who has watched that season. Table: tv_shows_tracked Fields: user_id, show_id user_id is the user_id of the user and show_id corresponds to a show_id from the tv_show_names table. Table: tv_show_names Fields: show_id, show_name, date_added show_id is primary key, auto incremented value. show_name is the name of the show, date_added is the date this show was added to the database. So there are some TV show names in the tv_show_names table. A user can then select which of these shows they want to keep track of. This updates the tv_shows_tracked table. A season for a TV show is added to the tv_seasons table. If a user is tracking a show, and some seasons exist for that show, they can then select how many episodes of that TV show they have watched. This updates the tv_seasons_watched table. The query I want to perform is as follows: For a user, I want to display the show names they are tracking which have exisitng seasons, and show how many episodes they have watched. I thought I had it working until I logged in as another user, and saw that it was not working correctly. The current query: SELECT *, tv_seasons.*, tv_show_names.show_name, tv_seasons_watched.episodes AS num_watched, tv_seasons_watched.user_id FROM tv_shows_tracked LEFT JOIN tv_show_names ON tv_shows_tracked.show_id = tv_show_names.show_id LEFT JOIN tv_seasons_watched ON tv_seasons_watched.season_id = tv_seasons.season_id INNER JOIN tv_seasons ON tv_seasons.show_id = tv_shows_tracked.show_id WHERE tv_shows_tracked.user_id = '1' ORDER BY show_name, season Note: the user_id of 1 in above code is dynamic in the actual query, taking the value of the current logged in user. This seems to work when I am logged in with user_id of 1. However, when logged in as user_id 3, it will show the results of user id 1 for the shows that user_id 3 is tracking. So for example, if both users are tracking show_id 4, and user_id 1 has watched all 20 episodes of season 1 of show_id 4, then it will display as user_id 3 having also watched all 20 episodes. Hopefully anyone reading this understands. If not please let me know and I'll try and provide more info. Thanks Colin
×
×
  • 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.