Jump to content

Database value at end of url


ringocarr

Recommended Posts

I'm trying to grab a value from a mySQL database and put that value on the end of a url path

 

e.g. http://url.com/$valuefromdb

 

The value from the database is data stored in a field (in this case filename)

 

Is there any tutorials to how to do this or can anybody recommend how to tackle this?

 

Kind Regards

Link to comment
https://forums.phpfreaks.com/topic/136820-database-value-at-end-of-url/
Share on other sites

I've tried various things now to attempt to get this to work - all to no avail.

 

My current attempt is

// Define variables
$filename = mysql_query("SELECT log_filename FROM uploads_log");
$issueno = mysql_query("SELECT log_issue FROM uploads_log");
$issuemonth = mysql_query("SELECT log_month FROM uploads_log");

print "<a href=www.url/uploads/$filename><?php echo Issue $issueno.", ".$issuemonth; ?></a>"; 


mysql_query only returns a result resource. In order to get the data from the result resource you'll need to use one of the mysql_fetch_(assoc, array oe row) functions, eg

 

// Define variables
$result = mysql_query("SELECT log_filename, log_issue, log_month FROM uploads_log");

while($row = mysql_fetch_row($result))
{
    list($filename, $issueno, $issuemonth) = $row;

    print "<a href=www.url/uploads/$filename><?php echo Issue $issueno.", ".$issuemonth; ?></a>"; 
}

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.