I am attempting to turn some query results into click-able links through PHP. I am a beginner and do not fully realize much. I am dealing with Wordpress. This is what I am shooting for: http://www.celebrything.com/

The best side bar is display the count results. I would like the celebrity names to connect to search links for every title. therefore the first should connect to http://www.celebrything.com/?s=%22Tiger+Woods%22&search=Search

Here's the PHP I am using to show my current results:

<?php
    global $wpdb;
    $result = $wpdb->get_results('SELECT name, count FROM wp_celebcount');

    foreach($result as $row) {
        echo ''.$row->name.' - '.$row->count.' Posts <br/>';
    }
?>

Now you ask ,, how you can I update this code to show what they are called into search links?

echo '<a href="http://www.celebrything.com/?s='.urlencode($row->name).'&search=Search">'.$row->name.' - '.$row->count.' Posts </a><br/>';
<a href="<?php bloginfo('url'); ?>/?s=<?php echo urlencode($row->name); ?>">
    <?php echo "{$row->name} ({$row->count} Posts)"; ?>
</a>

Observe that bloginfo is really a WordPress-specific function, so if you're focusing on a WordPress theme, I suggest by using this instead of hard-coding the domain title.

Creating a hyperlink is not really anything a lot more than you are already doing. The key part would be to make certain you correctly escape relevant areas of the URL. That is what [cde] is perfect for.

urlencode()

Do this:

foreach($result as $row) {
  echo '<a href="http://www.celebrything.com/?s=' .
    urlencode($row->name) . '&search=Search">' . $row->name .
    '</a> - ' . $row->count . ' Posts<br/>';
}