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..
and if i do this it says " Resource id #4 "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.... this just prints the guest id number..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;
can someone help me how to count im kinda new to this stuff -.-Code:$sql= mysql_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>";}
thank so much![]()
Last edited by hardinera; 03-07-2010 at 07:46 PM. Reason: -
1. Debugging MySQL issues in PHP John Ciacia
2. PHP: mysql_fetch_array - Manual
3. Try:Returns an array of strings that corresponds to the fetched row...
Code:$x = array(1, 2, 3, 4);
echo $x;
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 + 1 ;
}
//COUNTING CONTENT
echo $total;
Glad you solved it -.-
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks