PHP generated output on the same html page












0














I have got a WordPress site running and I want to offer a calorie calculator.



The html part is ready and the php script does what it should, BUT I want the php to create a output on the same html site under the input forms.



A other site solved that great:
https://www.dropbox.com/s/dsem8vj23qmqodr/Ask%20Stack.jpg?dl=0



I don't want to show my php file here, because of the calculation algorithm.



Someone told me it is possible WITHOUT sql to handle that problem. As I get that right it is about giving the inputvalues back to the html and create a outputfield... But unfortunately the guy is not contactable atm.



If you need the code, I will post it, but I think it is possible to help without.



Some more Infos:




  • php and html are two files

  • I want to put 8 values out, in a table like on the picture.

  • (if I have to) I have no clue how to contact the sql server via wordpress.










share|improve this question




















  • 1




    Hello @Joeykenoy - It would really help others help you if you posted some of the code that you've tried and what results you got. Hide anything that is sensitive. From the sounds of it, the calculation you reference has nothing to do with the core problem. Cheers.
    – KJH
    Nov 23 at 1:37










  • KJH is absolutely right you should abstract your code. It would be even enough if you abstract your algorithm to $a + $b = $output but we have to see how it all plays together. How you fetch, calculate and deploy the data. Regards
    – Axel
    Nov 23 at 3:19












  • Thx for your answers. Code in a new answer.
    – Joeykenoy
    Nov 23 at 16:32
















0














I have got a WordPress site running and I want to offer a calorie calculator.



The html part is ready and the php script does what it should, BUT I want the php to create a output on the same html site under the input forms.



A other site solved that great:
https://www.dropbox.com/s/dsem8vj23qmqodr/Ask%20Stack.jpg?dl=0



I don't want to show my php file here, because of the calculation algorithm.



Someone told me it is possible WITHOUT sql to handle that problem. As I get that right it is about giving the inputvalues back to the html and create a outputfield... But unfortunately the guy is not contactable atm.



If you need the code, I will post it, but I think it is possible to help without.



Some more Infos:




  • php and html are two files

  • I want to put 8 values out, in a table like on the picture.

  • (if I have to) I have no clue how to contact the sql server via wordpress.










share|improve this question




















  • 1




    Hello @Joeykenoy - It would really help others help you if you posted some of the code that you've tried and what results you got. Hide anything that is sensitive. From the sounds of it, the calculation you reference has nothing to do with the core problem. Cheers.
    – KJH
    Nov 23 at 1:37










  • KJH is absolutely right you should abstract your code. It would be even enough if you abstract your algorithm to $a + $b = $output but we have to see how it all plays together. How you fetch, calculate and deploy the data. Regards
    – Axel
    Nov 23 at 3:19












  • Thx for your answers. Code in a new answer.
    – Joeykenoy
    Nov 23 at 16:32














0












0








0







I have got a WordPress site running and I want to offer a calorie calculator.



The html part is ready and the php script does what it should, BUT I want the php to create a output on the same html site under the input forms.



A other site solved that great:
https://www.dropbox.com/s/dsem8vj23qmqodr/Ask%20Stack.jpg?dl=0



I don't want to show my php file here, because of the calculation algorithm.



Someone told me it is possible WITHOUT sql to handle that problem. As I get that right it is about giving the inputvalues back to the html and create a outputfield... But unfortunately the guy is not contactable atm.



If you need the code, I will post it, but I think it is possible to help without.



Some more Infos:




  • php and html are two files

  • I want to put 8 values out, in a table like on the picture.

  • (if I have to) I have no clue how to contact the sql server via wordpress.










share|improve this question















I have got a WordPress site running and I want to offer a calorie calculator.



The html part is ready and the php script does what it should, BUT I want the php to create a output on the same html site under the input forms.



A other site solved that great:
https://www.dropbox.com/s/dsem8vj23qmqodr/Ask%20Stack.jpg?dl=0



I don't want to show my php file here, because of the calculation algorithm.



Someone told me it is possible WITHOUT sql to handle that problem. As I get that right it is about giving the inputvalues back to the html and create a outputfield... But unfortunately the guy is not contactable atm.



If you need the code, I will post it, but I think it is possible to help without.



Some more Infos:




  • php and html are two files

  • I want to put 8 values out, in a table like on the picture.

  • (if I have to) I have no clue how to contact the sql server via wordpress.







php html wordpress output






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 at 4:29









Nic3500

3,32481829




3,32481829










asked Nov 22 at 18:31









Joeykenoy

32




32








  • 1




    Hello @Joeykenoy - It would really help others help you if you posted some of the code that you've tried and what results you got. Hide anything that is sensitive. From the sounds of it, the calculation you reference has nothing to do with the core problem. Cheers.
    – KJH
    Nov 23 at 1:37










  • KJH is absolutely right you should abstract your code. It would be even enough if you abstract your algorithm to $a + $b = $output but we have to see how it all plays together. How you fetch, calculate and deploy the data. Regards
    – Axel
    Nov 23 at 3:19












  • Thx for your answers. Code in a new answer.
    – Joeykenoy
    Nov 23 at 16:32














  • 1




    Hello @Joeykenoy - It would really help others help you if you posted some of the code that you've tried and what results you got. Hide anything that is sensitive. From the sounds of it, the calculation you reference has nothing to do with the core problem. Cheers.
    – KJH
    Nov 23 at 1:37










  • KJH is absolutely right you should abstract your code. It would be even enough if you abstract your algorithm to $a + $b = $output but we have to see how it all plays together. How you fetch, calculate and deploy the data. Regards
    – Axel
    Nov 23 at 3:19












  • Thx for your answers. Code in a new answer.
    – Joeykenoy
    Nov 23 at 16:32








1




1




Hello @Joeykenoy - It would really help others help you if you posted some of the code that you've tried and what results you got. Hide anything that is sensitive. From the sounds of it, the calculation you reference has nothing to do with the core problem. Cheers.
– KJH
Nov 23 at 1:37




Hello @Joeykenoy - It would really help others help you if you posted some of the code that you've tried and what results you got. Hide anything that is sensitive. From the sounds of it, the calculation you reference has nothing to do with the core problem. Cheers.
– KJH
Nov 23 at 1:37












KJH is absolutely right you should abstract your code. It would be even enough if you abstract your algorithm to $a + $b = $output but we have to see how it all plays together. How you fetch, calculate and deploy the data. Regards
– Axel
Nov 23 at 3:19






KJH is absolutely right you should abstract your code. It would be even enough if you abstract your algorithm to $a + $b = $output but we have to see how it all plays together. How you fetch, calculate and deploy the data. Regards
– Axel
Nov 23 at 3:19














Thx for your answers. Code in a new answer.
– Joeykenoy
Nov 23 at 16:32




Thx for your answers. Code in a new answer.
– Joeykenoy
Nov 23 at 16:32












2 Answers
2






active

oldest

votes


















0














Yes, you don't need sql for that, providing you have all the required calorie data hardcoded in your PHP script.



What you need to do is send a form, and if there was a $_POST data you just display the result produced by your script, below the form.



More neat solution would be to collect the form data with JS and make an AJAX call to your PHP calculation script, then display the result below the form with JS.



Hope that helps :)






share|improve this answer





















  • Thx for your answer, but I dont get it together with my code. I added some more informations.
    – Joeykenoy
    Nov 22 at 19:41





















0














Thx for your answer, but I don't get it together with my code. I am a rookie. -.-



This are the values I get from the html forms:



$kfa = $_POST['kfa'];
$groesse = $_POST['groesse'];
$gewicht = $_POST['gewicht'];
$beruf = $_POST['beruf'];
$ziel = $_POST['ziel'];
$ewb = $_POST['ewbedarf'];


(body fat percentage, height, weight, job, goal and protein need)



The php script calculates on that base the output values:



$wochenverbrauch
$tagesverbrauch
$freizeitumsatz
$arbeitsumsatz
$protein
$kohlenhydrate
$fette


(calories needed: week, day, in free time, at work and protein, carbs and fat intake)



The first values (user input in the forms) should be "active" in the form after the calculation AND the table of the second values should be displayed under the forms.



Here is the html file, hope it says more than my text (I cut out a lot of input values for here):
[https://pastebin.com/J7imKpqz][1]



I tried to paste it here, after half an hour I gave up. I don't know why the editor says there is code not proper formatted.






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',
    autoActivateHeartbeat: false,
    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%2f53436499%2fphp-generated-output-on-the-same-html-page%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









    0














    Yes, you don't need sql for that, providing you have all the required calorie data hardcoded in your PHP script.



    What you need to do is send a form, and if there was a $_POST data you just display the result produced by your script, below the form.



    More neat solution would be to collect the form data with JS and make an AJAX call to your PHP calculation script, then display the result below the form with JS.



    Hope that helps :)






    share|improve this answer





















    • Thx for your answer, but I dont get it together with my code. I added some more informations.
      – Joeykenoy
      Nov 22 at 19:41


















    0














    Yes, you don't need sql for that, providing you have all the required calorie data hardcoded in your PHP script.



    What you need to do is send a form, and if there was a $_POST data you just display the result produced by your script, below the form.



    More neat solution would be to collect the form data with JS and make an AJAX call to your PHP calculation script, then display the result below the form with JS.



    Hope that helps :)






    share|improve this answer





















    • Thx for your answer, but I dont get it together with my code. I added some more informations.
      – Joeykenoy
      Nov 22 at 19:41
















    0












    0








    0






    Yes, you don't need sql for that, providing you have all the required calorie data hardcoded in your PHP script.



    What you need to do is send a form, and if there was a $_POST data you just display the result produced by your script, below the form.



    More neat solution would be to collect the form data with JS and make an AJAX call to your PHP calculation script, then display the result below the form with JS.



    Hope that helps :)






    share|improve this answer












    Yes, you don't need sql for that, providing you have all the required calorie data hardcoded in your PHP script.



    What you need to do is send a form, and if there was a $_POST data you just display the result produced by your script, below the form.



    More neat solution would be to collect the form data with JS and make an AJAX call to your PHP calculation script, then display the result below the form with JS.



    Hope that helps :)







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 22 at 18:36









    Sachem

    146110




    146110












    • Thx for your answer, but I dont get it together with my code. I added some more informations.
      – Joeykenoy
      Nov 22 at 19:41




















    • Thx for your answer, but I dont get it together with my code. I added some more informations.
      – Joeykenoy
      Nov 22 at 19:41


















    Thx for your answer, but I dont get it together with my code. I added some more informations.
    – Joeykenoy
    Nov 22 at 19:41






    Thx for your answer, but I dont get it together with my code. I added some more informations.
    – Joeykenoy
    Nov 22 at 19:41















    0














    Thx for your answer, but I don't get it together with my code. I am a rookie. -.-



    This are the values I get from the html forms:



    $kfa = $_POST['kfa'];
    $groesse = $_POST['groesse'];
    $gewicht = $_POST['gewicht'];
    $beruf = $_POST['beruf'];
    $ziel = $_POST['ziel'];
    $ewb = $_POST['ewbedarf'];


    (body fat percentage, height, weight, job, goal and protein need)



    The php script calculates on that base the output values:



    $wochenverbrauch
    $tagesverbrauch
    $freizeitumsatz
    $arbeitsumsatz
    $protein
    $kohlenhydrate
    $fette


    (calories needed: week, day, in free time, at work and protein, carbs and fat intake)



    The first values (user input in the forms) should be "active" in the form after the calculation AND the table of the second values should be displayed under the forms.



    Here is the html file, hope it says more than my text (I cut out a lot of input values for here):
    [https://pastebin.com/J7imKpqz][1]



    I tried to paste it here, after half an hour I gave up. I don't know why the editor says there is code not proper formatted.






    share|improve this answer


























      0














      Thx for your answer, but I don't get it together with my code. I am a rookie. -.-



      This are the values I get from the html forms:



      $kfa = $_POST['kfa'];
      $groesse = $_POST['groesse'];
      $gewicht = $_POST['gewicht'];
      $beruf = $_POST['beruf'];
      $ziel = $_POST['ziel'];
      $ewb = $_POST['ewbedarf'];


      (body fat percentage, height, weight, job, goal and protein need)



      The php script calculates on that base the output values:



      $wochenverbrauch
      $tagesverbrauch
      $freizeitumsatz
      $arbeitsumsatz
      $protein
      $kohlenhydrate
      $fette


      (calories needed: week, day, in free time, at work and protein, carbs and fat intake)



      The first values (user input in the forms) should be "active" in the form after the calculation AND the table of the second values should be displayed under the forms.



      Here is the html file, hope it says more than my text (I cut out a lot of input values for here):
      [https://pastebin.com/J7imKpqz][1]



      I tried to paste it here, after half an hour I gave up. I don't know why the editor says there is code not proper formatted.






      share|improve this answer
























        0












        0








        0






        Thx for your answer, but I don't get it together with my code. I am a rookie. -.-



        This are the values I get from the html forms:



        $kfa = $_POST['kfa'];
        $groesse = $_POST['groesse'];
        $gewicht = $_POST['gewicht'];
        $beruf = $_POST['beruf'];
        $ziel = $_POST['ziel'];
        $ewb = $_POST['ewbedarf'];


        (body fat percentage, height, weight, job, goal and protein need)



        The php script calculates on that base the output values:



        $wochenverbrauch
        $tagesverbrauch
        $freizeitumsatz
        $arbeitsumsatz
        $protein
        $kohlenhydrate
        $fette


        (calories needed: week, day, in free time, at work and protein, carbs and fat intake)



        The first values (user input in the forms) should be "active" in the form after the calculation AND the table of the second values should be displayed under the forms.



        Here is the html file, hope it says more than my text (I cut out a lot of input values for here):
        [https://pastebin.com/J7imKpqz][1]



        I tried to paste it here, after half an hour I gave up. I don't know why the editor says there is code not proper formatted.






        share|improve this answer












        Thx for your answer, but I don't get it together with my code. I am a rookie. -.-



        This are the values I get from the html forms:



        $kfa = $_POST['kfa'];
        $groesse = $_POST['groesse'];
        $gewicht = $_POST['gewicht'];
        $beruf = $_POST['beruf'];
        $ziel = $_POST['ziel'];
        $ewb = $_POST['ewbedarf'];


        (body fat percentage, height, weight, job, goal and protein need)



        The php script calculates on that base the output values:



        $wochenverbrauch
        $tagesverbrauch
        $freizeitumsatz
        $arbeitsumsatz
        $protein
        $kohlenhydrate
        $fette


        (calories needed: week, day, in free time, at work and protein, carbs and fat intake)



        The first values (user input in the forms) should be "active" in the form after the calculation AND the table of the second values should be displayed under the forms.



        Here is the html file, hope it says more than my text (I cut out a lot of input values for here):
        [https://pastebin.com/J7imKpqz][1]



        I tried to paste it here, after half an hour I gave up. I don't know why the editor says there is code not proper formatted.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 at 19:40









        Joeykenoy

        32




        32






























            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%2f53436499%2fphp-generated-output-on-the-same-html-page%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

            What visual should I use to simply compare current year value vs last year in Power BI desktop

            How to ignore python UserWarning in pytest?

            Alexandru Averescu