Jump to content

using javascript in php


demonforce

Recommended Posts

hi :)

 

i have a small, but irritating problem.

 

i have a database with all kind of news in it, and i want it to show the newwest 3 id's in a collapse menu.

 

i allready have the collapse script, and the php part, but cause some reason it wont work.

 

code:

 

COLLAPSE

<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>

 

STYLE

<style type="text/css">
<!--
body {
text-align:center;
margin:30px;
}
#wrapper {
text-align:left;
margin:0 auto;
width:150px;
min-height:10px;
border:1px solid #ccc;
padding:10px;
}
a {
color:blue;
cursor:pointer;
}
#id1 {
border:1px solid #ccc;
background:#f2f2f2;
padding:20px;
}
-->
</style>

 

 

PHP

     <?php

require("mysql.connect.php");

$query = @mysql_query("SELECT * FROM nieuws") or die(mysql_error());

	while($values = mysql_fetch_array($query))
	{ 

		$id = $values['id'];
		$naam = $values['naam'];
		$bericht = $values['bericht'];

echo "<div id='wrapper'>";
echo "<a onclick='switchMenu('id1');' title='naam'>naam</a>";
echo "<div id='id1'>bericht</div>";
echo "</div>";

	}
	?>

 

 

what do i do wrong?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.