Jump to content

help -.-

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
hardinera

hardinera

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
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.. :crying:

<?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 "

$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..
$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>";} 

can someone help me how to count im kinda new to this stuff -.-
thank so much:love:

Edited by hardinera, 07 March 2010 - 07:46 PM.
-


#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
1. Debugging MySQL issues in PHP John Ciacia
2. PHP: mysql_fetch_array - Manual

Quote

Returns an array of strings that corresponds to the fetched row...
3. Try:
$x = array(1, 2, 3, 4);
echo $x;


#3
hardinera

hardinera

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
problem solved lol -.- heres my code.. if anyone wants this....

//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;


#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
Glad you solved it -.-