Guest robj Posted June 7, 2007 Share Posted June 7, 2007 I'm modifying the siteDocs.inc.php file to only display the first 5 id's. How can I end the count for $results[$i] within siteDocs.inc.php? Explanation: If doc_id = 6 end count and display Hope that helps -rob Quote Link to comment Share on other sites More sharing options...
Guest robj Posted June 7, 2007 Share Posted June 7, 2007 Found a solution. To exlude docID's above 5, I opened siteDocs.inc.php and: changed $results = $db->select("SELECT doc_id, doc_name FROM ".$glob['dbprefix']."CubeCart_docs ORDER BY doc_name ASC"); to $results = $db->select("SELECT doc_id, doc_name FROM ".$glob['dbprefix']."CubeCart_docs WHERE doc_id < 6 ORDER BY doc_name ASC"); Hope this help someone else. -rob Quote Link to comment Share on other sites More sharing options...
Guest EverythingWeb Posted June 7, 2007 Share Posted June 7, 2007 That will work without issue, unless you say deleted a site doc, added it as a new one, and it was added in the database with a higher value in the sitedoc id column (auto_increment). The fix in the results loop line would be to change: for ($i=0; $i<count($results); $i++){ to: for ($i=0; $i<5; $i++){ HTH. Quote Link to comment Share on other sites More sharing options...
Guest robj Posted June 11, 2007 Share Posted June 11, 2007 Let me ask this, in response to " auto_increment": If I deleted doc 3 (of the 6 docs) would the next doc I create have an id of 3 or would it be 7? It seems to me that either change would create a different problem. Unless there is a way to define which ID is to display on a specific navigation area, the admin will just have be be diplomatic on what to display. Also, the loop change has been tested and does work (for those anonymous visitors). Quote Link to comment Share on other sites More sharing options...
Guest EverythingWeb Posted June 11, 2007 Share Posted June 11, 2007 It would be ID 7 Yes, both could cause issue, you're right. You can always edit the value of the auto_increment in the database record, but it depends how heavy you want to get Quote Link to comment Share on other sites More sharing options...
Guest robj Posted June 12, 2007 Share Posted June 12, 2007 Making changes to the db woudn't be an issue for me, but for someone with less knowledge it might. I suggest plan ahead then create. Good info. Thanks -rob Quote Link to comment Share on other sites More sharing options...
Guest Posted June 16, 2007 Share Posted June 16, 2007 Try this:$results = $db->select("SELECT doc_id, doc_name FROM ".$glob['dbprefix']."CubeCart_docs ORDER BY doc_name ASC LIMIT 5"); ;) Quote Link to comment Share on other sites More sharing options...
Guest robj Posted June 28, 2007 Share Posted June 28, 2007 More fun: Currently within siteDocs.inc.php this is the display results function: $results = $db->select("SELECT doc_id, doc_name FROM ".$glob['dbprefix']."CubeCart_docs WHERE doc_id < 6 ORDER BY doc_name ASC"); How can I change this to get docs starting at id 2 through 6, eg: WHERE doc_id > 1 && < 6 (this code doesn't work) thanks -rob Quote Link to comment Share on other sites More sharing options...
Guest EverythingWeb Posted June 29, 2007 Share Posted June 29, 2007 WHERE 1 AND doc_id < 6 AND > 2 ORDER BY doc_name ASC" try that Quote Link to comment Share on other sites More sharing options...
Guest Posted June 29, 2007 Share Posted June 29, 2007 That won't work Will. The "WHERE 1" does nothing. And you can't use multiple conditionals like that....it'll throw an error. The proper way would be: SELECT doc_id, doc_name FROM ".$glob['dbprefix']."CubeCart_docs WHERE doc_id >= 2 AND doc_id <= 6 ORDER BY doc_name ASC Here are two pages that are indispensable when trying to construct SQL queries: MySQL - Functions and Operators MySQL - SQL Statement Syntax There are other pages on data types and such that are great too, but those to sections should be read by anybody who really wants to learn how to get the most out of their database. :) Quote Link to comment Share on other sites More sharing options...
Guest EverythingWeb Posted June 29, 2007 Share Posted June 29, 2007 Sorry Bill. It was nearly 3 in the morning and had been up and awake for around 18 hours! Wasn't thinking straight. I've duly slapped myself. Quote Link to comment Share on other sites More sharing options...
Guest Posted June 29, 2007 Share Posted June 29, 2007 Slap noted. ....next time, we want video though. :w00t: Quote Link to comment Share on other sites More sharing options...
Guest EverythingWeb Posted June 29, 2007 Share Posted June 29, 2007 :w00t: Quote Link to comment Share on other sites More sharing options...
Guest robj Posted July 2, 2007 Share Posted July 2, 2007 Fantastic. The script works like a dream, but I could have sworn I tried that. 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.