Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
probably easy solved problem with list-menu?
Old 12-28-2009, 08:40 PM probably easy solved problem with list-menu?
Novice Talker

Posts: 14
Trades: 0
Hi!

Im using a forum that is called e107 (http://www.e107.org) which is build in php.
Im editing this plugin:
http://plugins.keal.me.uk/plugins/re...nu/recipes.php

and run into a problem.
In the "Select Category" (see picture below) I succeded to list all the posts from a single author instead of categories by editing this code:
Code:
           $recipemenu_selcat = '
            <select class="tbox" name="recipemenu_select" onchange="this.form.submit()">
                <option value="" >' . RCPEMENU_111 . '</option>';
            if ($sql->db_Select('recipemenu_category', '*', ' order by recipe_category_name', 'nowhere', false))
            {
                while ($recipemenu_row = $sql->db_Fetch())
                {
                    extract($recipemenu_row);
                    $recipemenu_selcat .= "<option value='{$recipe_category_id}' ";
                    if ($recipe_category_id == $recipemenu_recipecat)
                    {
                        $recipemenu_selcat .= ' selected="selected"';
                        $recipe_catdesc = $recipe_category_description;
                        $recipemenu_catname = $recipe_category_name;
                        $recipemenu_where = "recipe_category='$recipemenu_recipecat'";
                        if ($recipemenu_row['recipe_category_icon'] && file_exists('images/caticons/' . $recipemenu_row['recipe_category_icon']))
                        {
                            $recipemenu_caticon = '<img src="http://www.webmaster-talk.com/images/caticons/' . $recipemenu_row['recipe_category_icon'] . '" style="border:0;" alt="" />';
                        }
                    }
                    $recipemenu_selcat .= '>' . $tp->toFORM($recipe_category_name) . '</option>';
                } // while
            }
            else
            {
                $recipemenu_selcat .= '<option value="0">' . RCPEMENU_4 . '</option>';
            }
            $recipemenu_selcat .= '</select>';
into:
Code:
// START CODE
            $recipemenu_selcat = '
            <select class="tbox" name="recipemenu_select" onchange="this.form.submit()">
                <option value="" >' . RCPEMENU_111 . '</option>';
            if ($sql->db_Select('recipemenu_recipes', '*', ' order by recipe_author', 'nowhere', false))
            {
                while ($recipemenu_row = $sql->db_Fetch())
                {
                    extract($recipemenu_row);
                    $recipemenu_selcat .= "<option value='{$recipe_author}' ";
                    if ($recipe_author == $recipemenu_recipecat)
                    {
                        $recipemenu_selcat .= ' selected="selected"';
                        $recipe_catdesc = $recipe_author_description;
                        $recipemenu_catname = $recipe_author;
                        $recipemenu_where = "recipe_author='$recipemenu_recipecat'";
                        if ($recipemenu_row['recipe_author_icon'] && file_exists('images/caticons/' . $recipemenu_row['recipe_author_icon']))
                        {
                            $recipemenu_caticon = '<img src="http://www.webmaster-talk.com/images/caticons/' . $recipemenu_row['recipe_author_icon'] . '" style="border:0;" alt="" />';
                        }
                    }
                    $recipemenu_bortmedborjan = explode(".", $recipemenu_row['recipe_author'], 2);
                    $recipemenu_lank = $tp->toFORM($recipemenu_bortmedborjan[1], false);
                    $recipemenu_selcat .= '>' . $recipemenu_lank . '</option>';
                } // while
            }
            else
            {
                $projectmenu_selcat .= '<option value="0">' . RCPEMENU_4 . '</option>';
            }
            $projectmenu_selcat .= '</select>';
// END CODE
what i basically did was to replace the recipe_category with recipe_author.

The function works but the problem is that now I get a list that looks like this:


as you can see the authors are repeating eachother. I just want the different authors to be displayed once.

I was thinking to solve it by count the project_author in the project_author and if they where more than 1 i just displayed one but since im not very good in php I run into problems. This is what I tried anyway:
Code:
$text = "";
$count_project_author = $sql->db_Count("projectmenu_projects", "*", "project_author", ?????);
if($count_project_author > 1)
echo $text;
I know that would never work and the echo text and everything is not the right way but maybe if someone want to help to dig a bit deeper into this?

Heres a picture from the database from phpmyadmin:


thanks a lot! any help what so ever would be very much apreciated!!!
perik is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-29-2009, 03:04 AM Re: probably easy solved problem with list-menu?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
I think it's the db query you need to adapt.
But for that, the signature of $sql->db_Select must be known.

If you want a list of the authors, you want to have a "group by" applied to the sql query to get only the distinct authors.
Something along the lines of:
Code:
select p.project_author
from projectmenu_projects p
group by p.project_author
Maybe this would do the trick:
PHP Code:
$sql->db_Select('recipemenu_recipes''recipe_author''group by recipe_author order by recipe_author''nowhere'false
By the way, why does the query seems to be done in the recipemenu_recipes table, and your screenshot shows the projectmenu_projects table ?
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 12-29-2009 at 03:05 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-29-2009, 04:38 PM Re: probably easy solved problem with list-menu?
Novice Talker

Posts: 14
Trades: 0
solved it by changing:
Code:
    if ($sql->db_Select('projectmenu_projects', '*', ' order by project_author', 'nowhere', false))
to:
Code:
            if ($sql->db_Select('projectmenu_projects', 'project_author', ' GROUP BY project_author', 'nowhere', false))
The whole code is now:
Code:
//FROM
            $projectmenu_selcat = '
			<select class="tbox" name="projectmenu_select" onchange="this.form.submit()">
				<option value="" >' . RCPEMENU_111 . '</option>';
//              if ($sql->db_Select('projectmenu_projects', '*', ' order by project_author', 'nowhere', false))
            
            if ($sql->db_Select('projectmenu_projects', 'project_author', ' GROUP BY project_author', 'nowhere', false))
            {
                while ($projectmenu_row = $sql->db_Fetch())
                {
                    extract($projectmenu_row);
                    $projectmenu_selcat .= "<option value='{$project_author}' ";
                    if ($project_author == $projectmenu_projectcat)
                    {
                        $projectmenu_selcat .= ' selected="selected"';
                        $projectmenu_catname = $project_author;
                        $projectmenu_where = "project_author='$projectmenu_projectcat'";
//            	if ($projectmenu_row['project_author_icon'] && file_exists('images/caticons/' . $projectmenu_row['project_author_icon']))
//            	{
//            	$projectmenu_caticon = '<img src="images/caticons/' . $projectmenu_row['project_author_icon'] . '" style="border:0;" alt="" />';
//          	}
                    }
					$projectmenu_bortmedborjan = explode(".", $projectmenu_row['project_author'], 2);
//					$projectmenu_lank = $tp->toFORM($projectmenu_bortmedborjan[1], false);
                    $projectmenu_selcat .= '>' . $tp->toFORM($projectmenu_bortmedborjan[1], false) . '</option>';
                } // while
            }
// TO
But now I would like to change so I get links instead of <option> menu so it displays like below:
Quote:
Katapult <a href LINK THAT LISTS ALL THE PROJECTS OF THAT USER>
Per <a href LINK THAT LISTS ALL THE PROJECTS OF THAT USER>
User3 <a href LINK THAT LISTS ALL THE PROJECTS OF THAT USER>
User4 <a href LINK THAT LISTS ALL THE PROJECTS OF THAT USER>
and so on ...
so links instead of the users that are displayed in option menu "Show by member:":


any tips how?

By the way in the picture of the phpmyadmin there have been some small namechangnings so just imagine that everywhere it says project there shall be recipe instead.

Thanks a lot!

Per
perik is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to probably easy solved problem with list-menu?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22217 seconds with 12 queries