Page 1 of 1

using script variable in php

Posted: Sat Apr 16, 2011 10:40 am
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 />";   }
  }  
?>  

Re: using script variable in php

Posted: Sat Apr 16, 2011 11:04 am
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?

Re: using script variable in php

Posted: Sat Apr 16, 2011 11:24 am
by McInfo
PHP is executed on the server; JavaScript is executed in the browser; and it happens in that order.

Re: using script variable in php

Posted: Sat Apr 16, 2011 11:29 am
by ckdoublenecks
thanks, that is so sweet. something to add to my file.

Re: using script variable in php

Posted: Sat Apr 16, 2011 11:52 am
by fugix
no problem..hope that helped