Hello all. I'm hoping to be able to get some help in solving a problem with query/rowcount output. I've been learning PHP and mySQL for about 7 months now and have several successful Mods written/modified for PHP-Fusion CMS version7.00.05. My host is running PHP-5 and MySQL-5. I am converting a Mod from Fusion-ver6 to work on ver-7, called Classified Ads. It has turned out to be a MONSTER to modify and I have run into a snag. There is code that selects ALL the categories and divides them in half displaying half in a table TD and the other half in another TD beside it for a 2 column display. This works just great. What I have is 22 categories and approx. 220 sub-categories. What I am trying to do is display the number of sub-categories below each main category. Here is a pic of the current display with annotations:
I tried using the same code (which works for the main cats), to display the # of sub-cats. It works fine for the first TD but fails in the second TD. I will show the pertinent code rather than posting the entire script, unless requested to do so. Here is the code that produces what you see in the pic:
Code: echo "<table width='100%' border='0' cellspacing='0' cellpadding='3'><tr>n";
$result = dbquery("SELECT * FROM ".DB_CLASSIFIED_CATEGORIES." WHERE status='1' AND parentid=0");
$numrows = dbrows($result);
if($numrows > 0) {
$numrows % 2 ? $numrows += 1 : $numrows;
$rows = $numrows / 2;
echo "<td valign='top' width='50%'>";
$result = dbquery("SELECT cid, title, description, image, parentid FROM ".DB_CLASSIFIED_CATEGORIES." WHERE status='1' AND parentid='0' ORDER BY title LIMIT $rows");
while(list($cid, $title, $description, $image, $parentid) = dbarraynum($result))
{
$count1=dbcount("(*)", $db_prefix."classified", " cid='$cid' AND status='1'");
echo "<table cellspacing='2' cellpadding='1' width='100%' border='0'><tr>n";
echo "<td valign='top' width='100%'>";
if($image) {
echo "<a href='".FUSION_SELF."?op=view_ad&cid=".$cid."'><img src='".INFUSIONS."classified_ads_panel/images/cat/".$image."' alt='".$title."' border='0'></a>(<strong>".$count1." ";
if($count1>1 || $count1<1) {
echo $locale['CLS_0120'];
} else {
echo $locale['CLS_0119'];
}
echo "</strong>)";
} else {
echo "<a href='".FUSION_SELF."?op=view_ad&cid=".$cid."'><strong>".$title."</strong></a>(<strong>".$count1." ";
if($count1>1 || $count1<1) {
echo $locale['CLS_0120'];
} else {
echo $locale['CLS_0119'];
}
echo "</strong>)<br />";
// start here
$subresult = dbquery("SELECT * FROM ".DB_CLASSIFIED_CATEGORIES." WHERE status='1' AND parentid >0");
$myrows = dbrows($subresult);
if($myrows > 0) {
$myrows % 2 ? $myrows += 1 : $myrows;
$subrows = $myrows / 2;
$subresult = dbquery("SELECT cid, title, description, image, parentid FROM ".DB_CLASSIFIED_CATEGORIES." WHERE parentid >0 AND parentid=$cid ORDER BY parentid LIMIT $subrows");
$myrows = dbrows($subresult);
$subrows = $myrows;
}
echo $subrows." sub-categories<br />";
// end here
}
echo "</td>n";
echo "</tr><tr>n";
echo "<td>".$description."</td>n";
echo "</tr></table>n";
}
echo "</td><td valign='top' width='50%'>";
$result1 = dbquery("SELECT cid, title, description, image, parentid FROM ".DB_CLASSIFIED_CATEGORIES." WHERE status='1' AND parentid='0' ORDER BY title LIMIT $rows, $rows");
while(list($cid, $title, $description, $image, $parentid) = dbarraynum($result1))
{
$count1=dbcount("(*)", $db_prefix."classified", " cid='$cid' AND status='1'");
echo "<table cellspacing='2' cellpadding='1' width='100%' border='0'><tr>n";
echo "<td valign='top' width='100%'>";
if($image) {
echo "<a href='".FUSION_SELF."?op=view_ad&cid=".$cid."'><img src='".INFUSIONS."classified_ads_panel/images/cat/".$image."' alt='".$title."' border='0'></a>(<strong>".$count1." ";
if($count1>1 || $count1<1) {
echo $locale['CLS_0120'];
} else {
echo $locale['CLS_0119'];
}
echo "</strong>)";
} else {
echo "<a href='".FUSION_SELF."?op=view_ad&cid=".$cid."'><strong>".$title."</strong></a>(<strong>".$count1." ";
if($count1>1 || $count1<1) {
echo $locale['CLS_0120'];
} else {
echo $locale['CLS_0119'];
}
echo "</strong>)<br />";
// start here
$subresult = dbquery("SELECT cid, title, description, image, parentid FROM ".DB_CLASSIFIED_CATEGORIES." WHERE parentid >0 AND parentid=$cid ORDER BY parentid LIMIT $subrows, $subrows");
$myrows = dbrows($subresult);
$subrows = $myrows;
echo $subrows." sub-categories<br />";
// end here
}
echo "</td>n";
echo "</tr><tr>n";
echo "<td>".$description."</td>n";
echo "</tr></table>n";
}
echo "</td>n";
}
I'm wondering why my added code works OK for the first part but not the second part. Any and all help/suggestions would be GREATLY appreciated
PHP Logging Error
When running the script on website it doesn't copy both input boxes, Only the user and not the password, Any help would be great.. Heres the code, It's suppose to log the username and the password,
Logging and nologging bulk insert
Hi,
If statement help please.
Hello on my site I have 2 content boxes. 1 is for the main content (which is the biggest one) and the second one is for a sub navigation (which is a small box). I am trying to write an IF statement so
Get word number x from string?
How can I use a function to loop through a string, and "have a look at" every word in the string, probably separated by a comma, and print them out, like this:word 1: xxxxword 2: xxxxword 3:
Uploading Filetypes and placing them in seperate folders.
Hello, first post , and asking for help im afraid. Very new to PHP, was making good progress I thought , but im stuck with this part. I have a uploading form that works perfectly and uploads
Something like an INI editor or a DelimitedText-Editor
Hi all,Am very, very, very new to PHP and not sure if I should be posting this to a Javascript or PHP forum so I posed the question on both FORUM.Basically, I am looking for something like an INI
mysqli_fetch_assoc returns multiple arrays, how to return a single array
Hello, I am using mysqli_fetch_assoc which is returning multiple rows, so it looks like:Code: [Select]while($row = mysqli_fetch_assoc($result)) { print_r($row);}But this returns multiple arrays
Date Format
Hi there,I have a date format like this right now:Sat, 17 Oct 2009 17:04:00 I need to turn that into:2009-10-17T17:04:00ZMy thought process was to remove with regex "Sat," and then just
Grouping and sorting results
Please help with this query.I have 2 tables in a database, countires and cities. states looks like thiscountriesid -----------country1 ------------uk2 ------------us3 ------------japancitiesid
Problem in OnClientClick and OnClick sync
Hi,Strange and irritating problem: