S
S
Sergey Defactov2017-02-15 22:21:55
PHP
Sergey Defactov, 2017-02-15 22:21:55

How to output sql to php?

FUNCTION
must display the last 5 comments from posts

function Wo_GetAllComments() {
    global $wo, $sqlConnect;
    $data       = array();
    $type_table = T_COMMENTS;
    $type_id    = Wo_Secure('comment_id');
    $query_one  = mysqli_query($sqlConnect, "SELECT `id` FROM {$type_table} WHERE 1 ORDER BY `time` DESC LIMIT 5");
    while ($fetched_data = mysqli_fetch_assoc($query_one)) {
        $data[] = Wo_UserData($fetched_data['comment_id']);
    }
    return $data;
}

Tried this method but 0 results
<?php 
                  foreach (Wo_GetAllComments() as $wo['comment']) {
                     echo $data;
                   }
                  ?>

help me please

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Wolf, 2017-02-15
@mannaro

Where did the $data variable come from?

E
Eugene, 2017-02-15
@Caravus

foreach (Wo_GetAllComments() as $comment) {
                     print_r($comment);
                   }

M
McBernar, 2017-02-15
@McBernar

Make a var_dump and see what arrives when the function is called. If the array is empty, then the problem is in the request. Or not.
What does the Wo_UserData($fetched_data['comment_id']); function do?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question