freelancer Posted June 9, 2007 Share Posted June 9, 2007 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 More sharing options...
chocopi Posted June 9, 2007 Share Posted June 9, 2007 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 ~ Chocopi Link to comment https://forums.phpfreaks.com/topic/54875-solved-seperating-with-comma/#findComment-271405 Share on other sites More sharing options...
freelancer Posted June 9, 2007 Author Share Posted June 9, 2007 Thanks, I also got solution here <?php $query = mysql_query("SELECT * FROM table"); hile ($info=mysql_fetch_array($query)) { $crap = explode(",", $info['ss']); foreach($crap as $v) { echo $v; } } ?> Link to comment https://forums.phpfreaks.com/topic/54875-solved-seperating-with-comma/#findComment-271411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.