A
A
Abay Tazhigaliev2016-01-31 13:40:08
PHP
Abay Tazhigaliev, 2016-01-31 13:40:08

How to make the path of the last comments to a particular section?

13046b7e9eb04f099c236d80476e5940.jpg
The database has 3 tables of videos, articles, photos.
Here is a database query
function get_last_comments($lang){
db_connect();
$query = "SELECT * FROM comments WHERE comments.lang = '$lang' ORDER BY comments.id DESC LIMIT 3";
$result = mysql_query($query);
$result = db_result_to_array($result);
return $result;
}
And this is the loop that I output
<?php foreach($last_comments as $item):?>
<?=$item['text'];?>
<?php endforeach;?>
I need to make the correct path to the sections that comments are left ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
IceJOKER, 2016-01-31
@webcoderpro

The best option is to add another field in the comments table - target, to write 'article', 'photo', 'video' etc. there.
Otherwise, you will have to parse the link each time and, starting from the link, display where the comment was left

A
Abay Tazhigaliev, 2016-01-31
@webcoderpro

Thanks, I'll take a look!
Issue resolved
<?php foreach($last_comments as $item):?>
<?=str_size_title($item['text']);?>
<?php endforeach;?>
Wrote this code <?=$item['section '];?>
In the comment table there was a section field, just the path was not written correctly. Thanks, it works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question