In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] says...
> Question 1:
> How can I append strings to my authors array?
> Me thinks this doesn't work :�) ?
> $authors .= explode(";", $mydata->KW);
> I'm getting "Invalid argument supplied for foreach()"
>
> Question 2:
> Once I get this working, I want to (a) alphabetise the contents of the
> array, (b) count repititions, (c) elimintate copies, and create an array
> I can print with tow things "$author[i]\t$counter[i]", so I end up with
> something like:
See the array handling functions to resolve some of these problems.
> Adam 2
> Louis 5
> John 3
> Mary 8
>
> ------------------------------------------------------------------------
>
> $myconnection = mysql_connect($server,$user,$pass);
> mysql_select_db($db,$myconnection);
> $news = mysql_query("select KW from $table");
>
> while ($mydata = mysql_fetch_object($news))
> {
> $authors .= explode(";", $mydata->KW);
Presumably your error is occurring here; it would seem that the content
of $mydata->KW is not such that explode will create an array. There may
be cases perhaps where you do not have a series of authors names
separated by semicolons? You may have to add a test for the case where
$authors is not an array.
> }
>
> foreach ($authors as $author)
> {
> echo "$author<br>\n";
> }
> ------------------------------------------------------------------------
>
> I'm learning, slowly but surely Martin :)
I think this has already been said, but it seems there is scope to
restructure your tables in such a manner as to be able to handle a lot of
these problems with SQL from a properly designed database. Frinstance you
might have a structure that has a main table with a unique ID, the
abstract info, title, publisher etc and a separate table with author name
and ID of the main table entry.
Just at a guess, you are/have imported this information from a
bibliographic package of some sort?
--
David Robley
Temporary Kiwi!
Quod subigo farinam
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php