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