How to print php result from query without table?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kdao
Forum Newbie
Posts: 9
Joined: Fri Jun 13, 2008 11:58 am

How to print php result from query without table?

Post by kdao »

<?php


$user='kdao';
$pass='khaidao';
$host='localhost';
$db='kdao';
$table='guessbook';

$conn = mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db,$conn);

$query_1 = "select concat('There are ',to_days('2008-10-15') - to_days(current_date()),' left to the special holiday .');
$result_1 = mysql_query($query_1);

print "Hello world";

mysql_close($conn);
?>
parimala
Forum Newbie
Posts: 8
Joined: Wed Jun 11, 2008 7:21 am

Re: How to print php result from query without table?

Post by parimala »

hi kdao

you had written every thing correctly but the minor mistake is you forgot to keep the " quotation at the end of the statement.

The proper format is
$query_1 = "select concat('There are ',to_days('2008-10-15') - to_days(current_date()),' left to the special holiday .')";
$result_1 = mysql_query($query_1);
echo mysql_result($result_1,0,0);

you will get the result without a table;

thanks and regards
parimala
Post Reply