Previous Thread
Next Thread
Print Thread
Rate Thread
#272513 04/17/2004 9:31 PM
Joined: Apr 2002
Posts: 102
Journeyman
Journeyman
Offline
Joined: Apr 2002
Posts: 102
I'm working on a project and have run into something that for my current level of PHP knowledge, would take me a while to figure out. If you can offer any help/tips it would be much appreciated

Current related code:

[]
$cats = array(1,2);
unset($cats);
$mice = array(1=>array(1,2));
unset($mice[0]);
unset($mice[1]);

// Gather the needed FAQs
$result = mysql_query("SELECT uid,title FROM faq WHERE (is_private = 0 AND approved_date_time = '0000-00-00 00:00:00') || (is_private = 1 AND author_uid = " . $rid . ");");
for ($i = 0; $i < mysql_num_rows($result); $i++) {
list($uid,$title) = mysql_fetch_row($result);
$cats[$uid] = $title;
}

// For each FAQ that was gathered above, get the category_tree_uid
foreach($cats as $key => $value) {
$khalif = mysql_query("SELECT category_tree_uid FROM faq_category WHERE faq_uid = " . $key . ";");
if(mysql_num_rows($khalif)) {
for ($i = 0; $i < mysql_num_rows($khalif); $i++) {
list($category_tree_uid) = mysql_fetch_row($khalif);

// See if the reseller is subscribed to this category
$res = mysql_query("SELECT user_uid FROM user_sub WHERE user_uid = " . $rid . " AND category_tree_uid = " . $category_tree_uid . ";");
if(mysql_num_rows($res)) {
$mice[$category_tree_uid][$key] = $value;
}
}
}
}

$fight = array(1,2);
unset($fight);
foreach($mice as $key => $value) {
$vizier = mysql_query("SELECT name FROM category_tree WHERE uid = " . $key . ";");
list($category) = mysql_fetch_row($vizier);
?>
<h2><?=$category?></h2>
<?
$fight = $value;
foreach($value as $keys => $values) {
$linkme = $keys;
$title = $values;
?>
<a href="display-faq-detail.php?id=<?=$linkme?>"><?=$title?></a><br>
<?
}
}
[/]

Pseudocode I've come up with:

[]
// For each FAQ - We need to load these types of information into array(s)

category_name <- name of the FAQ's parent category
category_tree_uid <- id number for the FAQ's parent category
key <- id number for the specific FAQ
title <- title of the FAQ

// Need to sort individual FAQs by category_name, regardless of it's category_tree_uid

// Need to output each FAQ:
// Display the category_name only once for each group of FAQs with identical category_name
// Print link/title
[/]

Main things are getting the info into arrays, sorting while keeping related data for each FAQ grouped, cycling through array to print out info.

Thanks again for any help.

Sponsored Links
AleksejVL #272514 04/19/2004 5:24 PM
Joined: Apr 2002
Posts: 102
Journeyman
Journeyman
Offline
Joined: Apr 2002
Posts: 102
Nevermind..

AleksejVL #272515 04/23/2004 1:33 PM
Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
cats and mice?


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)