pp wrote:

> > >             $topics   = $topicid->id;
> > >             $name     = $article->title;
> > 
> > Don't you want $name = $article->name here?
>
> hmmmm...... article i get has empty name so I thought I can force cretae
> name from title

You can, I was just wondering whether this wasn't a cut-and-paste
error.

> > > And creates articles anyway. Nevermind if $article_created exists.
> > > Why it works for topics but not for articles?
> > 
> > The above code fetches the first article, compares the title (not
> > name) and creates it. If you want to prevent duplicates you'll have to
> > go through the entire fetch to determine if the name allready exists.
> 
> Would You write more "readable" version? I can really hardly understand
> it.

Let's say you have 3 articles, assuming name==title everywhere:
art1, art2, art3

Let's say you want to create an article with name 'art2'.
The code above would fetch art1, compare titles, which will differ, and create
the new article. You now have two articles with name=art2.

In order to make sure no duplicates for an article with name $newname will exist,
you'll need:

$arts = mgd_list_topic_articles($topicid);
$duplicate = 0;
while (!$duplicate && $arts && $arts->fetch()) {
   $duplicate = ($arts->name == $newname);
}

if ($duplicate) { echo "Don't think so Jose"; }
else { /* create article here */ }

Emile


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to