|
Posted by guitarromantic on 11/19/82 11:47
Jerry Stuckle wrote:
> First of all, don't store review_type. You can find out if it has multiple
> reviews by a simple
>
> SELECT COUNT(*) FROM multip_reviews WHERE id='1234'
My reason for using review_type is that we already have a secondary
review type (in this case it uses the same database structure, only the
review body is part of our "200 words or less" feature, and I like to
mark that visually on the review index).
> As for inserting multiple values, it's pretty simple. You need to build the
> query in your foreach loop. First you need to get all of your variables for a
> single review into an array, i.e. assuming you have your form fields as author1,
> author2, score1, score2 and review1, review2, etc.: (warning - not tested)
Apologies if this is a stupid question, but would this method only
allow 2 authors to be used when adding a review? Occasionally we use 3,
there's no single number. Just so I can get my head around this, what
are the numbers 5 and 6 doing in that code?
> Now that the data is sorted, you can build an insert VALUES clause ($id has the
> review id)
>
> $insert = '';
> foreach($data as $value) {
> if ($insert != '') // add a comma if not the first one
> $insert .= ', ';
> $insert .= "($id, $value['author'], $value['score'], '$value['review'])";
Using this code I get a "Parse error: syntax error, unexpected
T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or
T_NUM_STRING" on the final line of the above code. I took out the ' by
$value, same result.
Thanks again for all the help thus far, I'll have to credit you
somewhere on the site (scenepointblank.com) when this eventually goes
live!
Matt
Navigation:
[Reply to this message]
|