Jump to content

Kristoff1875

Members
  • Posts

    242
  • Joined

  • Last visited

Posts posted by Kristoff1875

  1. My Races Table, note RaceID 50000

     

    https://www.dropbox.com/s/vwha17y80h9kgw8/Screenshot%202014-03-31%2019.47.13.png

     

    This is my Results table which did have data that tied up with the other tables, such as RaceID 50000 did show up, but now all related values have vanished. Here is the browse tab:

     

    https://www.dropbox.com/s/1t6m9gcu0cj52vx/Screenshot%202014-03-31%2019.48.01.png

     

    Here is select all search:

     

    https://www.dropbox.com/s/902xthpzgvusq9l/Screenshot%202014-03-31%2019.49.26.png

  2. Guys would you be able to shed any light on my next problem? In the results table i've got a UserID appearing twice, each one has it's relative finishing result, for example 1 and 5 for first and fifth. Have you guys got any idea on how I should calculate those in to a total of points? For example If first position received 10 points, second received 9 and so on, to calculate the total points?

  3. Just a quick one then if you could... How would I go about making each result unique? For example so that only 1 User can finish in 3rd place per race, and so that each UserID can only be in each result once?

     

    Ignore that, think i've done it now.

  4. I have a few tables: Results, Races and Users. Users has "UserID" indexed, Races has "RaceID" indexed and the plan was to use Results to grab it all together. Issue is each Result has 24 places and I wanted to call the user ID's for each position, so P1 and then link it to a UserID all the way to 24. When trying to do this though i'm getting the error:

     

    Too many key parts specified; max 16 parts allowed

     

    Does anyone have any idea of how I can get around this?

  5. A LEFT JOIN B ---> Returns all records in A with data from B where there is a match, otherwise null values from B

    A INNER JOIN B ---> Ony returns rows where there is matching data in both A and B

    Perfect thank you, you're a star. Amazing how something so simple can throw you off in such a way!

  6. Ok, I think I understand why it's returning 1 row, because it's seeing that the user exists, but not any transactions. So the result does exist, but the transactions don't... Gazumped now though as I don't know how to check for results that match both.

  7. There's no transactions currently, but there are users, but there can't be any transactions by the logged in user as there are no transactions at all. Sorry, when I said no rows in the table I meant no rows related to the query, although there are no rows in transactions.

  8. Hi guys, trying to make the move to MySQLi and some of it is baffling me. Quick question as my query is currently saying there's 1 result even if there isn't one...

     

    How do I go about finding the number of rows returned for this:

    $sql = <<<SQL
        SELECT u.*, t.*
        FROM Users u
    	LEFT JOIN Transactions t USING (UserID) 
    	WHERE UserID = $UserID
    	ORDER BY Date DESC
    	LIMIT 5
    SQL;
    

    Thanks in advanced!

  9. Ah, so simple! Thanks. Is there a way to check for the:

     

    Fatal error: Wrong SQL: INSERT INTO Selected ..... Error: Duplicate entry

     

     

    Message and then use a custom error message? I'm searching google for this currently, just thought I'd ask here too.

    Thanks again for your help!

     

    ------------
     

    Ok, so it's this part:

    if($db->query($sql) === false) {
      trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $db->error, E_USER_ERROR);
    } else {
     PRINT "Inserted"; 
    }
    

    Showing the error, so can I break this down in to different error pages?

  10. Could you guys point me in the direction for this by any chance?

     

    I have the value of boxes selected being passed as:

     

    box1,box2,box3

     

    But no matter what I do, I can't seem to get this to insert to the database with a foreach statement. Here's what i've got:

    $Selected = $_POST['Selected'];
    
    $Selected1 = explode(',', $Selected);
    $Selected2 = implode(',', $Selected);
    
    
    $v1="'" . $db->real_escape_string('UserID') . "'";
    
    foreach($Selected as $Selection){
    	
        $sql = "INSERT INTO Selected (BoxID) VALUES ('$Selection')";
    

    I've tried any mixture of these, including foreach($Selected1 as $Selection) and foreach($Selected 2 as $Selection) but don't seem to be getting anywhere. Anybody got any pointers for me please?!

  11. Nope, i'm talking more backend stuff. The idea is, depending on which SaleID is opened by the user, the page then calls all of the already taken boxes from the database and assigns them to the boxes on the site and as such says "This one is taken" and even if they try to choose it, it won't let them. What I am more meaning is as you say, double checking that they aren't somehow trying to add a box that someone else already has. Obviously that shouldn't be an issue if the UI works correctly, but just as a precaution!

  12. Hi guys, before I get to the main part of my question, I first wanted to ask whether there is a maximum number of values you should store in an array. If for example you have 5000 boxes that people can choose from and eventually all 5000 boxes will be chosen, is it save to store all of the chosen boxes in an array? For example box1,box5,box7,box21 are already chosen, then someone chooses box2,box3,box4 and it adds to the same array, is that feasible with up to 5000 values in total? My thoughts on it were that it would probably be more feasible than giving each box it's own column!?

     

    Secondly, assuming the above is ok, how would I go about ensuring nobody could choose a box already chosen? Basically, if somebody chooses box3 and box4, how can I check that these don't exist in the column before adding them so they don't duplicate?

     

    Hope this makes some sense and isn't just gobblydeegook!

     

    Finally, if somebody in the Users table chooses box3 and box4 from SaleID5, what would be the best way of storing what they've chosen in the User table to use the data when they're viewing what they've got?!

     

    Many thanks in advance guys.

  13. Well, what i'm inputting is this:

     

    Option One

    Delegate 1 Name: Example1

    Delegate 1 Email: Example1@eg.com

    Delegate 1 Position: Manager

     

    Delegate 2 Name:

    Delegate 2 Email:

    Delegate 2 Position:

     

    Delegate 3 Name:

    Delegate 3 Email:

    Delegate 3 Position:

     

    Which I was then sending to a unique row, in to the following columns:

     

    OneDel1 -> Example1, Manager

    OneDel1Email -> Example1@eg.com

     

    OneDel2

    OneDel2Email

     

    OneDel3

    OneDel3Email

     

    I'm storing the position with the name and for the purpose it's been serving, it's been working fine. But now I just need to check and see which of the columns of the selected row are empty so I can total them up.

  14. One piece of data per row? Do you mean rather than having OneDel1 OneDel2 etc, to use OneDel and store them in there as an array? The problem with that for me is that for each OneDel there is also an OneDel1Email and OneDel1Position (number changes for each) and some rows may only have 1 piece of data for each, some may have 4.

×
×
  • 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.