Output of PHP as placeholder











up vote
-1
down vote

favorite












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.










share|improve this question
























  • printf("rowcount"); - You forgot the $ sign here.
    – Funk Forty Niner
    Nov 11 at 14:13










  • Sorry, i deleted the div style to make the php script more clear. I edited it back to my initial code :)
    – Job de Ruiter
    Nov 11 at 14:19















up vote
-1
down vote

favorite












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.










share|improve this question
























  • printf("rowcount"); - You forgot the $ sign here.
    – Funk Forty Niner
    Nov 11 at 14:13










  • Sorry, i deleted the div style to make the php script more clear. I edited it back to my initial code :)
    – Job de Ruiter
    Nov 11 at 14:19













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











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.










share|improve this question















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.







php html mysql iframe






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 14:40

























asked Nov 11 at 14:03









Job de Ruiter

13




13












  • printf("rowcount"); - You forgot the $ sign here.
    – Funk Forty Niner
    Nov 11 at 14:13










  • Sorry, i deleted the div style to make the php script more clear. I edited it back to my initial code :)
    – Job de Ruiter
    Nov 11 at 14:19


















  • printf("rowcount"); - You forgot the $ sign here.
    – Funk Forty Niner
    Nov 11 at 14:13










  • Sorry, i deleted the div style to make the php script more clear. I edited it back to my initial code :)
    – Job de Ruiter
    Nov 11 at 14:19
















printf("rowcount"); - You forgot the $ sign here.
– Funk Forty Niner
Nov 11 at 14:13




printf("rowcount"); - You forgot the $ sign here.
– Funk Forty Niner
Nov 11 at 14:13












Sorry, i deleted the div style to make the php script more clear. I edited it back to my initial code :)
– Job de Ruiter
Nov 11 at 14:19




Sorry, i deleted the div style to make the php script more clear. I edited it back to my initial code :)
– Job de Ruiter
Nov 11 at 14:19












2 Answers
2






active

oldest

votes

















up vote
0
down vote













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






share|improve this answer




























    up vote
    -1
    down vote













    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






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249513%2foutput-of-php-as-placeholder%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













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






      share|improve this answer

























        up vote
        0
        down vote













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






        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









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






          share|improve this answer












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







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 14:09









          Ditrix 36

          162




          162
























              up vote
              -1
              down vote













              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






              share|improve this answer



























                up vote
                -1
                down vote













                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






                share|improve this answer

























                  up vote
                  -1
                  down vote










                  up vote
                  -1
                  down vote









                  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






                  share|improve this answer














                  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







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 11 at 14:20

























                  answered Nov 11 at 14:11









                  Sreeraj Nair

                  13




                  13






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249513%2foutput-of-php-as-placeholder%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Bressuire

                      Vorschmack

                      Quarantine