Jump to content

[SOLVED] Can't create html link


StanLytle

Recommended Posts

I've tried several different ways and can't get the output to generate a link.  Here's the code:

 

<?

$query = "SELECT UserID, COUNT(UserID), SUM(Views) FROM Photos GROUP BY UserID";

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result))

{

echo "There are ". $row['COUNT(UserID)'] ." photos and ". $row['SUM(Views)'] ." views for user ". $row['UserID'] ."" ?><a href=Search.php?SearchUserID='UserID'&Search=Search>Search</a><?;

echo "<br />";

}

?>

 

Here's what the output looks like:

 

There are 52 photos and 932 views for user 2Search

 

Everything I have tried generates an unexpected error code.  I'd like the UserID number to be a clickable link, that generates code that says "Search.php?SearchUserID='UserID'&Search=Search>Search" where UserID number is the same value as returned with the "$row['UserID']" function.

 

Thanks,

Stan

 

Link to comment
https://forums.phpfreaks.com/topic/43705-solved-cant-create-html-link/
Share on other sites

try

<?php

$query = "SELECT UserID, COUNT(UserID), SUM(Views) 
            FROM Photos 
            GROUP BY UserID";
$result = mysql_query($query) or die(mysql_error());
while(list($id, $ct, $sum) = mysql_fetch_row($result))
{
   echo "There are $ct photos and $sum views for user $id <a href='Search.php?SearchUserID=$id&Search=Search'>Search</a><br>";
   
}
?>

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.