[nycphp-talk] A question about run php variable in javascript
chad qian
nynj.tech at hotmail.com
Thu May 1 11:59:28 EDT 2008
I need to run php to get street from mysql database.Then test the street variable in javascriptif street is emty,javascript will pop up alert window
Here are my thoughts:
<?php
//connection to server,database
$q = "select street from apt where username = '$user'";$result = mysql_query($q) or die(mysql_error());while($row = mysql_fetch_array($result)){ $street=$row['street']; }?>
<script LANGUAGE="JavaScript">st=<?=$street?>;if(st) alert("miss street");
</script>
Can I run st=<?=street?> in javascript?I'm not sure here.
Thanks!
chad
_________________________________________________________________
In a rush? Get real-time answers with Windows Live Messenger.
http://www.windowslive.com/messenger/overview.html?ocid=TXT_TAGLM_WL_Refresh_realtime_042008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080501/676ba43e/attachment.html>
More information about the talk
mailing list