PHP/DIV programming

Started by
4 comments, last by MaulingMonkey 19 years, 6 months ago
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;">
 <center>
 Address<br />
 <?php
 $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>
 <?php
 }
 ?></center>
  </font>
 </div>

But when I show it it doesn't execute the PHP code. It's jsut blank. Anyone have any ideas? Thanks in advance.
Advertisement
does anyone have any ideas?
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?
Realize that ANYTHING between <? and ?> will be processed BEFORE ANYTHING is sent to the client at all.

&#106avascript used to show and hide a div happens LONG after ALL PHP script is executed.
daerid@gmail.com
Also, you appear to be missing a close brace on your while loop :s
Quote:Original post by Zahlman
Also, you appear to be missing a close brace on your while loop :s


No he's not:

<?php } ?></center>  </font> </div>

This topic is closed to new replies.

Advertisement