I want to get a hyperlink from a mysql (bibliographic) database to my php webpage. In order that I might have a sound hyperlink for each ebook each in native and in distant net pages.
I assume that the one approach ought to be to make use of javascript. And certainly the next code works (after all $intellectualia php variable is already outlined, completely different in native and in distant), in a single static web page:
<script>
var intellectualia = "<?php echo "$intellectualia"; ?>";
</script>
<p>Hyperlink to <a href="" onclick="location.href=intellectualia+'/mypath/myfilephp';return false;">go to myfile</a></p>
However utilizing mysql in php I didn’t handle to get the anticipated consequence.
This code doesn’t work:
I omit the entire mysql question (and a few ineffective rows):
$consequence = mysqli_query($db, $question);
echo "<desk>";
whereas ($row = mysqli_fetch_array($consequence))
{ $href = "https://www.sitepoint.com/group/t/dynamic-link-from-mysql/$row[href]";
$hyperlink = "onclick="https://www.sitepoint.com/group/t/dynamic-link-from-mysql/$row[href]"";
if($href != '') {echo "<td><a href="" $hyperlink>learn</a></td>";}
echo "</tr>"; }
echo "</desk>";
In my mysql knowledge I’ve set a row with this content material (in href
column):
location.href=intellectualia+'/mypath/myfile.php';return false;
The ensuing html supply code (not working, after all) is:
<a href="" onclick='location.href=intellectualia+'/mypath/myfile.php';return false;'>learn</a>
What ought to I modify?
Thanks!