Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3964394
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:19:44+00:00 2026-05-20T03:19:44+00:00

I have the following jquery code: while (count < 31) { window[‘cday_’ + count]

  • 0

I have the following jquery code:

  while (count < 31) {
  window['cday_' + count] = <?php echo $day_1 ?>; 
  window['tday_' + count] = (window['cday_' + count] * formfig) / formfig2; 
  count++;
  }

But I need $day_1 in the php echo statement to reflect the variable “count”, so in theory it should be something like “echo $day_count”. Is it possible to pass the var to php?


php & jquery coding:

$i=0;
while ($i < $num) {
${"day_$i"}=mysql_result($result,$i,"datavalue");
$i++;
}

?>

<script type="text/javascript">
var chart1; 
var count=1;
var formfig=17;
var formfig2=2;

function chartdraw(){

      while (count < 31) {
      window['cday_' + count] = <?php echo $day_1 ?>; 
      window['tday_' + count] = (window['cday_' + count] * formfig) / formfig2; 
      count++;
      }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:19:45+00:00Added an answer on May 20, 2026 at 3:19 am

    The short answer here is no.

    To understand what’s possible, you need a deep understanding of what’s going on. Your PHP code is building an HTML document (with embedded JavaScript) and sending it on to the web browser. Once the web browser (which is, of course, running on the user’s machine, not your server) renders that page, it will execute the javascript. This is when the javascript variables begin to actually mean something. Until then, they are just text getting sent across the network. This point is long after the PHP code has finished running. Your server has already closed down that php instance as it sent the code to the user.

    Keeping that in mind, you can send the value of a javascript variable (or any number of other things) back to your server with something called an ajax request. Essentially, this will send some information (the variable’s value, and the name of the page you want) back to your server, which will in turn cause your server to build a new web page, which can have PHP code in it. That web page’s content will get returned to another bit of javascript you can provide — called a ‘callback’ — which can take the page created by the second php script and make use of it. This is, of course, fairly resource intensive.

    Unless you plan to do something that ONLY PHP can do, I would recommend finding a way to do as much of your logic as possible in javascript. This alleviates all these complex problems and keeps all the hard work on the user’s machine.

    If you can structure your code so your php code provides all the data the javascript code needs before the php finishes running, you can get away without doing anything fancy with ajax. Here’s an example:

    <script type="text/javascript">
      var days = {};
      <? for($day = 0; $day < 30; $day++) { ?>
        days.<? echo $day ?> = "<? echo get_day_info($day) ?>";
      <? } ?>
    </script>
    

    What this will do is create a javascript object called days. Then it will fill in days.i for i from 0 to 30. It assumes you have a function called get_day_info($day) which takes a day and returns the info for that day. I’m assuming here that you’re dealing with strings — if not, you will need to remove the quotes, and possibly do other things to wrap the data depending on what format it takes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following jquery code. basically i will have several overlapped divs and
I have the following JQuery code that worked perfect in C#/Asp.net 2.0 to call
I have the following JQuery code which does similar functionality like Stackoverflow where the
I'm making a rating system, and I have the following jQuery code on my
I have the following (javascript/jquery) code to show a busy indicator (after a delay)
Very simple question: suppose I have the following js/jquery code doSomething(); $.get(url, callback); doSomethingElse();
i have this example code: while ($row = mysql_fetch_object($result1)) { echo '<input type=radio name=vote
I have the following code that simply uses a jquery ui modal dialog to
I have the following PHP code to display the file structure of my site.
Let's say I have the following jQuery AJAX call: $.ajax({ type: POST, url: MyUrl,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.