Jump to content

hga77

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

hga77's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks mate it works now...hours of fustrations and now its good to go...:) Cheers for that ;)
  2. Thanks for this. I wanted to have the sql do all the hard work but this should work great too. Now the other issue is Im struggling to use foreach to retrieve the content. Maybe an example :) Thanks mate
  3. I have two tables. codes and users. The codes table holds the unique codes along with a reference key which is the user_id, to link to the users table. They look like this: table 1:[b]users[/b]{[u]user_id[/u], name} table 2:[b]codes[/b]{[u]the_codes[/u], user_id, final_score, seconds} Users must answer 10 questions in the fastest time. This query is needed for the leaderboard. Lets fill those tables with data: [b]users[/b] user_id     name -------    ------ 1             Jim 2             Bob 3             Lee 4             Peter [b]codes[/b] the_codes     user_id      final_score      seconds ----------    --------     -----------     ----- 1111               1                10               5 2222               1                10               4 3333               1                6                 2 4444               3                10               8 5555               4                8                 8 [b]Result I need after query:[/b] the_codes     user_id      final_score      seconds    name ----------    --------     -----------     -----       ------ 2222               1                10               4           Jim 4444               3                10               8           Lee 5555               4                8                 8          Peter **notice the order from top to bottom, heighest score with lowest time, and without duplicating all the scores for Jim, just his best score! Now I need to query those two tables and get a list of scores (dont want scores by the same user, just one score per user being the best score ofcourse) starting with the highest score with the lowest time, onwards. I can do this fine, but I cant remove the duplicates. I have tried Distict 'user_id', Group By 'user_id', Union etc. But I'm not an SQL master so I dont really know advanced sql. This is the current sql Im using: $sql = "SELECT * FROM codes, users WHERE codes.user_id=users.user_id ORDER BY final_score DESC, seconds ASC"; Please tell me how I can modify this so I dont get those annoying duplicates and still get the best score per user. Thank you.
  4. This is so wierd. I am getting very frustrated. This is the worst kind of coding bug you can get!!! Why? cos its random and I cant track where the problem is coming from. Ok, let me explain: I have an html file that holds the html layout for the email. (email_template.html) From php, I use: [code]$htmlbody = file_get_contents("email_template.html");[/code] within this html file, I have a variable: $$content$$ I set a variable ($content) and give it some more html, but within php. Then I say in php: [code]htmlbody = str_replace('$$content$$', $content, $htmlbody);[/code] Finally I use phpMailer to send the email using $htmlbody This ALWAYS worked before! But now I get some really wierd result within the html from any email client. And I always randomly get this within the html that messes it up -> & # 13;&# 10; I know thats ascii line feed and something else...But why dont I just get clean html and untouched when its been sent? Any help appreciated
×
×
  • 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.