【问题标题】:PHP show records from one IDPHP 从一个 ID 显示记录
【发布时间】:2017-01-10 20:56:35
【问题描述】:

目前我对域有一个概述。我使用联系人 ID 为 197246 的帐户登录。但它显示了所有这些。在这里,我想过滤我的概述,即登录的用户看到他自己的域。

因此,当 ID 197246 登录时,显示联系人 ID 为 197246 的域。当 ID 307890 登录时,显示这些域。

到目前为止,这是我的代码。我想这里需要一个过滤器。

<?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.");
	}
}
?>

【问题讨论】:

  • 您能告诉我 versio_api 对该命令的作用吗?应该有一个过滤器,允许您在其中发送 ID。
  • 您使用的 API 可以过滤/查询数据,或者您在显示记录时通过在循环中进行比较来手动过滤。您正在使用哪个选项以及您尝试过什么?
  • 这完全取决于Versio_api() 它接受什么以及返回什么..
  • @Tosfera versio.nl/api-doc DomainsListActive
  • @David 没试过,我停电了所以我不知道有什么解决办法哈哈

标签: php html arrays


【解决方案1】:

Versio 的文档为您提供了调用中的完整选项列表。您可以做的一种选择是检查“contactid_x”是否等于登录用户。

更多信息请访问他们的 wiki right here


举个例子,这样就可以了:

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.");
    }
}
?>

确保将 ID 替换为第 41 行用户提供的 ID

【讨论】:

  • 那是我正在使用的,我想我必须检查'contactid_x'是否等于登录用户,但不知道如何。也许它太容易了,我忘记了如何......
  • 如果您在会话中保存了用户的 ID,您可以简单地将 '197246' 替换为 $_SESSION['
  • 当我使用你的代码时,我不会得到任何结果。我不知道为什么。我试过 197246 但他没有展示我的例子。有什么想法吗?
  • 尝试查看 $versio['contactid_'. $teller],它可能与 API 文档所述不同。此外,您使用的 ID 可能是来自用户帐户的 ID,而不是来自 Versio 的 contactid。
  • 当我尝试 if ($versio['contactid_'.$teller] == 197246 ) continue;他确实过滤了那个并显示了其他的。所以我不知道为什么他在 != .... $versio['contactid_'. $teller] 从 API 中给出 DomainListContacts 的 ID。所以我想为联系人创建一个帐户并根据 ID 显示他们的域。
猜你喜欢
  • 2021-08-25
  • 1970-01-01
  • 2018-08-04
  • 1970-01-01
  • 2019-01-05
  • 1970-01-01
  • 1970-01-01
  • 2011-12-10
  • 1970-01-01
相关资源
最近更新 更多