php作为占位符的输出

sqougxex  于 2021-06-18  发布在  Mysql
关注(0)|答案(2)|浏览(443)

我有一个网站的x数量的标记,存储在mysql数据库。我想显示的数量的标记(作为一个数字)显示在Map上。
使用php,我计算了数据库中的行数,并制作了一个作为dropdowntrigger的html按钮。
现在,我想把这个数字作为按钮上的占位符。

在哪里 EN 在示例pic中,我想显示标记的数量。最好的方法是什么??

<div class="right">
    <span data-dropdown-id="counter" id="counter" class="button actionButton dropdownTrigger">
        <iframe src="Counter.php"></iframe>
    </span>
</div>

代码php

<?php
require("test.php");

if(!$con)
{
    echo 'Not Connected To Server';
}
if(!mysqli_select_db($con,'test'))
{
    echo 'Database Not Selected';
}

$sql="SELECT * FROM markers";

if ($result=mysqli_query($con,$sql))
  {
  // Return the number of rows in result set
  $rowcount=mysqli_num_rows($result);
  printf("<div style='font:25px/25px Arial;color:#73AD21'>$rowcount</div>");
  // Free result set
  mysqli_free_result($result);
  }

mysqli_close($con);
?>

使用echo和iframe更新:更新示例文本是可选择的(光标变为“select”),不可单击(如dropdowntrigger),也不对齐。

qmb5sa22

qmb5sa221#

只需使用php的echo属性就可以了。例如,如果您的值存储在$rowcount中。

<?php echo $rowcount ?>

printf将只输出格式化的字符串

$number = 28;
$str = "India";
printf("There are %u states in %s.",$number,$str);

用echo替换printf

ukqbszuj

ukqbszuj2#

只要替换一下 printf("rowcount")echo $rowcount 我想你可以走了。

相关问题