Staggan Posted November 22, 2012 Share Posted November 22, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/271035-adding-link-to-definition-list/ Share on other sites More sharing options...
Staggan Posted November 22, 2012 Author Share Posted November 22, 2012 Actually, I should be clearer on clicking the tournament name I want to open another page sending the tournament_id as a post variable... Thanks Quote Link to comment https://forums.phpfreaks.com/topic/271035-adding-link-to-definition-list/#findComment-1394402 Share on other sites More sharing options...
PFMaBiSmAd Posted November 22, 2012 Share Posted November 22, 2012 (edited) 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 November 22, 2012 by PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/271035-adding-link-to-definition-list/#findComment-1394404 Share on other sites More sharing options...
thara Posted November 22, 2012 Share Posted November 22, 2012 What is the problem that you have faced with this script? Is there any errors? Quote Link to comment https://forums.phpfreaks.com/topic/271035-adding-link-to-definition-list/#findComment-1394405 Share on other sites More sharing options...
Staggan Posted November 22, 2012 Author Share Posted November 22, 2012 (edited) I've tried add an href link but it does not work...and yes I want to turn the tournament name into a link Thanks Edited November 22, 2012 by Staggan Quote Link to comment https://forums.phpfreaks.com/topic/271035-adding-link-to-definition-list/#findComment-1394406 Share on other sites More sharing options...
Staggan Posted November 22, 2012 Author Share Posted November 22, 2012 Ah, I missed the line of code.. That works thanks, I had my href in the wrong place Quote Link to comment https://forums.phpfreaks.com/topic/271035-adding-link-to-definition-list/#findComment-1394408 Share on other sites More sharing options...
Staggan Posted November 22, 2012 Author Share Posted November 22, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/271035-adding-link-to-definition-list/#findComment-1394425 Share on other sites More sharing options...
mrMarcus Posted November 22, 2012 Share Posted November 22, 2012 You're missing a closing </a> to your link. Quote Link to comment https://forums.phpfreaks.com/topic/271035-adding-link-to-definition-list/#findComment-1394427 Share on other sites More sharing options...
Staggan Posted November 22, 2012 Author Share Posted November 22, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/271035-adding-link-to-definition-list/#findComment-1394443 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.