suttercain Posted June 4, 2007 Share Posted June 4, 2007 Hi Guys, I have been working on this for a while but can't get it... It works fine without MySQL and PHP but when I try to integrate that into the script, I'm having a hard time. Here is the script I am running (PHP, MySQL, CSS, and JavaScript) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Switch menu</title> <style type="text/css"> @import url("http://www.supermandatabase.com/sd_style.css"); </style> <?php include ('/home/superman/public_html/get_connected.php'); ?> <style type="text/css"> <!-- body { text-align:center; margin:30px; } #wrapper { text-align:left; margin:0 auto; width:750px; min-height:100px; border:1px solid #ccc; padding:2px; } a { color:blue; cursor:pointer; } --> </style> <script type="text/javascript"> <!-- function switchMenu(obj) { var el = document.getElementById(obj); if ( el.style.display != "none" ) { el.style.display = 'none'; } else { el.style.display = ''; } } //--> </script> </head> <body> <div id="wrapper"> <?php //Convert seriesTitle Column to out put from the MySQL instead of HTML $sql = mysql_query("SELECT * FROM actionFigures ORDER BY seriesTitle, series, title ASC") or die (mysql_error()); $current = ''; $series = ''; while($row = mysql_fetch_array($sql)) { if($current != $row['seriesTitle'] && $series != $row['series']) { $current = $row['seriesTitle']; $series = $row['series']; echo "<table width='730' border='0' cellpadding='3' cellspacing='1'> <tr> <td width='530'><b><a onclick=\"switchMenu('myvar');\" title=\"Switch the Menu\">" . strtoupper($current) . "</a></b></td> <td width='100'><b>SERIES</b></td> <td width='100'><b>YEAR</b></td> </tr></table>"; } //Continuation of CSS for the Alternating Color Rows $class = $class == 'even' ? 'odd' : 'even'; echo "<div id=\"myvar\">"; echo "<table width='730' border='0' cellpadding='3' cellspacing='1'>"; echo "<tr class=\"$class\">\n"; echo "<td width='530'><a href='view_actionfigures.php?id=" . $row['actionFigureId'] . "'>" . $row['title'] . "</a></td>\n"; echo "<td width='100'>$row[series]</td>\n"; echo "<td width='100'>$row[year]</td>\n"; echo "</tr>\n"; echo "</table>"; echo "</div>"; } echo "<br>"; ?> </div> </body> </html> Here is the page the I am running this script on: http://www.supermandatabase.com/collectibles/actionFigures/try.php I am trying to get it to look somewhat like this: http://www.supermandatabase.com/collectibles/actionFigures/ Any help would be great. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/54182-using-ajax-to-expandcollapase-phpmysql-results/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.