I looked through at least 10 questions before I got here and then looked at every relevant question the site gave me with my question title. The most relevant thing I found was:
Can't put hyperlink in PHP echo statement
However, if I use either single or double quotes I still can't click any of the links.
echo '<div a href="http://www.amouramis.com">yo</div>';
echo "<div a href='http://www.amouramis.com'>yo</div>";
I opened up the "view page source" and can click in there and it navigates, but it's all text in there, which defeats the purpose.
Maybe I messed up something earlier? Here's the entire code (yes, it's crazy looking):
<?php
include "errorcontrol.php";
include "style.css";
$days=0;
ob_end_flush();
ob_start();
do{
echo $days++;
$ten = ob_get_contents(); //10
$first = str_split($ten);
}while ($days<10);
ob_end_flush();
echo "<br>";
echo 10 + $days;
echo "<br>";
ob_start();
//20
do{
echo $days++;
$tenplus = ob_get_contents();
$second = str_split($tenplus, 2);
}
while ($days<32);
ob_end_flush();
//truncate
$all = array_merge((array)$first, (array)$second);//30
echo "<br>";
echo $ten;
echo "<br>" . "NEXT" . "<br>";
echo $tenplus;
echo "<br>" . "first array contents follow" . "<br>";
print_r($first);
echo "<br>" . "second array contents follow" . "<br>";
print_r($second);//40
echo "<br>";
echo "code ran";
echo "<br>";
print_r ($all);
echo "<br>";
echo "<br>";
$i="1";
echo $i;
echo "<br>";//50
$name = "name of table";
echo "<table>";
echo "<tr>";
echo '<th class="month">' . $name . '</th>';
echo "</tr>";
//60
do{
echo '<tr>' . '<td a href="http://www.hotmail.com/' . $i . '.html" class="border">' . $all[$i] . '</td>' . '</tr>';
$i++;
}while ($i < 32);
echo "</table>";
echo '<div a href="http://www.amouramis.com">yo</div>';
echo "<div a href='http://www.amouramis.com'>yo</div>";
?>
This has nothing to do with PHP. You can't click on these links because these aren't links:
<div a href="http://www.amouramis.com">yo</div>
What you have there is invalid HTML. And a browser's behavior with invalid HTML is undefined. A link would look like this:
<a href="http://www.amouramis.com">yo</a>
Or, within a div
:
<div><a href="http://www.amouramis.com">yo</a></div>
Links are of the form <a href="http://example.com/">Click here</a>
, without the div
after the <
.
This isn't valid HTML:
echo '<div a href="http://www.amouramis.com">yo</div>';
echo "<div a href='http://www.amouramis.com'>yo</div>";
If you want the whole div to be a link use:
echo '<a href="http://www.amouramis.com"><div>yo</div></a>';
If you want the text to be a link use:
echo '<div><a href="http://www.amouramis.com">yo</a></div>';