Jump to content

Recommended Posts

Hello

 

I am trying to add a link to the output of a definition list...

 

This is my code:

 


while ($row = mysql_fetch_assoc($result)){
 // detect if the heading changed
 if($last_heading != $row['tournament_name']){
  // heading changed or is the first one

  if($last_heading != null){// not the first one, (optionally) close out the previous section here...

  echo "</dl>\n";
  }

  echo "<dl class='v_show_hide' >\n<dt>Tournament {$row['tournament_name']}</dt>\n"; /// I WANT TO ADD LINK HERE 
  $last_heading = $row['tournament_name'];
  }
  echo "<dd>Member {$row['team_id']}</dd>\n";
  }

  if($last_heading != null){

echo "</dl>\n";

}


 

 

I want to add a link like this to where I wrote "I WANT TO ADD LINK HERE"

 

<a href=page.php?con=<?php echo $row['tournament_id']; ?>'></a>

 

 

Any help would be appreciated

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/271035-adding-link-to-definition-list/
Share on other sites

Do you want to turn the Tournament {$row['tournament_name']} text into a link or add a separate link after it?

 

Edit: LOL, the IPB forum post notification is pointless.

 

So, you want to turn the tournament name into a link -

 

echo "<dl class='v_show_hide' >\n<dt>Tournament <a href='page.php?con={$row['tournament_id']}'>{$row['tournament_name']}</a></dt>\n";

Edited by PFMaBiSmAd

Actually, I changed the code a little so the link is not on the tournament name, but instead is another dd at the bottom of the list of dd for each dt

 

So,

 

I tried this...

 


while ($row = mysql_fetch_assoc($result)){
 // detect if the heading changed
 if($last_heading != $row['tournament_name']){
  // heading changed or is the first one

  if($last_heading != null){// not the first one, (optionally) close out the previous section here...
 [color=#FF0000]  echo "<dd><a href='page.php?con={$row['tournament_id']}'>Click to create tournament</dd>\n";[/color]

  echo "</dl>\n";

  }

  echo "<dl class='v_show_hide' >\n<dt>Tournament {$row['tournament_name']}</a></dt>\n";   
  $last_heading = $row['tournament_name'];
  }
  echo "<dd>Member {$row['team_id']}</dd>\n";
  }

  if($last_heading != null){
echo "</dl>\n";

}

 

 

So, the text in red does not work, it works for the first list but for the next list it makes the dt a link and the link var it is trying to post is the same for the first list....

 

I tried this code in a couple of places and ended up with varying results, none of which are what I wanted...

 

What am I missing?

 

Thanks

Still not quite right...

 

This is what I have now...

 


while ($row = mysql_fetch_assoc($result)){
 // detect if the heading changed
 if($last_heading != $row['tournament_name']){
  // heading changed or is the first one
[color=#FF0000]  echo "<dd><a href='page.php?con={$row['tournament_id']}'>Click to create tournament</a></dd>\n";[/color]

  if($last_heading != null){// not the first one, (optionally) close out the previous section here...

  echo "</dl>\n";

  }

  echo "<dl class='v_show_hide' >\n<dt>Tournament {$row['tournament_name']}</a></dt>\n";   
  $last_heading = $row['tournament_name'];
  }
  echo "<dd>Member {$row['team_id']}</dd>\n";
  }

  if($last_heading != null){
echo "</dl>\n";

}

 

The line in red works, but is placed before the tournament name in my list... if I move the line elsewhere it does not have the corrct value for $con or it will show the link on the end of one list but not others...

 

Any idea?

 

Thanks

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.