Sign in to follow this  

PHP/DIV programming

Recommended Posts

Hey, I'm trying to get it so when I click Show Address Book, teh div shows (this part I've done successfully), then make it so when the div shows it grabs data form a database called addressbook. The code looks like this:
<div id="Layer1" style="position:absolute; left:34px; top:108px; width:143px; height:124px; z-index:1; visibility:hidden;">
 <font style="font-family:'Courier New', Courier, mono; font-size:11px;">
 Address<br />
 $sql_3 = "SELECT * FROM addressbook WHERE myuser = '$myuser'";
 $result_3 = mysql_query($sql_3, $dbh);
 while($row_3 = mysql_fetch_array($result_3))
 	$account = $row_3[ 'useracc' ];
 <a href="javascript:document.to_user.value='<?php echo "$useracc"; ?>';" style="font-family:'Courier New', Courier, mono; font-size:11px;"><?php echo "$useracc"; ?></a>

But when I show it it doesn't execute the PHP code. It's jsut blank. Anyone have any ideas? Thanks in advance.

Share this post

Link to post
Share on other sites
You assign $account from $row_3[ 'useracc' ] but then use the variable $useracc which I don't see assigned anywhere in your code, so that should output a bunch of:

<a href="javascript:document.to_user.value='';" style="font-family:'Courier New', Courier, mono; font-size:11px;"></a>

You did view the source of your output, right?

Share this post

Link to post
Share on other sites
Realize that ANYTHING between <? and ?> will be processed BEFORE ANYTHING is sent to the client at all.

javascript used to show and hide a div happens LONG after ALL PHP script is executed.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this