Jump to content

PHP How do I...?


Dustin013

Recommended Posts

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

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

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

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.