Jump to content

richiman

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Everything posted by richiman

  1. Hello, Are different arrays. {$cate1} works, but as I say, there can be up to 100 arrays: $cate100, or even more. I've managed to get it working with a PHP block. I know it is not clean nor recommended, but that's the only thing I could get working in Smarty 2.x. Here's the code: {assign var="name" value="cate"} {php} $varname = $this->get_template_vars('name').$this->get_template_vars('i'); $this->assign('result', $this->get_template_vars($varname)); {/php} Then loop through result with a {section name=result loop=$result}{/section} Thanks for the help. I hope someone finds this post useful. Regards, Richi
  2. Hello, I have variables containing arrays that are named automatically: cate1 | cate2 | cate3 | and so on. I need to use those vars in Smarty. The problem is that I cannot get it working with the official documentation. cateX, where X is $i. {section name=catdisp start=1 loop=$cattotal+1 step=1} {assign var="i" value=$smarty.section.catdisp.index} Iteration {$i} <br /> {$cate{$i}} {/section} Iteration works, but I cannot make the script output cate0. It does not even output: "Array". Any help is greatly appreciated. Regards, Richi
  3. Hello, They have #, because there are cases, where multiple categories exist there: #2# #24# etc. It's a premade script called Clip-Bucket, so making them without # will affect other functions as well. I'll try what you just told me. Will keep you updated. Thanks for the help. Regards, Richi
  4. I know quoting in the above query is wrong, just noticed, but can't edit anymore.
  5. Hello, I'm trying to create the SQL query, but I am having trouble doing it. So far, I have: $q="SELECT cb_video_categories.category_name, cb_video "."FROM cb_video_categories,cb_video "."WHERE cb_video.category = cb_video_categories.category_id"; But the problem, is that cb_video.category records, have # symbols. I mean, category is wrapped like this: #5#. How can I make it override those symbols? My query will look for the category name and will fetch all the rows of cb_video (item). Regards, Richi
  6. Hello, Categories is actually an array that contains multiple elements. Let's forget about Smarty, and simply try to do it in PHP. I have a parent category and a sub category. Each sub category has mutiple items. I want to display all sub categories and display all items the sub category has. Subcat ->Item ->Item ->Item Subcat ->Item ->Item ->Item Subcat ->Item ->Item ->Item When I know the subcategory id, it will now look into another table to find all items that have that belong to that sub category. For example, I need to fetch items from sub cat 1,2,3. I can think of a for() loop, counting all the subcategories we are going to fetch if they where in an array with count(). $catsarr = array(1,2,3); //All the cats must be retrieved from the db. This is what is causing me trouble to achieve. for($i=1;$i<=count($catsarr);$i++) { $q= "SELECT * FROM items WHERE subcategory = {$i}"; $res=mysql_query($q); while($row=mysql_fetch_array($res)) { print "Sub category".$i."<br />"; //HERE I NEED A LOOP TO SHOW ME ALL THE VIDEOS THAT ARE FROM THAT CATEGORY. DON'T KNOW HOW TO. } } It's kinda confusing for me to explain. If someone does really want to help me and has the time, we can have a chat. I'd definitely appreciate it. Again, any help is greatly appreciated. Regards, Richi
  7. Hello, Thanks for the help, yet that's not what I need , it's kinda hard to explain, though. The query, fetches two rows, but when I pass var to smarty, it only has the last one. I need to work with each of them different, if I could add lets say row1 as $cat1arr, row2 as $cat2arr, would be great! I hope I was clear and somebody can help me. I appreciate all the help! Regards, Richi
  8. Hello, This is driving me crazy, as I cannot get it working. I have a database that has a table called 'categories'. I need to retrieve all categories with category_id != '1,2,3'. For this, I can this query: $q = "SELECT * FROM categories WHERE category_id NOT IN (1,2,3 )"; The query executes fine. I need this categories retrieved, to be passed to a Smarty Template Engine powered page. I have: $q = "SELECT * FROM categories WHERE category_id NOT IN (1,2,3)"; $res = mysql_query($q); while($row=mysql_fetch_array($res)) { Assign('categories',$row); } But when retrieving the array in the Smarty page, with a loop, I only see the last item of the array (the last category). If I go back to the while loop, and add a print_r($row); , I see two arrays (I have two categories). But the question is: How can I work with those two categories, as I need to use them individually outside the while loop? Any help is appreciated. Best Regards, Richi
×
×
  • 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.