How do I display how many are Online [closed] - php

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
So I would like to know how I would get something like this..
There are 7 Members Online
Using my Timestamp which is set as format
2016-04-25 19:27:00
I would like this to be within a 30 min gap. This is how I tried it, But it did not work.
<?php $logged = mysql_query("SELECT COUNT(time) FROM users where time >= 600 ;") or die(mysql_error()); ?>
There are <?php echo $logged; ?> Members Online

SELECT COUNT(*) as theCount
FROM users
where login_time + interval 30 minute >= now()

Related

group by hour and post (multiple) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I want something like this:
Table
And my database table is like this:
Database
How can I get this records group by (hour and post) at the same time?
And How can I print this results on html?
SELECT post_id, hour, COUNT(*) FROM <table_name> GROUP BY post_id, hour

How to retrive data from SQL from specific row to last record [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I want to get data from database from specific row to last row.
How can I do it?
You can set limit and offset with your sql query like this.
SELECT *
FROM your_table
ORDER BY id DESC
LIMIT 1, 1;
See more : http://www.mysqltutorial.org/mysql-limit.aspx
$sql="Select * from table order by id desc limit 20";//It will give you last 20 records

Get top 5 post count sql [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
$coins = #mysql_query("SELECT coin_id FROM coins WHERE user_id = '".user_id."'")or die (error_sql(mysql_error(),__LINE__,__FILE__));
I use this to show how many coins member have, and only the member can see his stats.
I want to show top 5 to public, I did not know how to do that.
Any help?
you could use this:
$coins = #mysql_query("SELECT coin_id FROM coins WHERE user_id = '".user_id."' LIMIT 5")or die (error_sql(mysql_error(),LINE,FILE));
Regards.

Select statement with sum and limit [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
What's wrong with this query and how can i output the result?
`SELECT sum(BM) from (SELECT rpdc.BM from rpdc LIMIT $start, $limit) as totalbm`
You need to give an alias for the sum something as
SELECT
sum(BM) as total_sum
from (SELECT rpdc.BM from rpdc LIMIT $start, $limit) as totalbm
Then in php you can use as
$row['total_sum'];
Hey you need to add as 'some_name' like SELECT name as firstname
Replcae with this sum(BM) as total
So, result array will treat total_sum as key of array.
You can use it as $result['total']

MySQL How to print the result of this query? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have this query:
$sql = $link->query("SELECT m.id_rel, (SELECT SUM(visita) as total FROM icar_mas_vistas WHERE id_rel = m.id_rel), icar_categorias.nombre
FROM icar_mas_vistas AS m, icar_categorias WHERE m.id_rel = icar_categorias.id_categoria");
if($sql->num_rows){
while($row = $sql->fetch_object()){
echo ''.$row->total.' '.$row->nombre.'';
}
It's working great in the SQL console, but when printing in PHP the value of total is not showing, how can i print it?
Thanks
Try change query adding AS total after brackets, to:
SELECT m.id_rel,
(SELECT SUM(visita) as total FROM icar_mas_vistas WHERE id_rel = m.id_rel) AS total, icar_categorias.nombre
FROM icar_mas_vistas AS m, icar_categorias
WHERE m.id_rel = icar_categorias.id_categoria

Categories