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.

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Dec 2015
    Posts
    6
    Member #
    52693

    Need MySQL PHP Help

    Hello,

    This script is suppose to connect to our database, go to the "bids" table and display the recent 5 bids from servers its suppose to display the server's name and the amount of the bid however it only displays 1 server instead of 5!

    <tbody>
    <?php
    $result = mysql_query("SELECT * FROM `bids`");

    $row = mysql_fetch_array($result);

    $serverid = $row['serverid'];
    $price = $row['price'];
    $result = mysql_query("SELECT name FROM `servers` WHERE id=$serverid LIMIT 5");
    while ($server_data = mysql_fetch_array($result)) {
    $servername = $server_data['name'];
    $info = array();
    #heres the problem line--># echo "<tr><td>" . $server_data['name'] . "</td><td>" . $row['price'] . "</td></tr>";
    }
    ?>
    Last edited by Deathcaptain; Dec 22nd, 2015 at 02:20 PM. Reason: in correct name

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,686
    Member #
    5580
    Liked
    716 times
    I'm not sure if this is it or not ...

    Change this line:

    $result = mysql_query("SELECT name FROM `servers` WHERE id=$serverid LIMIT 5");

    To this:

    $result = mysql_query("SELECT name, id, price FROM `servers` WHERE id=$serverid LIMIT 5");


    If you are using "id" as a condition, it also needs to be selected.
    Also, you wish to use "price" as well, for the echo.
    Last edited by mlseim; Dec 23rd, 2015 at 11:33 AM.


  4. #3
    Banned
    Join Date
    Dec 2015
    Posts
    75
    Member #
    52817
    Liked
    7 times
    Did you echo or var_dump the $result?


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 05:14 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com