php作为占位符的输出

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

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

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

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

代码php

  1. <?php
  2. require("test.php");
  3. if(!$con)
  4. {
  5. echo 'Not Connected To Server';
  6. }
  7. if(!mysqli_select_db($con,'test'))
  8. {
  9. echo 'Database Not Selected';
  10. }
  11. $sql="SELECT * FROM markers";
  12. if ($result=mysqli_query($con,$sql))
  13. {
  14. // Return the number of rows in result set
  15. $rowcount=mysqli_num_rows($result);
  16. printf("<div style='font:25px/25px Arial;color:#73AD21'>$rowcount</div>");
  17. // Free result set
  18. mysqli_free_result($result);
  19. }
  20. mysqli_close($con);
  21. ?>

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

tuwxkamq

tuwxkamq1#

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

  1. <?php echo $rowcount ?>

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

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

用echo替换printf

ncecgwcz

ncecgwcz2#

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

相关问题