Mahmud Adam Mahmud Adam - 2 months ago 16
PHP Question

Linking to Google Search in href

I am dynamically creating a table, and I'd like to display the title of the books to be links to a Google search of the title. I have looked at many solutions here, but all suggest something like this:

"<td><a href='http://google.com/q={$title}'>'$title'</a></td>";


echo "<TR>";
echo "<TD><a href='http://google.com/q={$title}'>$title</a></TD>";
echo "</TR>";


But I cannot get this to work since
//
keeps getting recognized as a comment. Is there a better way to do this?

Answer

try this one:

echo "<TR>";
echo "<TD><a href='http://google.com/?gws_rd=cr,ssl#q={$title}'>$title</a></TD>";
echo "</TR>";

it is not perfect way to search, use google search script for best result. https://developers.google.com/custom-search/docs/tutorial/implementingsearchbox