|
Posted by guitarromantic on 11/19/72 11:47
Jerry Stuckle wrote:
> Well, you can also get the name of all values from the $_POST array, i.e.
>
> foreach ($_POST as $key->$value) {
Ahh, thanks again. One last question:
When I post the final values to my database, I need to split them up.
Say I enter 3 authors and 3 individual scores and reviews, I need to
save them concurrently. What I've just done is coded a query to insert
the data that applies to all the multiple-author reviews (eg, band
name, record label, etc) into the main reviews table. I also assigned
that row a "review_type" of '3' which tells me it's a multiple review.
What I wanna do to display a review is test for type, if "3", then
search in table multiple_reviews for all occurences of whatever $id
review I'm displaying.
After my code to insert these common variables into the db, I then pull
out the most recent $id entered into the reviews table, and store that
as the $id for the new row being saved in multiple_reviews, with the
intention of storing like so:
table: reviews
id: 1234
artist_name: The Beatles
album_name: Let It Be
record_label: Apple
author_id: (left blank)
review: (left blank)
score: (left blank)
review_type: 3
table: multiple reviews
id: 1234
author_id: 34
score: 7
review: blah blah
id: 1234
author_id: 67
score: 8
review: blah blah BLAH
etc. I hope that wasn't too insulting to your intelligence..
Anyway, my issue is, for the INSERT to get that info into the second
table, how can I grab each element of the array? As you've probably
gathered, I'm new to php (I could probably do this in Java, though..)
and all I've got so far is:
foreach ($author as $value) {
echo "$value";
}
which just prints out each element of the array. How can I make an
insert query that'll populate the tables as outlined above (with the
last three rows mentioned all being arrays)?
Navigation:
[Reply to this message]
|