I have a problem regarding PHP/MySQL.
I’ve been learning PHP, along with HTML/CSS/jQuery (jQuery just started), for a month now, without any prior programming/markup experience, so be soft here.
Anyways, I’ve come across a problem I can’t solve and I’d be grateful if someone here can solve it for me. I have a leaning more towards the front-end development, so I kinda suck at PHP (haven’t really done anything in more than a week), but I would like to know the basics at least. Hope someone answers, thank you in advance.
Let’s say we have a database called ‘store’, a table called ‘movies’ and a table called ‘reservations’. I need to create a .php page with movie titles (let’s say the column is named ‘movienames’) sorted alphabetically, for example:
American History X
I should create a link on every title that leads to another page we can call ‘reservations.php’. There, we should list the schedule of reservations for a certain movie. Obviously, there should be a primary key (‘movienames’) from movies in ‘reservations’ as a secondary key. We should also have a date column, let’s call it ‘resDate’ and one more secondary key from another table (video store users for example) we can call ‘users’. We should format it like this:
That’s basically it, I should also have a link on ‘reservations.php’ that leads to the main page we can call ‘index.php’.
P.S. I’m sure it’s an easy task for you, but I’m really awful at PHP and I neglect it whenever I can.
Sure, take it slow and one step at a time.
Create your database, add your tables and fields with some sample data.
Create a user and password for this user with permission to access this database.
Decide on the method to connect to the database. Might I suggest PDO.
Make a test page and add connection script. Once you get that working you can make it your conn.php page that you include on all your pages.
Make a page and work on accessing your tables.
Once you have these first steps working, you can focus on making the project.
For any of these steps you will find lots of examples on the web, just steer clear of mysql as it’s depreciated.
I’m not sure what problem you’re having there - you’ve described what you want to do, but not what’s causing the problem. Yes, you’d have a primary key in the movies table and a column for it in the reservations table (don’t use the movie name, way too complicated if you mis-spell something after you’ve created loads of reservations, for one thing), so your link from the movie titles list will take you to a page that lists all reservations for that movie-id where resdate is later than today (presumably).
Like Drummin said, just work through it step by step and come back if you hit any specific issues. You’ll want to look at paginating the data as well, once you’ve got more than 30-odd movies in the database a single page listing them all won’t be very nice. Also consider an “alternate” title field, as I had in a books database I was using for a similar learning exercise - otherwise you’ll have lots of titles starting with “The” or “A” that don’t really belong together.