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
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>";

Link to comment
Share on other sites

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.

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.