ringocarr Posted December 13, 2008 Share Posted December 13, 2008 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 More sharing options...
ringocarr Posted December 13, 2008 Author Share Posted December 13, 2008 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>"; Link to comment https://forums.phpfreaks.com/topic/136820-database-value-at-end-of-url/#findComment-714569 Share on other sites More sharing options...
wildteen88 Posted December 13, 2008 Share Posted December 13, 2008 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>"; } Link to comment https://forums.phpfreaks.com/topic/136820-database-value-at-end-of-url/#findComment-714609 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.