How about:

        while ($mydata = mysql_fetch_object($news))
        {       $mydata->AUS = str_replace(" ;", ";", $mydata->AUS);
        $mydata->AUS = str_replace("; ", ";", $mydata->AUS);
        $tempauthors = explode(";", $mydata->AUS);
        foreach ($tempauthors as $singleauthor)
        {       if ($singleauthor <> "")
                $authors[$singleauthor][] = $mydate->id;
                }
        }

        ksort($authors);
        foreach ($authors as $author=>$ids)
        {       echo "<a
href=\"match.php?searchenquiry=".urlencode($author)."&match=partial+match\">
");
        echo($author."</a>");
        echo("(". count[$ids] .") [");
        foreach ($ids as $id) echo($id); // need something a bit fancier
here, but you get the idea
        echo("]<br>\n");
        }


Tim Ward
Internet chess www.chessish.com <http://www.chessish.com> 


        ----------
        From:  jtjohnston [SMTP:[EMAIL PROTECTED]]
        Sent:  04 March 2002 23:55
        To:  [EMAIL PROTECTED]
        Subject:  Re: [PHP] Does anyone follow?

        Can you show me how :) ? I'm in over my head.
        I get working with arrays, but need more practice,
        examples etc. to learn how to code from. How would two arays work?
        John


        > Does anyone follow what I'm trying to do?
        >
        > I have a list of authors I explode from a field called AUS. I sort
them
        > sort($authors);
        >
        > The layout is agreeable. What I would like now to do is change:
        >
        >    array_push($authors,$singleauthor);
        >
        > for
        >
        >    array_push($authors,$singleauthor,$mydata->id);
        >
        > But how do I sort them now? These two lines permitted me to:
        >
        > sort($authors);
        > foreach (array_count_values ($authors) as $author=>$count)
        >
        > sort, count and display each occurence only once.
        >
        > O'Henry, James (5)  #<--- there were 5 occurences of O'Henry in my
        > database explode
        >
        > Now what I want to do is display the id number (record number) of
each
        > occurence of O'Henry:
        >
        > O'Henry, James (5) [record 1, record 4, record, 87, record 119,
record
        > 120]
        >
        > How do I re-evaluate this code, modify it to display authors one
time
        > only,
        > count the number of occurences in my database
        > and somehow integrate $mydata->id  ?
        >
        > Does anyone follow what I'm trying to do?
        >
        > ------------------snip-----------------------------------
        > $myconnection = mysql_connect($server,$user,$pass);
        > mysql_select_db($db,$myconnection);
        >
        > $news = mysql_query("select id,AUS from $table");
        >
        > $authors = array();
        >
        > while ($mydata = mysql_fetch_object($news))
        > {
        > $mydata->AUS = str_replace(" ;", ";", $mydata->AUS);
        > $mydata->AUS = str_replace("; ", ";", $mydata->AUS);
        > $tempauthors = explode(";", $mydata->AUS);
        >  foreach ($tempauthors as $singleauthor)
        >   {
        >    if ($singleauthor <> "")
        >    array_push($authors,$singleauthor);
        >   }
        >  }
        >
        > sort($authors);
        > foreach (array_count_values ($authors) as $author=>$count)
        > {
        > echo "<a
        >
href=\"match.php?searchenquiry=".urlencode($author)."&match=partial+match\">
        > ".$author."</a>
        > (".$count.")<br>\n";
        > }
        >
        > mysql_close($myconnection);
        

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to