Display links in sql query

Asked

Viewed 52 times

0

In a database (Mysql) I have a column dedicated to electronic addresses (links). My problem is: often the same line can have multiple links. I would like to include the links in the bank in the same cell (Links), and in the display, make a href or something, so that each link is clickable for the user, and does not appear attached to the other (example: www.google.comwww.youtube.comwww.facebook.com).

Any idea how I should proceed ?

  • You can change the way these links are recorded?

  • The ideal is to have only one link per line. It is also possible to do this with several links but is not recommended.

  • The way I found it was to insert repeat records, only changing the link on each re-inclusion.. but it gets a lot repeated and I think it can slow down the consultation..

  • I find it difficult now to change the way of recording the link, because I need to finish soon, but I am open to suggestions..

1 answer

1

There are several ways to do this recommend using serialize/unserialize.

<?php

$sites = array(
    'www.google.com',
    'www.terra.com.br',
    'www.globo.com'
);

$serializado = serialize($sites);

$lista = unserialize($serializado);
var_dump($serializado);
var_dump($lista);

ex. https://ideone.com/8GftAj

Then just make a foreach to assemble the links

  • Thanks for the tip, I’ll test.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.