XF 1.2 PHP Callback

Secretchaos

Member
Hello,

I'm very new to XenForo en starting to work with the php callback function. It was a little bit strugling to get started. But now I have a problem, wich I can't solve myself.

First I will show the callback.

PHP:
<?php
class problemen_db
{
    public static function respond(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)
    {
    $con=mysqli_connect("*****","****","*****","*******");
        // Check connection
    if (mysqli_connect_errno()) {
        echo "De server kon geen verbinding maken met de database, error: " . mysqli_connect_error();
    }
        // Query
    $Query = mysqli_query($con,"SELECT * FROM Problems");
    while($Result = mysqli_fetch_array($Query))
    {
        $response->params['id'] = $Result['id']; 
        $response->params['Server'] = $Result['Server'];
        $response->params['Problem'] = $Result['Problem'];
        $response->params['Solved'] = $Result['Solved'];
        $response->params['Player'] = $Result['Player'];
        $response->params['Date'] = $Result['Date'];         
    }
    $response->templateName = 'problemen';
    }
}
?>
And my template:
HTML:
<!-- This CSS is specific to each page and can either modify the existing classes or be used in isolation -->
<style type="text/css">


.page_generalText{
text-align: justify;
}

.page_section{
padding:0 0 10px!important;
overflow: hidden;
zoom: 1;
}

.page_header{
margin-top: 0 !important;
}

.page_memberDetails{
float: left;
margin-right: 10px;
clear: both;
}

.page_memberName{
text-align: center;
word-wrap: break-word;
width: 122px;
margin-top: 0 !important;
margin-bottom: 0 !important;
}

.page_memberText{
text-align: justify;
}


</style>

<div class="baseHtml messageText"> <!-- All content must be wrapped in these default classes to enable pages to use the same CSS as forum posts and automatically update with each style -->

<!-- Introduction section -->
    <div class="sectionMain">
        <div class="page_generalText">
        Op deze pagina enzo :)
            <br>
            Deze mensen zorgen ervoor dat jullie de beste speelervaring hebben, en dit allemaal vrijwillig.
            <br />
        </div>
    </div>
<!-- Problem section -->
    <div class="sectionMain">
        <div class="page_generalText">
        <table border='1'>
        <tr><th>id</th><th>Server</th><th>Probleem</th><th>Opgelost</th><th>Player</th><th>Datum</th></tr>
        <tr><td>{$id}</td><td>{$Server}</td><td>{$Problem}</td><td>{$Solved}</td><td>{$Player}</td><td>{$Date}</td></tr>
        </table>
        </div>
    </div>
</div>
Output:
6acbbed9440fad3f666c93deb99aa9d8.png

This works fine, except it only displays one record. In stead of the whole tabel. And I can't find out how to solve this.

I want to thank you, for your time.
(Sorry for the bad grammar, I'm from the netherlands)
 
What is the best way to do this with XenForo? A friend of me said loop the table, so put that in a different tpl. En create a callback wich loops it.

Anyone have a better option? Otherwise I will try the method of that friend.

Thanks for your reaction @Slavik !
 
What is the best way to do this with XenForo? A friend of me said loop the table, so put that in a different tpl. En create a callback wich loops it.

Anyone have a better option? Otherwise I will try the method of that friend.

Thanks for your reaction @Slavik !

Take a look at the member_list template as an example.

Code:
<ol class="section memberList">
 <xen:foreach loop="$users" value="$user">
 <xen:include template="member_list_item">
 <xen:set var="$noOverlay">1</xen:set>
 </xen:include>
 </xen:foreach>
</ol>
 
Top Bottom