vLIB
Welcome, Guest. Please login or register.
Did you miss your activation email?
Fri, 21. December 2007 - 08:59:00

Login with username, password and session length
Search:     Advanced search
Please register with your real name and do not post any SPAM! Violations: "Hk." and "Getagrip" => deleted
1.459 Posts in 346 Topics by 21 Members
Latest Member: Tim81
* Home Help Search Login Register
+  vLIB
|-+  English support
| |-+  vlibTemplate, vlibMimeMail, vlibDate
| | |-+  Help with loop Categories and sub-categories
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Help with loop Categories and sub-categories  (Read 429 times)
Emanuele
Newbie
*
Offline Offline

Posts: 6


on: Mon, 25. June 2007 - 12:58:10

Hi guys,

i have this problem with loop in my template the categories and sub-categories.

Example whit image categories:



and image sub-categories



Now i use this code PHP in the template but i dont like this....Beacuse is not dinamic for the image in the table menu Sad

Code:
$dati = $connetti->query("SELECT * FROM tbl_blog_categoria WHERE cat_parent_id = 0 ORDER BY cat_ordine");
while($array = $connetti->fetchArray($dati)){
echo"<tr><td height=\"25\" >&nbsp;&nbsp;
<a href=\"?azione=categorie&cat_id=$array[cat_id]\">$array[cat_nome]</a><br></td>";   

 $dati2 = $connetti->query("SELECT * FROM tbl_blog_categoria WHERE cat_parent_id = $array[cat_id]");
 while($array2 = $connetti->fetchArray($dati2)){
 $sottocategoria = substr($array2[cat_nome],0 , $caratteri);
  if($array2[cat_parent_id] == $_GET[cat_id])   
 
 echo"</tr><tr><td height=\"25\" >&nbsp;&nbsp;
 - <a href=\"?azione=categorie&cat_id=$array[cat_id]&categoria=post&parent_id=$array2[cat_id]\">$sottocategoria</a>
 <br></td>" ;

I can make?

Any example

Thanks, sorry for my english


Logged
ClausVB
Administrator
Hero Member
*****
Offline Offline

Posts: 496



WWW
Reply #1 on: Mon, 25. June 2007 - 14:50:29

Your problem does not contain any vlib-question. If you want to change your code please take a look at:

vlibTemplate Documentation
loop.php
nested_loops.php
Nested loops with database records

You have to understand these examples and afterwards you should change your source-code and use vLIB.

If you want to use vLIB it is important you understand how to use Arrays with two or four dimensions.

Regards,
Claus
Logged
Emanuele
Newbie
*
Offline Offline

Posts: 6


Reply #2 on: Tue, 26. June 2007 - 13:07:21

ah ok now i try the new solution for change my php code.

Thanks
Logged
ClausVB
Administrator
Hero Member
*****
Offline Offline

Posts: 496



WWW
Reply #3 on: Tue, 26. June 2007 - 20:33:30

Off-Topic:

Quote
<a href=\"?azione=categorie&cat_id=$array[cat_id]\">

If you have the time, you should think about using mod_rewrite:
- italian tutorial
- english guide

Your URL could look like:
categorie_8.htm
or
categorie_8

But since this is off topic here, this thread will be closed.

Regards,
Claus


Last Edit: Tue, 26. June 2007 - 21:55:03 by ClausVB Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!