Stringa che diventa un url

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
Ritorno con un altro quesito,

ho campo di nome distributor ( varchar) e' utilizzato per inserire indirizzi in formato testo, vorrei che diventasse un url ed si aprissi su un'altra pagina se clicco sopra
esempio:
da
imdb.com
a

la visualizzazione deve essere come il testo originale pero' (imdb.com) , solo creare il collegamento

il codice sotto non funziona, inoltre c'e' un'altra cosa da risolvere, come controllare se l'url in cui punta e di tipo https o http ?

PHP:
<?php

if(!empty($row['distributor'])) { echo "<p class=\"bioheading\">Distributor</p><p  class=\"biodata\">" . '<a href="' . $row ['distributor'] . '" target="_blank">' . $row ['distributor'] .'</a> ' . "</p>"; }

?>

grazie
 
PHP:
<?php

if(!empty($row['distributor'])) { echo "<p class=\"bioheading\">Distributor</p><p  class=\"biodata\">" . '<a href="' . '//' . $row['distributor'] . '" target="_blank">' . $row['distributor'] .'</a> ' . "</p>"; }

?>
Se la url è in https o http dovrebbe aprire una pagina di ugual tipo.
.
 
Ultima modifica:
sembra che cosi funziona :)

PHP:
<?php

if(!empty($row['distributor'])) { echo "<p class=\"bioheading\">Distributor</p><p  class=\"biodata\">" . '<a href="' . 'Http://' . $row['distributor'] . '" target="_blank">' . $row['distributor'] .'</a> ' . "</p>"; }

?>

grazie Hormus ;)
 
e sorto un altro problema, se inserisco doppie stringhe separate da virgola non mi separa i link

questo e' il file distributor.php


PHP:
<?php 
    
    
   $country_ = $row['distributor'];
        $singolo_paese = explode(",", $country_);
foreach($singolo_paese as $distributor_){
                          $distributor_ = trim($distributor_);
switch ($distributor_)
       {
          
case 'universalpictures.com':
echo  '<img src="../image_upload/distributor/universalpictures-57x57.png"></img>' . '&nbsp;&nbsp;';
break;


case 'imdb.com':
echo  '<img src="../image_upload/distributor/imdb.ico"></img>' . '&nbsp;&nbsp;';
break;


default:
echo  '(<span style="color:red;"> no flag</span>)' .'<img src="../image_upload/distributor/nomatch.gif"</img>' . '&nbsp;&nbsp;' ;


}
}


?>


e questo quello precedente

PHP:
<?php
// inserito href che trasforma la stringa in url code by Hormus 2020.08.25


if(!empty($row['distributor'])) { echo "<p class=\"bioheading\">Distributor</p><p  class=\"biodata\">" . '<a href="' . 'Http://' . $row['distributor'] . '" target="_blank">' . $row['distributor'] .'</a> ' . "</p>"; }




?>


<?php


include ("distributor.php");


?>
 
non capisco dove sta l'errore, adesso mi splitta la stringa ma non mi genera l'url :rolleyes:


sshot-2.png



distributor.php

PHP:
<?php 
    
    
   $country = $row['distributor'];
        $singolo_paese = explode(",", $country);
foreach($singolo_paese as $distributor){
                          $distributor = trim($distributor);
switch ($distributor)
       {
          

case 'universalpictures.com':
echo $distributor . '<a href="' . 'Http://' . $distributor . '" target="_blank">' .'</a> ' . '&nbsp;&nbsp;' . '<img src="../image_upload/distributor/universalpictures-57x57.png"></img>' . '&nbsp;&nbsp;';
break;


case 'imdb.com':
echo  $distributor . '<a href="' . 'Http://' . $distributor . '" target="_blank">' .'</a> ' . '&nbsp;&nbsp;' .'<img src="../image_upload/distributor/imdb.ico"></img>' . '&nbsp;&nbsp;';
break;


default:
echo  '(<span style="color:red;"> no flag</span>)' .'<img src="../image_upload/distributor/nomatch.gif"</img>' . '&nbsp;&nbsp;' ;


}
}


?>
 
risolto :D

PHP:
case 'universalpictures.com':
echo '<a href="' . 'Http://' . $distributor . '" target="_blank">' . $distributor .'</a> ' . '&nbsp;&nbsp;' . '<img src="../image_upload/distributor/universalpictures-32x32.png"></img>' . '&nbsp;&nbsp;';
break;


case 'imdb.com':
echo  '<a href="' . 'Http://' . $distributor . '" target="_blank">' . $distributor .'</a> ' . '&nbsp;&nbsp;' .'<img src="../image_upload/distributor/imdb-32x32.png"></img>' . '&nbsp;&nbsp;';
break;
 

Discussioni simili