Simple PHP Variable Issue.
Posted: Sat Nov 15, 2008 11:36 pm
I've got a database that contains some phrases. I grab these phrases from the database and then display them one by one. But initially I don't want any of the text to show. Then as each line shows you have to click a link to display the next line. Pulling from the database works fine, but I'm using prototype/scriptaculous to make these hidden divs visible. It works fine on the first time, but when I dynamically generate the link code - it doesn't work. The script in its entirety is below. Any thoughts?
Code: Select all
<html>
<head>
<script src="/lordsprayer/javascripts/prototype.js" type="text/javascript"></script>
<script src="/lordsprayer/javascripts/scriptaculous.js" type="text/javascript"></script>
</head>
<body>
<?php
include_once "ez_sql_core.php";
include_once "ez_sql_mysql.php";
$db = new ezSQL_mysql('***','***','***','localhost');
$phrases=$db->get_results("SELECT phrase FROM phrases");
?>
<a href="#" onClick="Effect.toggle('1','appear');">Show.</a>
<?php
$i=0;
$j=0;
foreach ( $phrases as $phrase )
{
$i=$i+1;
$j=$i+1;
echo "<div id='".$i."' style='display:none'>";
echo $i; ' Just checking the value of $i.
echo $phrase->phrase;
echo "<br />";
echo "<a href='#' onClick='Effect.toggle('". $j ."','appear');'>Show.</a>";
echo $j; ' Just checking the value of $j.
echo "</div>";
}
?>
<?php
$db->debug();
?>
</body>
</html>