Jump to content

Problem with a list


gple

Recommended Posts

I am using a table with data in it to help create a list of links using php.

for ($i=0;$i<$num;$i++)
{
$team=($result,$i,"team")//this line gets the team name.
                                // if I echo $team out, i will get Holy Cross
echo "<a href=team_schedule.php?$team=".$team.">".$team."</a>";

//This code is supposed to produce a link that reads <a href=team_schedule.php?team=holy cross> but for some reason this only produces <a href=team_schedule.php?team=holy. It doesnt recognize anything after the space. Any ideas why this happens and what can be done to make this work. This only happens when the team I am pulling from the table has two words with a space. The info cannot be altered. Any ideas?
}
Link to comment
https://forums.phpfreaks.com/topic/27870-problem-with-a-list/
Share on other sites

The forum code put the [nobbc][/url][/nobbc] into your code because it saw what it thought was a URL. To avoid this in the future, please surround all of your code with [b][nobbc][code][/code][/nobbc][/b] tags.

As for your problem, you need to enclose the value of the href attribute of the HTML address tag [nobbc]<a>[/nobbc] in quotes. This will make sure that all spaces are included in the value of the URL.

[code]<?php
echo '<a href="team_schedule.php?team=' . $team . '">' . $team;
?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/27870-problem-with-a-list/#findComment-127462
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.