using script variable in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ckdoublenecks
Forum Newbie
Posts: 21
Joined: Mon Jan 24, 2011 6:47 pm

using script variable in php

Post by ckdoublenecks »

I have the date (showdate) set up in the script but not sure how to use it in the php code?

Code: Select all

<?php?>
<HTML><HEAD>
<script type="text/javascript">
var dateNow = new Date();
  var dayNow = dateNow.getDate();
  var showdate = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear();
showdate.value = showdate;
</script>
</HEAD><body></body></html>
 <?php 
include("getinvno.php");
 
mysql_connect(localhost,root,""); 
mysql_select_db(oodb) or die( "Unable to select database"); 
$query="SELECT payrec, ordernum, invnum, bname, bstreet, bcity, bstate, bzip, contact, sname, sstreet, scity, sstate, szip, terms, fob, shipdate, shipamt, dateord, datecomp, datepaid, qty, descr, charges, paidamt, tax, amtdue, paidsum FROM oocust WHERE payrec = 'R' AND pd = ' '";
$result=mysql_query($query);  
if(mysql_num_rows($result))  
   {
while(list($payrec, $ordernum, $invnum, $bname, $bstreet, $bcity, $bstate, $bzip, $contact, $sname, $sstreet, $scity, $sstate, $szip, $terms, $fob, $shipdate, $shipamt, $dateord, $datecomp, $datepaid, $qty, $descr, $charges, $paidamt, $tax, $amtdue, $paidsum)= mysql_fetch_row($result))
   { 
echo "<b><center><font size=+2><br /><br /><br /><br /><br />Invoice</center></b></font><br /><br />";

// echo "Date: $row['showdate']<br />";
 
echo "<b>Invoice No: $invnum</b></b><br />";   }
  }  
?>  
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: using script variable in php

Post by fugix »

instead of using javascript to get a certain date...why dont you use PHP and the date() function with the format that you want?
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: using script variable in php

Post by McInfo »

PHP is executed on the server; JavaScript is executed in the browser; and it happens in that order.
ckdoublenecks
Forum Newbie
Posts: 21
Joined: Mon Jan 24, 2011 6:47 pm

Re: using script variable in php

Post by ckdoublenecks »

thanks, that is so sweet. something to add to my file.
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: using script variable in php

Post by fugix »

no problem..hope that helped
Post Reply