Output of PHP as placeholder

116
November 12, 2018, at 3:10 PM

I have a website with an x amount of markers that are stored in mysql database. I want to show the amount of markers (as a figure) showing on the map.

With php I counted the amount of rows in the database, and made an html button that functions as a dropdowntrigger.

Now, I want to have that number as the placeholder on the button.

Where the EN is in the example pic, I want to show the amount of markers. what is the best way to do this??

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

Code 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);
?>

UPDATE using echo and iframe: update example The text is selectable (cursor changes to 'select') and not clickable (like the dropdowntrigger) and not alined.

Answer 1

just replace printf("rowcount") by echo $rowcount and I think you shall be good to go.

Answer 2

Just use the echo attribut of php and is done. for example if your value is stored in lets say $rowcount.

<?php echo $rowcount ?>

Printf will output only a formatted string.For example

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

Replace the printf with Echo

Rent Charter Buses Company
READ ALSO
Creating erlang record from two separate lists

Creating erlang record from two separate lists

In one of our erlang project we are loading data from mysql database using mysql-otp as below -

126
Updating a column of type double using select and update

Updating a column of type double using select and update

I have a column in table account that i have defined as doubleI want to update the field which i am calling account_balance

134
Java Mysql connection without Class.forName

Java Mysql connection without Class.forName

I've been trying to connect to a mysql database from java without loading the driver previously with ClassforName (

133
docker-compose mysql init sql is not executed

docker-compose mysql init sql is not executed

I am trying to set up a mysql docker container and execute init sql scriptUnfortunately the sql script is not executed

1042