0

Hi everyone,
I'm trying to tweak some PHP code on my own without the programmer's help... actually it's just an addition that I want.

Basically, I'm trying to enter object_id... into a classes_entered table which has class_id & object_id.
There is also a classes table with class_id and show_id.

I'm trying to insert object_id into one show at a time, by show_id.

So I need a way to enter object_id into the classes entered table but only where the class id is associated with the show_id that is entered into the form.

User can enter the object_id and show_id...

Could someone help me? I feel like this should be easy, but uh... yeah, nope.

}elseif($_POST){
$object_id = $_POST;
$show_id = $_POST;
INSERT INTO classes_entered (class_id, object_id) SELECT class_id FROM shows, WHERE show_id=$show_id")or die("Could not enter show" . mysql_error());


I realize this is most likely horribly wrong. Obviously it doesn't work or I wouldn't be here. But that is what I have so far.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by violaceous
0

This should work:

"INSERT INTO classes_entered (class_id, object_id) VALUES ((SELECT class_id FROM shows WHERE show_id=$show_id limit 1),'$object_id')"

bye :)

-1

Thanks cereal, I actually got this to work last night after a lot of rockstar and forgot to post about it... ;) but if you're willing to help again, could you check out my other post? Having issues with checkboxes!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.