|
Posted by kenoli on 10/21/06 19:52
Yes. I think I get your concept. I can do a lookup based on keyword
input from the form in the keyword table to get the appropriate keyword
Ideas, match them to person ids in the linking table and them retrieve
those person records from the person table using those ids. I'll get
into it. What I like is the many-to-many approach.
A big advantage here is that if I make changes to the keywords, it
applies to all referenced records via the linking table.
Do I get the concept?
--kenoli
Koncept wrote:
> In article <1161429049.560461.21980@i42g2000cwa.googlegroups.com>,
> kenoli <kenoli@igc.org> wrote:
>
> > As usual, a thoughtful reply. What I think is being done here, however
> > is that you are getting a list of keywords associated with a person.
> > What I want to do, however, is rhe opposite. People will select a
> > group of keywords using, say, checkboxes identified with keywords from
> > a lookup table and on submit I will want to return data for all the
> > persons associates with any selected keyword. Something that does
> > something like:
> >
> > SELECT * FROM persons WHERE keyword=keyword1 OR keyword=keyword 2 OR
> > keyword=keyword3 etc.
> >
> > I know this isn't a correct query, but it illustrates conceptually what
> > I will want to do.
> >
> > --Kenoli
>
> Ahhh. Gotcha. How's something like this?
>
> <?php $r = range(1,10) ?>
> <form action="<?=basename($_SERVER['PHP_SELF'])?>" method="post">
> <?php foreach($r as $i): ?>
> <input type="checkbox" name="keywords[kw<?=$i?>]" value="on"
> id="kw<?=$i?>" />Keyword <?=$i?><br />
> <?php endforeach ?>
> <input type="submit" value="Submit" />
> </form>
> <?php
> // What the form got
> printf("<pre>%s</pre>",htmlentities(print_r($_POST,true)));
> ?>
> <code>
> <?php
> if($_POST['keywords']):
> // dump mySQL statement
> $sql = "SELECT * FROM persons WHERE";
> // Obviously, this is ripe for SQL poisoning right now, but just to
> offer a solution.
> // Make sure to properly prepare and check your values
> echo $sql ." keyword='".join("' or keyword='",
> array_keys($_POST['keywords']))."';";
> endif;
> ?>
> </code>
>
> --
> Koncept <<
> "The snake that cannot shed its skin perishes. So do the spirits who are
> prevented from changing their opinions; they cease to be a spirit." -Nietzsche
Navigation:
[Reply to this message]
|