Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 25
  1. #11
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    While joins involve a fair bit of overhead, I'm pretty sure `over 10,000' isn't where you start running into issues. Usually I read about people getting problems when their amount starts reaching over a million records.

    Nonetheless, it's always wise to, for example, only include information you need on that particular page. It's also useful to cache results, so that the database only gets hit once for every page for every update. There are many other approaches you can use to lighten the load on your database, too.

  2.  

  3. #12
    Junior Member
    Join Date
    Dec 2005
    Location
    Vilnius, Lithuania
    Posts
    17
    Member #
    12192
    Hello Shadowfield,

    Assuming, I'm selecting all games of a particular team from a table "games". I'm using a while loop in my php to create an output table.
    Is there any way how I can store the team name and use it outside the while cycle (for page title and header). Usually I call the db twice to achieve this.
    That would be a nice improvement!
    Thank you.

  4. #13
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Sure. That's what variables are for What trouble do you see with trying to achieve this currently?

  5. #14
    Junior Member
    Join Date
    Dec 2005
    Location
    Vilnius, Lithuania
    Posts
    17
    Member #
    12192
    The main trouble is my limited knowledge of programming technique
    I'll type here a simplified example of the problem:

    <table>
    <?
    if ($team) {
    $query = mysql_query("SELECT team, result, tour FROM db_games") or die (mysql_error());
    while($row = mysql_fetch_array($query)) {

    echo '<tr><td>team</td><td>result</td><td>tour</td></tr>'; }

    }
    ?>
    </table>
    Simple even for me. But what if i want to use "team" field from db in <title></title> and headers <h1>, <h2>...?
    As for now I'd make another query (on the same page to the same table db_games) to select "team" but it seems to be a clumsy way.

  6. #15
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Note: You shouldn't have a separate table for "total". The data you're proposing to store there could be simply attained from a query of your other tables.

  7. #16
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well, if you've got a guarantee that the team is going to be the same, then you can just do the one query and use the first row to grab the team name for the title.

  8. #17
    Junior Member
    Join Date
    Dec 2005
    Location
    Vilnius, Lithuania
    Posts
    17
    Member #
    12192
    Oh, hello gentlemen ))

    As for your comment transio - these can be calculated somehow?
    `total_gms` int(4) NOT NULL,
    `won` int(4) NOT NULL,
    `lost` int(4) NOT NULL,
    `balance` varchar(20) NOT NULL,
    `points` int(5) NOT NULL,
    And how about:
    `place` int(5) NOT NULL, - should the script "place" teams automatically based on results?
    Doesn't seem to be easy )) [i don't know how to make math calculations on db quires]

    Shadowfiend, can i ask you to give me a primitive example of how to:
    1) select all
    2) use the selected data in a cycle while for building a table or a list
    3) use the same data outside the cycle
    Example:
    select data and build a table of results for a particular team;
    use the team name (acquired from the db together with other data) for a header.
    To me it's just 2 different quires...

    That would be really helpful, cause i believe that you are right ))

  9. #18
    Junior Member
    Join Date
    Dec 2005
    Location
    Vilnius, Lithuania
    Posts
    17
    Member #
    12192
    And sorry for another stupid one, just as you are here...
    How to order correctly tours
    1,2,3,...10,11,...and finally 1/8, 1/4, 1/2 ? or should i use some sort of replacements (tour ids). Probably i should.
    Even without that dodgy 1/2 normal order is breaking since 1 is followed by 11, 12, etc and only after 2, 20...

  10. #19
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    mmdesign,

    I suggest that you read the MySQL manual on DDL (13.1) and DML (13.2) to get a handle on the language.

    http://dev.mysql.com/doc/refman/4.1/en/sql-syntax.html

    Also, reference the MySQL function list to get an understanding of how you can further manipulate data:

    http://dev.mysql.com/doc/refman/4.1/en/functions.html

    Specifically, you should focus on the following: Sub-SELECT, COLLATE, GROUP, SUM, MAX, and other aggregate data manipulators:

    http://dev.mysql.com/doc/refman/4.1/...modifiers.html

    You should probably also get a book on SQL. I recommend "SQL for Smarties".

    Get a basic understanding of SQL so you can post specific questions. That way, you're not essentially coming here asking us to design your database for you (a service our clients pay us very handsomely for).

    If there's something you can't figure out after reading the manual, post specific questions and we'll be happy to respond.

  11. #20
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    Quote Originally Posted by mmdesign
    And sorry for another stupid one, just as you are here...
    How to order correctly tours
    1,2,3,...10,11,...and finally 1/8, 1/4, 1/2 ? or should i use some sort of replacements (tour ids). Probably i should.
    Even without that dodgy 1/2 normal order is breaking since 1 is followed by 11, 12, etc and only after 2, 20...
    Use decimals.

    1/8 = 0.125
    1/4 = 0.25
    1/2 = 0.5

    It would be easy to convert when you need it.


Page 2 of 3 FirstFirst 1 2 3 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:18 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com