PHP显示来自一个ID的记录

Overview Screenshot

Currently I have an overview of domains. I logged in with an account that has the contact ID of 197246. but it shows all of them. Here I want to filter my overview that the user which is logged in, sees his own domains.

So when ID 197246 logs in, show the domains that have contact id 197246. When ID 307890 logs in, show those domains.

This is my code so far. I guess here needs to be a filter.

<?php

unset($command);
$command = array(
    "command" => "DomainsListActive"
);

$api = new Versio_api();
$versio = $api->api_send($command);

if($versio['success']==0) {
    echo("Fout opgetreden. Fout code: ".$versio['command_response_code'].". Fout text: ".$versio['command_response_message']."");
}
else {
    if($versio['total_count']>0)
    {
require_once("includes/submenu.php");
?>
    <div class="col-sm-9 col-md-9" style="width:80%;">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title">Klantenpaneel</h3>
        </div>
        <div class="panel-body">
            <form method="post" action="">
                <table class="table table-striped">
                    <thead>
                      <tr>
                        <th>Domein</th>
                        <th>TLD</th>
                        <th>Verloop datum</th>
                        <th>Automatisch verlengen</th>
                        <th>contact ID</th>
                      </tr>
                    </thead>
                    <table class="table table-striped table-bordered">
                    <tbody>
<?php 
    $teller = 1;
    while($versio['total_count']>=$teller) {
?>
                      <tr>
                        <td><a href="records.php?domain=<?php echo        $versio['domain_'.$teller]; ?>&tld=<?php echo $versio['tld_'.$teller]; ?>">
                        <?php echo $versio['domain_'.$teller]; ?></a></td>
                        <td>.<?php echo $versio['tld_'.$teller]; ?></td> 
                        <td><?php echo $versio['expiration_date_'.$teller]; ?></td>
                        <td><?php echo $versio['auto_renew_'.$teller]; ?></td>
                        <td><?php echo $versio['contactid_'.$teller]; ?></td>
                      </tr>
<?php                  $teller++;
                    }
?> 
                    </tbody>
                </table>
            </form>
        </div>
    </div>
<?php
    } else {
        echo("Er zijn geen DNS records gevonden voor dit domein.");
    }
}
?>

</div>

The documentation from Versio gives you an entire list of options in the call. One option you could do is check if the 'contactid_x' equals to the logged in user.

more information on their wiki right here


As an example, this would do the trick:

unset($command);
$command = array(
    "command" => "DomainsListActive"
);

$api = new Versio_api();
$versio = $api->api_send($command);

if($versio['success']==0) {
    echo("Fout opgetreden. Fout code: ".$versio['command_response_code'].". Fout text: ".$versio['command_response_message']."");
}
else {
    if($versio['total_count']>0)
    {
require_once("includes/submenu.php");
?>
    <div class="col-sm-9 col-md-9" style="width:80%;">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title">Klantenpaneel</h3>
        </div>
        <div class="panel-body">
            <form method="post" action="">
                <table class="table table-striped">
                    <thead>
                      <tr>
                        <th>Domein</th>
                        <th>TLD</th>
                        <th>Verloop datum</th>
                        <th>Automatisch verlengen</th>
                        <th>contact ID</th>
                      </tr>
                    </thead>
                    <table class="table table-striped table-bordered">
                    <tbody>
<?php 
    $teller = 1;
    while($versio['total_count']>=$teller) {
        if ($versio['contactid_'. $teller] != 197246 ) continue;
?>
                      <tr>
                        <td><a href="records.php?domain=<?php echo        $versio['domain_'.$teller]; ?>&tld=<?php echo $versio['tld_'.$teller]; ?>">
                        <?php echo $versio['domain_'.$teller]; ?></a></td>
                        <td>.<?php echo $versio['tld_'.$teller]; ?></td> 
                        <td><?php echo $versio['expiration_date_'.$teller]; ?></td>
                        <td><?php echo $versio['auto_renew_'.$teller]; ?></td>
                        <td><?php echo $versio['contactid_'.$teller]; ?></td>
                      </tr>
<?php                 $teller++;
                    }
?> 
                    </tbody>
                </table>
            </form>
        </div>
    </div>
<?php
    } else {
        echo("Er zijn geen DNS records gevonden voor dit domein.");
    }
}
?>

make sure to replace the ID with the ID from the user on line 41