First thing I would do, is make sure you are cleaning your input data before using it in an sql query, to avoid sql injection hacks. I'm not an expert on the subject, but I know it has to be done. Maybe someone else on this forum could help you, or you could search for tips on how to protect your queries.
As far as the query goes: Maybe you could do a join on your cards table and your user inventory. Using phpmyadmin, first write the join to include all cards in a deck, and only include user_inventory data if that user has a card in the deck. This would be handled with a left join, where the table in the select statement is cards and the table in the join statement is user_inventory.
I'm not writing out sql for you, because you can do it yourself and check for errors in phpmyadmin, and because you're not going to learn if you just use someone else's sql without knowing exactly what it does.
The next step, once you have that working correctly, is to add a line to the previous query where user_id = NULL. This will leave out any cards that the user has in the inventory. Now, put this code in your php file, and execute it, using print_r to display results. If it works, now you can loop through these results and add them to the user_inventory.