Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004
    Posts
    2

    Unanswered: Need help to speed up my sql querie's efficiency

    I'm currently working on a stockmarket game, and i need to figure a very efficient way to get alot of data from a table, heres how the table looks like:


    Code:
    orderid  volume  sellerid  buyerid  brokerid  ordertime  price  quote
    (and under that the data comes)
    Under these columns there might be generated 100's or 1000's lines hourly, so i need to make it as fast as possible. This table will be displayed in many of the pages.

    The code i got so far is prety slow, because it "while"-loops single line till the prefered amount of lines is reached, alot of unnecesary mysqlqueries. I've tried to look at different docs and tutorials, but can't figure it out.

    What would be most efficient way to fetch top 30 lines and converting 'orderid' 'volume' 'sellerid' 'buyerid' 'brokerid' 'ordertime' 'price' 'quote' into different-php-variables (different, imean like: $orderid = 'orderid') ?



    I realy appriciate your time
    Thanks in advance

  2. #2
    Join Date
    Jun 2004
    Posts
    11
    This is how i'd do it. Even with 1000 rows it shouldn't take that long.

    PHP Code:
    echo "<table><tr>
    <td>orderid</td><td>volume</td><td>sellerid</td>
    <td>buyerid</td><td>brokerid</td><td>ordertime</td>
    <td>price</td><td>quote</td>
    </tr>"
    ;

    $sql "SELECT orderid,volumne,sellerid,buyerid,brokerid,ordertime,price,quote FROM tblName LIMIT 30";
    $db mysql_connect($server$login$password);
    mysql_select_db($dbname);
    $result mysql_query($sql$db);
    while (
    $row mysql_fetch_array($resultMYSQL_ASSOC)) {
    echo 
    "<tr>";
    echo 
    "<td>" $row['orderid'] . "</td>";
    echo 
    "<td>" $row['volume'] . "</td>";
    echo 
    "<td>" $row['sellerid'] . "</td>";
    echo 
    "<td>" $row['buyerid'] . "</td>";
    echo 
    "<td>" $row['brokerid'] . "</td>";
    echo 
    "<td>" $row['ordertime'] . "</td>";
    echo 
    "<td>" $row['price'] . "</td>";
    echo 
    "<td>" $row['quote'] . "</td>";
    echo 
    "</tr>";
    }

    echo 
    "</table>"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •