Jump to content

ScottLacey

New Members
  • Posts

    6
  • Joined

  • Last visited

ScottLacey's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So I am currently working on a website that is a business directory. These listings are grouped by regions and categories. My problem is that this website is going to be multilingual. The regions and categories are stored in a database and I need to easily be able to both modify and access the language items based on the user's selected language. I would prefer to store these names in CI's language files. I've thought about creating a column in each table called "language index" so that would make it easy to call the items from the language file... for example foreach($query_categories->result_array() as $cat) { $title = $this->language->item($cat['language_index']); } But the bigger issue is editing the file if a category is modified or deleted(I can just add a new line to the end of the file if one is created). What do you guys think would be the best way to store and modify names for different languages for each of these regions and categories?
  2. Yeah I agree with you about alerting the user. Seems like it would be more of an annoyance than anything else. I was thinking about this more and realized it would be better to perform the search as the user types. However, instead of a timer, do you think performing the search after every three or four types of a key would be more prudent?
  3. Okay, so I'm pretty new to jQuery but I am pretty experienced with PHP. I am about to begin coding a script written mostly in jQuery. It will use AJAX to verify that an article tag a user provides exists in a database. When a user goes to write an article on my website, my form will ask them to add keyword tags which will be used in searches. Basically only admins will be allowed to create new tags, so this is why I check the tags first. And also to prevent duplicates and similar tag entries in the database. The form will have a single input that the user will use to search for a tag. Once the user hits the enter key, it will search the database for tags that already exist. Once the ajax is complete, a list of related tags will pop up and the user will be able to select their desired tag by either clicking the tag link in the list or by pressing enter. This is a very crude demonstration of what my idea is. This is my flow chart. Am I missing any steps? Have any suggestions that would make this better?
  4. I have a file upload script that will eventually process a ton of files. I would like to upload them into sub-directories according to what year, month, and day they are uploaded. A typical tree should look like this: attachments/ --/2014 -----/January --------/01 --------/02 --------/03 , etc. -----/February --------/01 --------/04 --------/09 --------/18 --------/20, etc -----/March, etc --/2015, etc. So a file called image.jpg uploaded on 10/31/2014 would have a URL of attachments/2014/October/31/image.jpg. I understand that every time a file is uploaded, the script would have to detect through FTP whether or not folders for the year, month, and day exist, and if they don't create them. My problem is that I have no idea what the logic of this script would be. What order should I do things in? Is there a way to use maybe foreach to detect/create the folders? Any input would be appreciated.
  5. Is there a way that I could also fetch the title of the last article in this query?
  6. I am developing a CMS with articles and categories. I am making a feature for the admin panel that shows all the categories. In the table, I would like to include each category's latest article. My traditional method is to select just the categories in one query, loop through the results, and then inside the category loop have a query that gets the information on the latest article... So something like... $query = " SELECT category_id, title, description FROM categories ORDER BY title ASC"; if($query = mysql_query($query)){ while($cat=mysql_fetch_assoc($query)){ $query_article = " SELECT article_id, category_id, title FROM articles WHERE category_id = ".$cat['category_id']." ORDER BY article_id DESC LIMIT 1"; $last = mysql_fetch_assoc($query_article); } } How could I use joins and/or subqueries to achieve my goal of combining these two queries into one? I have come up with a query which is below: SELECT c.category_id, c.title, c.description, a.article_id, a.category_id, a.title, COUNT(a.article_id) AS total_articles FROM article_categories AS c LEFT JOIN articles AS l ON ( SELECT article_id AS article_id, category_id, title AS article_title FROM articles AS l WHERE l.category_id = c.category_id ORDER BY l.article_id DESC LIMIT 1) LEFT JOIN articles AS a ON (c.category_id = a.category_id) GROUP BY c.category_id ORDER BY c.title ASC When I use the above query, I get an error saying "Operand should contain 1 column(s)" I would also like to add something that counts the total number of articles in the category. Thanks for your time!
×
×
  • 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.