Reputation: 3641
I have this:
$query = "SELECT time FROM table_schedule GROUP BY time ORDER BY count(*) desc LIMIT 1 ";
then I stored it in:
$result = mysql_query($query);
I will output the value by <?php echo $result ?>
but I am always getting this value Resource id #20.
I am new in sql so I hope someone can help me with my problem.
Upvotes: 2
Views: 45
Reputation: 8369
You are trying to show the result in a unproper way. In PHP mysql_query()
will execute a query. In order to get the result, you should use
$result = mysql_query($query);
$row=mysql_fetch_array($result); // fetches the result of the query and stores in an associative array
$time=$row['time']; // get the result from the associate array with field name as the index
You can also use ,
$row=mysql_fetch_row($result);
$time=$row[1];
which will fetch the result as an enumerated array where you want to display each fields with the column number starting from 0.
Upvotes: 1