PHP and Javascript
Posted: Tue Feb 24, 2004 12:20 pm
I'm am using a javascript menu and want to incorporate php/mysql to determine the menu height. The code in the header section for the dimensions are:
<script language="javascript">
new ypSlideOutMenu("menu3", "right", 80, 140, 150, 180)
</script>
The second set of numbers are the numbers of concern (i.e. 150, 180). In particular is the 180. This is the height of the menu that contains the names of people in the mysql database. So, if a person is added/removed from the database, I need the height to adjust accordingly.
The body of the html document contains the following code which accesses the mysql database for a list of faculty members:
<div id="menu3Container">
<div id="menu3Content" class="menu" align="center">
<table border="0">
<?php
$fac_array = @mysql_query('SELECT faculty.ID, FLNAME FROM faculty ORDER BY LNAME');
if (!$fac_array) {
die('<h2>Error retrieving faculty from database!</h2><br>' .
'Error: ' . mysql_error());
}
while ($faculty = mysql_fetch_array($fac_array)) {
$fid = $faculty['ID'];
$flname = $faculty['FLNAME'];
echo ('<tr valign=center>
<td><a href="http://webserver.nsm.tridenttech.edu?pg ... .'</a></tr>');
}
?>
</table>
</div>
Now, I have the php code which will count the number of rows in the database which I can then multiply that number times the number of pixels per entry, but I thought that php could only be used in the body of an html document and this would require me to use the variable with the row count in the js in the header. I'm confused. Can someone shed some light on the matter for me? Or, if you know of a good js menu or dhtml menu script that easily works with php please let me know. I need a vertical menu possibly with multiple submenus.
Many thanks,
Chris
<script language="javascript">
new ypSlideOutMenu("menu3", "right", 80, 140, 150, 180)
</script>
The second set of numbers are the numbers of concern (i.e. 150, 180). In particular is the 180. This is the height of the menu that contains the names of people in the mysql database. So, if a person is added/removed from the database, I need the height to adjust accordingly.
The body of the html document contains the following code which accesses the mysql database for a list of faculty members:
<div id="menu3Container">
<div id="menu3Content" class="menu" align="center">
<table border="0">
<?php
$fac_array = @mysql_query('SELECT faculty.ID, FLNAME FROM faculty ORDER BY LNAME');
if (!$fac_array) {
die('<h2>Error retrieving faculty from database!</h2><br>' .
'Error: ' . mysql_error());
}
while ($faculty = mysql_fetch_array($fac_array)) {
$fid = $faculty['ID'];
$flname = $faculty['FLNAME'];
echo ('<tr valign=center>
<td><a href="http://webserver.nsm.tridenttech.edu?pg ... .'</a></tr>');
}
?>
</table>
</div>
Now, I have the php code which will count the number of rows in the database which I can then multiply that number times the number of pixels per entry, but I thought that php could only be used in the body of an html document and this would require me to use the variable with the row count in the js in the header. I'm confused. Can someone shed some light on the matter for me? Or, if you know of a good js menu or dhtml menu script that easily works with php please let me know. I need a vertical menu possibly with multiple submenus.
Many thanks,
Chris