Jump to content

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>"; 
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.