Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Multiple Categories and parent categories

Locked Asked Modified Viewed 4,670 times
A
afaaro
A
afaaro 10
  • Senior Member, joined since
  • Contributed 295 posts on the community forums.
  • Started 68 threads in the forums
  • Started this discussions
asked
Senior Member

Hi

I have multiple categories and parent categories but need to get 1 category and it's parent categories and how this is the link : http://hamarey.com/infusions/node/pag...categories
0 replies

11 posts

F
Falk
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
answered
Super Admin

$category = " get / post / result etc ";
$result = dbquery("SELECT * FROM ".DB_TABLE." WHERE parentid='".$category."'");


0 replies
A
afaaro
A
afaaro 10
  • Senior Member, joined since
  • Contributed 295 posts on the community forums.
  • Started 68 threads in the forums
  • Started this discussions
answered
Senior Member

Hi Domi

I tried this but it isn't working.


   echo "News";
     $category = dbquery("SELECT * FROM ".$db_prefix."nodeObject WHERE category=57");
     $result = dbquery("SELECT o.name name, o.image image, o.type type, o.link link, o.id id, o.date, o.category, c.id catid, c.name catname FROM ".$db_prefix."nodeObject o LEFT JOIN ".$db_prefix."nodeCategory c ON c.id=o.category WHERE c.parent='".$category."' ORDER BY date DESC LIMIT 20");
     $rows = dbcount("(id)", "".$db_prefix."nodeObject");
     if ($rows != 0) {
       echo "<div class='news'>";
         while ($data = dbarray($result)) {
           echo "<div class='row'>";
           if ($data['image']) {
             $image = "<a href='node.php?cat_id=".$data['catid']."&amp;id=".$data['id']."'><img src='".INFUSIONS."node/uploads/".$data['image']."'></a>";
           }elseif ($data['link']) {
             $image = "<a href='node.php?cat_id=".$data['catid']."&amp;id=".$data['id']."'><img src='".parse_youtube_url($data['link'],'thumb')."' /></a>";
           } else {
             $image = "<a href='node.php?cat_id=".$data['catid']."&amp;id=".$data['id']."'><img src='".INFUSIONS."node/images/nophoto.jpg' /></a>";
           }
           echo $image;
           echo "<a class='gridtitle' href='node.php?cat_id=".$data['catid']."&amp;id=".$data['id']."'>".trimlink($data['name'],30)."</a>";
           echo "</div>";
         }
       echo "</div>";
     }



I need to get contents from these categories and it's parents

Quote


Category: 57
---- Parent: 58
---- Parent: 59
---- Parent: 60
---- Parent: 61

Edited by afaaro on 27-10-2013 21:44,
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

If you are taking in just category 57, 58, 58, 60, 61 permanently, then


define("NODE", ".$db_prefix."nodeObject);
$result57 = dbquery("SELECT * FROM ".NODE." where category='57');
$result58 = dbquery("SELECT * FROM ".NODE." where category='58');
$result59 = dbquery("SELECT * FROM ".NODE." where category='59');
$result60 = dbquery("SELECT * FROM ".NODE." where category='60');
$result61 = dbquery("SELECT * FROM ".NODE." where category='61');

$data57 = dbarray($result57);
$data58 = dbarray($result58);
$data59 = dbarray($result59);
$data60 = dbarray($result60);
$data61 = dbarray($result61);


1. You never show how he SQL table is designed. I cannot relate with a query.
2. Permanent query or dynamic query?

You said you want Category: 57, 58, 59, 60 and 61 only.

Only after you show me the SQL table info, then only I can help better.
0 replies
A
afaaro
A
afaaro 10
  • Senior Member, joined since
  • Contributed 295 posts on the community forums.
  • Started 68 threads in the forums
  • Started this discussions
answered
Senior Member

I tried this
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]


$data1 = dbarray(dbquery("SELECT * FROM ".$db_prefix."nodeCategory WHERE parent='1'"wink);
$data2 = dbquery("SELECT * FROM ".$db_prefix."nodeCategory WHERE parent='".$data1['parent']."'"wink;
while($row = dbarray($data2)){
echo "<h3>{$row['name']}</h3>";
$result = dbquery("SELECT o.name name, o.image image, o.type type, o.link link, o.id id, o.date, o.category, c.id catid, c.name catname FROM ".$db_prefix."nodeObject o LEFT JOIN ".$db_prefix."nodeCategory c ON c.id=o.category WHERE o.category='".$row['id']."' ORDER BY date DESC LIMIT 30"wink;
echo "<div class='muxaadaro'>";
while($row2 = dbarray($result)){
echo "<div class='grid'>";
if ($row2['image']) {
$image = "<a href='node.php?cat_id=".$row2['catid']."&amp;id=".$row2['id']."'><img src='".INFUSIONS."node/uploads/".$row2['image']."'></a>";
}elseif ($data['link']) {
$image = "<a href='node.php?cat_id=".$row2['catid']."&amp;id=".$row2['id']."'><img src='".parse_youtube_url($row2['link'],'thumb'wink."' /></a>";
} else {
$image = "<a href='node.php?cat_id=".$row2['catid']."&amp;id=".$data['id']."'><img src='".INFUSIONS."node/images/nophoto.jpg' /></a>";
}
echo $image;
echo "<a class='gridtitle' href='node.php?cat_id=".$row2['catid']."&amp;id=".$row2['id']."'>".trimlink($row2['name'],30)."</a><br>".$row2['catname'];
echo "</div>";
}
echo "</div>";
}
[/syntaxhighlighter]

and this what comes up http://hamarey.com/infusions/node/pag...=muxaadaro
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Likewise, I need to see your SQL record. Like this:

Database Nodeobject

ID | Name | Category | Access | <--- column name needed
-------------------------------------
1 Record A 0 0 <---- records.
2 Record B 1 0
3 Record C 1 0
0 replies
A
afaaro
A
afaaro 10
  • Senior Member, joined since
  • Contributed 295 posts on the community forums.
  • Started 68 threads in the forums
  • Started this discussions
answered
Senior Member

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]

$inf_newtable[1] = "".$db_prefix."nodeCategory (
id int(11) unsigned NOT NULL auto_increment,
name varchar(255) NOT NULL default '',
parent int(11) NOT NULL default '0',
body text NOT NULL,
image varchar(255) NOT NULL default '',
count int(11) NOT NULL,
locked int(11) NOT NULL default '0',
access int(1) NOT NULL default '0',
PRIMARY KEY (id)
) ENGINE=MyISAM;";

$inf_newtable[2] = "".$db_prefix."nodeObject (
id int(10) unsigned NOT NULL auto_increment,
name varchar(255) NOT NULL default '',
category int(10) NOT NULL default '0',
type enum('news','video','audio'wink NOT NULL default 'news',
link varchar(255) NOT NULL default '',
body text NOT NULL,
image varchar(255) NOT NULL default '',
date int(10) UNSIGNED NOT NULL DEFAULT '0',
author int(10) UNSIGNED NOT NULL DEFAULT '1',
count int(10) NOT NULL,
locked int(10) NOT NULL default '0',
access int(1) NOT NULL default '0',
PRIMARY KEY (id)
) ENGINE=MyISAM;";
[/syntaxhighlighter]

Merged on Oct 28 2013 at 00:50:26:
Its unlimited categories and sub - sub -sub

Merged on Oct 28 2013 at 00:52:53:
hamarey.com/categories.gif
Edited by afaaro on 28-10-2013 02:52,
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Quote

afaaro wrote:

I tried this
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]


$data1 = dbarray(dbquery("SELECT * FROM ".$db_prefix."nodeCategory WHERE parent='1'"));
$data2 = dbquery("SELECT * FROM ".$db_prefix."nodeCategory WHERE parent='".$data1['parent']."'");
while($row = dbarray($data2)){
echo "<h3>{$row['name']}</h3>";
$result = dbquery("SELECT o.name name, o.image image, o.type type, o.link link, o.id id, o.date, o.category, c.id catid, c.name catname FROM ".$db_prefix."nodeObject o LEFT JOIN ".$db_prefix."nodeCategory c ON c.id=o.category WHERE o.category='".$row['id']."' ORDER BY date DESC LIMIT 30");
echo "<div class='muxaadaro'>";
while($row2 = dbarray($result)){
echo "<div class='grid'>";
if ($row2['image']) {
$image = "<a href='node.php?cat_id=".$row2['catid']."&amp;id=".$row2['id']."'><img src='".INFUSIONS."node/uploads/".$row2['image']."'></a>";
}elseif ($data['link']) {
$image = "<a href='node.php?cat_id=".$row2['catid']."&amp;id=".$row2['id']."'><img src='".parse_youtube_url($row2['link'],'thumb')."' /></a>";
} else {
$image = "<a href='node.php?cat_id=".$row2['catid']."&amp;id=".$data['id']."'><img src='".INFUSIONS."node/images/nophoto.jpg' /></a>";
}
echo $image;
echo "<a class='gridtitle' href='node.php?cat_id=".$row2['catid']."&amp;id=".$row2['id']."'>".trimlink($row2['name'],30)."</a><br>".$row2['catname'];
echo "</div>";
}
echo "</div>";
}
[/syntaxhighlighter]

and this what comes up http://hamarey.com/infusions/node/pag...=muxaadaro


Did this solve your problem?
0 replies
A
afaaro
A
afaaro 10
  • Senior Member, joined since
  • Contributed 295 posts on the community forums.
  • Started 68 threads in the forums
  • Started this discussions
answered
Senior Member

No. I just wanted to join all together instead of like Glossary
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Do you have skype? Add me : "hien.phpfusion". I need to interview in what you need so I can help you finish this.

Merged on Oct 28 2013 at 01:23:35:
I take an example:

Usually it's top-down... like

Muxaadarooyinka - Parent
-- Sheekh Cabdi - Child to Muxa
--- Bidcada & Raadka xun - Child to Sheekh
--- Caalimka - Child to Sheekh

If I browse to Muxa, can I see Muxa, Sheekh, Bidcada and Caalimka?
Edited by Chan on 28-10-2013 03:26,
0 replies
A
afaaro
A
afaaro 10
  • Senior Member, joined since
  • Contributed 295 posts on the community forums.
  • Started 68 threads in the forums
  • Started this discussions
answered
Senior Member

Hien you are amazing and it's really working
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

You're welcome. Thank you for using Php-Fusion.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 11 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

F
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
A
A
afaaro 10
  • Senior Member, joined since
  • Contributed 295 posts on the community forums.
  • Started 68 threads in the forums
  • Started this discussions
C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet