Jump to content

a href to each result in a query


knaj11

Recommended Posts

i want each result of my query to have a link or be in a <a href =" "> tag..

 

code is this...

$query = "select artist from lyrics where artist like 'a%' order by artist ASC";
$result = mysql_query($query) or die ("Error in query: $query . " . mysql_query());

if (mysql_num_rows($result) > 0)
{
	while ($row = mysql_fetch_object($result))
	{
	?>
		<?php echo $row->artist; ?><br>
	<?php
	}
}
else
{
	echo 'No Content';
}

 

the result of this code is just this....

 

Adam Sandler

Aqua

Avril Lavigne

 

 

all w/o links...

 

how can i have the resulting queries have links???

 

 

Link to comment
https://forums.phpfreaks.com/topic/197525-a-href-to-each-result-in-a-query/
Share on other sites

$query = "select artist from lyrics where artist like 'a%' order by artist ASC";
$result = mysql_query($query) or die ("Error in query: $query . " . mysql_query());

if (mysql_num_rows($result) > 0)
{
	while ($row = mysql_fetch_object($result))
	{
		echo "<a href = \"somepage.php\">$row->artist;</a>";
	}
}
else
{
	echo 'No Content';
}

 

Not sure if it is

 

echo "<a href = \"somepage.php\">$row->artist;</a>";

 

or

 

echo "<a href = \"somepage.php\">$row->artist</a>";

bout the double post....

 

i think you got it all wrong...

 

my first post w/ subject "SELECT QUERY HELP" was on how to query something base on its first letter....

 

my second post w/subject "a href to each result in a query" was on how my result queries to have links on it...

 

just to clear things up mod fenway..

 

im not sure if my pm for you was sent it was not in my sent items so i did it here instead.

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.