0

hi everyone,
I have some problem about simplifying my php code.
At first I want to load my form and then load my information from database if their are any data exists according to the user name.

Actually the problem is,I want to load the js while the information is their.

<?php
$data=mysql_fetch_array[$result];
if($data[0]!=0){
echo"?>
<script>
document.getElementById('text1').value="<?php echo $data[0]";
document.getElementById('text2').value="<?php echo $data[1]";
</script>
<?php
}

?>

thats it..!!

But I want to write it in my js.That will load if data exists.

If their have any alternative way??

4
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by scru
0

Well aside from the fact that it is syntactically incorrect. You aren't terminating the php blocks when you echo. Remember to end them with ?>. Aside from that, when you get the results find the number of results with mysql_num_rows then do a loop.

0

if im getting this right you are trying to insert some value from php into the js
if so you could do it like this

<?php  echo "<script>some-js-code-with-$varableName</script>";   ?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.