Jump to content

[SOLVED] Seperating with comma


freelancer

Recommended Posts

Hello, I wanted to ask help about that how is it possible that when I have for example input field and I put there different links and seperate them with comma (http://www.web1.com, http://www.web2.com) then at my main website where I query my database table, there it shows me 2 or more different URL's which link to these addresses that are saved in database.

 

At the moment I'm using 2 input fields where I put 1link into 1st field and 2 into 2nd field and at my site these are shown so:

 

<? if (empty($ss2)) { echo "<a href='http://root/$ss'>1</a>"; } else { echo "<a  href='http://root/$ss'>1</a>, <a target=\"_blank\" href='http://root/$ss2'>2</a>"; } ?>

 

Someone told me about Comma-separated values but I didn't understand how and whatway I can use it. Hope you understood what I mean and are able to help me!

Link to comment
https://forums.phpfreaks.com/topic/54875-solved-seperating-with-comma/
Share on other sites

You could just split it over the comma

 

<?php

//This would be where your query should be
$urls = 'http://www.site1.com,http://www.site2.com';

list ($url1,$url2) = explode(',',$urls);

echo "<a href=\"".$url1."\">".$url1."</a><br />";
echo "<a href=\"".$url2."\">".$url2."</a><br />";

?>

 

I hope that helps ;D

 

~ Chocopi

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.