Dustin013 Posted June 13, 2008 Share Posted June 13, 2008 I have a table with the location of some files (e.g. 2=http://somefilename.exe) and I need to pull that URL our of the cell and display it as simply http://somefilename.exe. All of the cells have 2= in front of them. How would I go about cutting the 2= off and getting the $httplink variable to display correctly? Here is the code below I am working with... <?php if (isset($_GET['showid'])) { $fileID = $_GET['fileid']; } if (isset($_GET['otherid'])) { $otherID = $_GET['otherid']; } include("include/config.php"); include("include/connect.php"); mysql_select_db($dbname, $conn) or die ($dbname . " Database not found."); $query = "SELECT * FROM $table1 WHERE fileid =".$fileID." AND otherid =".$otherID." ORDER by name"; $result = mysql_query($query); $num = mysql_num_rows($result); $i=0; while ($i < $num) { $httplink = $ mysql_result($result, $i, "httplink"); $showfilename = mysql_result($result,$i,"name"); echo "<li><a href='$httplink'>$showfilename</a></li><br />"; $i++; } include("include/closedb.php"); ?> Link to comment https://forums.phpfreaks.com/topic/109995-php-how-do-i/ Share on other sites More sharing options...
trq Posted June 13, 2008 Share Posted June 13, 2008 Sorry, but your question makes little sense. http://somefilename.exe (all be it invalid on the wan) is a domain name, your question is? Link to comment https://forums.phpfreaks.com/topic/109995-php-how-do-i/#findComment-564440 Share on other sites More sharing options...
Dustin013 Posted June 13, 2008 Author Share Posted June 13, 2008 That link was an example path... all the cells have the link but the information is entered "2=http://domain.com/path/to/file.ext". I want to display "2=http://domain.com/path/to/file.ext" as "http://domain.com/path/to/file.ext"... simply removing the "2=" that is before the http://.. Link to comment https://forums.phpfreaks.com/topic/109995-php-how-do-i/#findComment-564444 Share on other sites More sharing options...
bluejay002 Posted June 13, 2008 Share Posted June 13, 2008 sorry for askin' but i just want to know why was there '2=' in the first place? well at any case, given 2= uniquely happen and is never included in any part of the path/filename... you may use preg_replace() for that... that is, using regular expression with a blank... its a sanitation process more like to say. Link to comment https://forums.phpfreaks.com/topic/109995-php-how-do-i/#findComment-564446 Share on other sites More sharing options...
hitman6003 Posted June 13, 2008 Share Posted June 13, 2008 Use either ltrim or substr... $string = "2=http://domain.com/path/to/file.ext"; echo substr($string, 2); Link to comment https://forums.phpfreaks.com/topic/109995-php-how-do-i/#findComment-564468 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.