waterox Posted January 29, 2009 Share Posted January 29, 2009 Hi, I am very new to php so go easy on me! I am trying to hack some pre-existing php code (see below) What I have is a page that currently gets the newest item from a database. On some pages this works. However, in this instance I need to show a specific item. Since the page is not fully dynamic, it is named after the corresponding item in the database (eg blue.php) I need to change the line that orders by itemDate. I'm guessing that grabbing 'blue' from /blue.php and looking this up in the table might be the solution? How could I achieve this? Below is the code: <?php $url = $_SERVER ["PHP_SELF"]; print "<!-- URL [$url] -->\n\n"; $productCode = substr($url, 15, 5); print "<!-- BC [$productCode] -->\n\n"; include('/include/ez_sql.php'); $product = $db->get_row(" SELECT productName, productText FROM product WHERE productCode = '$productCode' "); $item = $db->get_row(" SELECT itemCode, itemCat, itemName, itemText, itemDate FROM item WHERE itemCode REGEXP '^$productCode' ORDER BY 'itemDate' DESC LIMIT 1 "); $format = $db->get_results(" SELECT format FROM format WHERE itemCode = '$item->itemCode' "); $categoryCode = substr($item->itemCode, 5, 3); $itemCodex = substr($item->itemCode, -5); $category = $db->get_row(" SELECT categoryName FROM category WHERE categoryCode = '$category' "); $formats = $db->get_results(" SELECT lf.displayFormat FROM `format` f LEFT JOIN `lookupFormat` lf ON lf.japFormat = f.format WHERE f.itemCode = '$itemCodex' "); ?> Quote Link to comment Share on other sites More sharing options...
manny Posted April 1, 2009 Share Posted April 1, 2009 which field in the database holds the blue.php?? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.