Closed Thread
Results 1 to 4 of 4

Thread: help -.-

  1. #1
    hardinera's Avatar
    hardinera is offline Learning Programmer
    Join Date
    Jul 2009
    Posts
    42
    Rep Power
    0

    help -.-

    i just want to print the query i made.. if i type my query on MySql it returns how many the items that selected query

    but when i use php
    with this code i keep getting "array" and i don't know what that means..

    Code:
    <?php
    $username 
    "root";
    $password "";
    $host "localhost";
    $database "h_reservation";

    $connection = @mysql_connect($host$username$password) or die("Can not connect to database: ".mysql_error());

    $db = @mysql_select_db($database) or die("Can not select the database: ".mysql_error());


    $query mysql_query("select count('guest_id') from guest_info where room_type = 'double room' and
    check_in >= '2010-02-11'"
    ); 
    $row mysql_fetch_array($query);
    echo 
    $row;



    ?>
    and if i do this it says " Resource id #4 "

    Code:
    $sql "select count('guest_id') from guest_info where room_type = 'double room' and
    check_in >= '2010-02-11'"

    $row mysql_query($sql);

    echo 
    $row
    and if i do this.... this just prints the guest id number..
    Code:
    $sqlmysql_query("SELECT * FROM guest_info where room_type = 'double room' and
    check_in >= '2010-02-11'"
    ); 

    while(
    $row mysql_fetch_array($sql)){

    echo 
    $row['guest_id'] . "<br>";} 
    can someone help me how to count im kinda new to this stuff -.-
    thank so much
    Last edited by hardinera; 03-07-2010 at 07:46 PM. Reason: -

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: help -.-

    1. Debugging MySQL issues in PHP John Ciacia
    2. PHP: mysql_fetch_array - Manual
    Returns an array of strings that corresponds to the fetched row...
    3. Try:
    Code:
    $x = array(1234);
    echo 
    $x

  4. #3
    hardinera's Avatar
    hardinera is offline Learning Programmer
    Join Date
    Jul 2009
    Posts
    42
    Rep Power
    0

    Re: help -.-

    problem solved lol -.- heres my code.. if anyone wants this....

    Code:
    //DISPLAYING CONTENT!!

    $select mysql_query("SELECT * FROM guest_info where room_type = 'double room' and
    check_in >= '0000-00-00'"
    ); 

    $total 0;

    while(
    $row mysql_fetch_array($select)){

    echo 
    $row['guest_id'] . "<br>" "<br>";

    $total $total ;

    }

    //COUNTING CONTENT 

    echo $total

  5. #4
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: help -.-

    Glad you solved it -.-

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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