Jump to content

Looping the same data on the same page


SF23103

Recommended Posts

I'm trying to loop "Question" as a list of links (link is #id_number), and then later on the page loop "Question" and "Answer", anchored by the id_number tag.

 

It's looping "Question" just fine, but how do I then loop the same data again later in the same page?

 

<?php
$username="username";
$password="password";
$database="database_name";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM ft_form_17 WHERE Include='Include'";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>

Header Goes here<br /><br /><br />

<?php
$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"question"); //Question
$f2=mysql_result($result,$i,"answer"); //Answer
$f3=mysql_result($result,$i,"submission_id"); //id number
?>

<a href="#<?php echo $f3; ?>"><?php echo $f1; ?></a><br />

<?php
$i++;
}
?>
<br /><br /><br />

<strong><a name="<?php echo $f3; ?>"><?php echo $f1; ?></a></strong>
<?php echo $f2; ?>

Link to comment
https://forums.phpfreaks.com/topic/248858-looping-the-same-data-on-the-same-page/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.