0
Hello, I’m making a site in php and html, linked to a database in mysql.
And I have a table of news in the database, with the idartigos fields, title, text and link.
The link is running in text and I would like when someone sees the news on the site, becomes a link, so that the person clicked. Can someone help me?
$query = mysqli_query($mysqli, "SELECT * FROM artigos WHERE activo = 1 ORDER BY idartigos DESC");
while($row_artigos = mysqli_fetch_array($query))
{
echo "<br><br>";
echo($row_artigos[1]);
echo "<br>";
echo($row_artigos[2]);
# tirar # qdo tiver link echo($row_artigos[3]);
echo "<br><br>";
yes @carlosandrade however this code does not make people be redirected to the location that the link points to, imagining that I put www.google.pt I wanted the person clicking on the link to be redirected to that site.
– Joyana
Don’t? This example should print on your page something like:
<a href="http://www.google.pt">http://www.google.pt</a>
. Remembering that for the link to work, you should also write the protocol in the url, which would be exactly like this:http://www.google.pt
and not justwww.google.pt
.– Carlos Andrade
If you do not save the protocol in the field of your table (
http://
orhttps://
) you can add it when generating the link:echo '<a href="http://'.$row_artigos[3].'">'.$row_artigos[3].'</a>';
– Carlos Andrade
+1 is just that!!
– Joyana
I will make an edit in the reply to make a check for if the protocol is not inserted in the field, the same be inserted.
– Carlos Andrade