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.

document.getElementById('text1').value="<?php echo $data[0]";
document.getElementById('text2').value="<?php echo $data[1]";


thats it..!!

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

If their have any alternative way??

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.

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>";   ?>

also, be careful to escape the quotes in the javascript block if necessary