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.

Recommended Answers

All 2 Replies

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 :)

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.