Forum Moderators: coopster
I'm starting a new project which requires an understanding of PHP and MySQL. I know nothing, NOTHING, about either! Please help me get started. What do I need to learn and do? Any help, however small, will be appreciated.
Project Objectives
I have to build a database of coupons and promotions (i.e., sales, clearances, etc.) for online stores. I then have to get them to show on my web site using PHP, looking like this:
<snip>
Note the three different types of coupons/promotions:
1) Coupons with a code
2) Automatic coupons without a code
3) Common sales/clearances
They have different (a) block hyperlink anchor texts and (b) instructions on Line Two.
The expiration information must normally just present the date on which the coupon/promotion will expire. However, the day before one expires, it must say "Tomorrow!" in red font, and on the day that one expires, it must say "Today!" in red font.
Web Site Tabs
The coupons and promotions will be accessible by three tabs:
1) Browse coupons
2) Coupons by Category (drop-down menu)
3) A to Z of Stores
Browse Coupons
This tab will present all of the coupons and promotions, which will be sortable into New (those which have been added in the last three days), Expiring (those which are due to expire in the next three days) and Most Popular (those which have been clicked on the most). Coupons and promotions whose dates have expired must not appear.
Coupons by Category
This tab will be a drop-down menu, listing store categories (e.g., Electronics, Automotive, etc.). If, say, "Automotive" is clicked, the visitor will be shown all the automotive coupons. The coupons shown on category pages won't need the Category link, and must also be sortable into New, Expiring and Most Popular.
A to Z of Stores
This page will be a simple A-to-Z list of all the stores represented on my web site. However, after each store name will be a figure in parentheses reflecting how many coupons there are currently available for it. For example:
Amazon.com (4)
BestFilm.com (2)
CarCovers.com (0)
If a store is clicked, the visitor will be taken to a page where the store is described, which will also present all of the store's coupons. However, these coupons won't need the logo, the About link, or the Category link. When a store's coupons have expired, a message must appear on the store's description page in place of the coupons, saying, "Coupons have expired!"
[edited by: Tehuti at 7:39 pm (utc) on Aug. 27, 2008]
[edited by: eelixduppy at 12:06 am (utc) on Aug. 28, 2008]
[edit reason] no URLs, please [/edit]
I don't think anyone wants to do your entire project for you...and you've got a lot to learn.
I recommend going to w3schools or tizag and reading tutorials on html, php, and mysql before you begin. Asking one question when you're stuck is fine but asking someone to build the site for you for free is another.
StoutFiles: "For starters, you will mainly need an understanding of HTML and probably CSS to do this.I don't think anyone wants to do your entire project for you...and you've got a lot to learn.
I recommend going to w3schools or tizag and reading tutorials on html, php, and mysql before you begin. Asking one question when you're stuck is fine but asking someone to build the site for you for free is another."
I thought someone like you might respond . . .
Firstly, I know how to write XHTML and CSS.
Secondly, I didn't ask anyone to do anything for me. I specifically requested that someone help me get started in learning how to do it myself. Read it back.
What I want to know is - and not from you, StoutFiles - where do I begin? I've looked over the basics of both PHP and MySQL, but I still don't have any idea as to how to start, given the complexity of what I want to achieve.
What type of database tables will I need? And how many, considering the different types of coupons/promotions, and the fact that the coupons/promotions will look different depending on which page they will appear?
Will the expiration information be included in the tables? How will I get expired coupons not to show?
[edited by: tedster at 11:56 pm (utc) on Aug. 30, 2008]
If you've got the 'appearance' side of things down with html and CSS, great. Now forget about that for now.
Forget about how to make the bells and whistles of the appearance as well (Today! Tomorrow! stuff).
In fact, forget all about the web pages for right now and go right back to your base data and get your table design sorted out. If you haven't done any database design before, this is where you will start to struggle.
First lay out all your data in a spreadsheet with your column names across the top of the table, then start to normalise it - you're looking for data that keeps getting repeated in a column that can be split off into a separate table and joined with a relationship between the tables. Look up some tutorials on database design, normalisation and relationships. Get this right from the start or you'll be struggling from then on.
Then you need to learn how to write mysql queries to call the data out of the database. These queries are written into the code of the webpage.
THEN the PHP comes into play to display the results of your queries.
Your display stuff is waaaay down the list after all that.
It's a helluva big curve. If you have any sort of deadline to meet you might be better to look at outsourcing than learning from scratch.
Do a search on this site for threads that recommend some really good books for learning PHP/MySQL. They will make a huge difference to you. Actually, the thread I'm thinking of may be in the library.
Good luck.
hey, hey, hey.. steady on there, Tehuti. Stoutfiles' reply, while not what you wanted to hear, is exactly what a lot of members will be thinking but not even bothering to type, simply from the complexity and size of your question.
I had to explain everything so people could understand the complexity of the project. Otherwise, I might have received advice that would ultimately have been irrelevant or unusable once the logistics of other objectives were considered. The problem is, it seems that - and I thought this might happen - people are seeing my huge post as a massive and audacious cry for free help. Not true . . . I need to learn and do this stuff myself.
I understand where you're coming from, and you have done well to lay it all out pretty clearly - but it kinda pays to play nice around here... catch a lot more flies with honey, y'know?
So where are you getting your data from anyway? Do you have a datafeed from somewhere or are you collecting coupons manually? That's going to have a big influence on your database design right there - if you're getting a datafeed from anywhere you want to dump it in with as little editing as possible. - You'd still be able to ahve all the custom fields you want, but you'd probably put them in an attached table, or at least make sure they're off the end of teh table so you've got a smooth cut/paste option
What type of database tables will I need? And how many, considering the different types of coupons/promotions, and the fact that the coupons/promotions will look different depending on which page they will appear?
How many tables.. for a coupon site, probably surprisingly few, in fact you could probably do it on one table - a 'flat file' design. Depends on how many different sources your coupons are coming from, what sort of categorisation you want to do, all sorts of things. That they will look different on the various pages probably doesn't influence your table design at all.
Will the expiration information be included in the tables? How will I get expired coupons not to show?
Yes, expiration date would definitely be one of your table fields.
Expired coupons will be excluded in your query, which would be something long the lines of, for example, if you wanted to show coupons from Widgetstore in their Bed and Bath category:
SELECT * (wildcard meaning select all data) FROM COUPONS (your table name) WHERE MERCHANT (field name) = "Widgetstore" AND EXPIRYDATE (field name) < TODAY.
That's not correct syntax, but is basically what a mysql query would look like.
Every so often you could go through and just delete expired coupons from your table, or automate a function to do so, but the query is already preventing expired coupons from showing, so there is no urgency there.
*lol* chick.. not dude... chick... and yer welcome.
Oops! Sorry . . . ! Didn't know.
So where are you getting your data from anyway? Do you have a datafeed from somewhere or are you collecting coupons manually? That's going to have a big influence on your database design . . .
I collect the coupons manually.
How many tables.. for a coupon site, probably surprisingly few, in fact you could probably do it on one table - a 'flat file' design. Depends on how many different sources your coupons are coming from, what sort of categorisation you want to do, all sorts of things. That they will look different on the various pages probably doesn't influence your table design at all.
Interesting feedback. It's sounding easier than I originally thought. Thanks!
Yes, expiration date would definitely be one of your table fields.Expired coupons will be excluded in your query . . .
Every so often you could go through and just delete expired coupons from your table, or automate a function to do so, but the query is already preventing expired coupons from showing, so there is no urgency there.
Thanks for that, Deejay! I understand it better now. I thought that I would have to do something really fancy to prevent expired coupons from showing. In fact, it seems that all I will have to do is adjust the PHP query slightly and delete the coupons manually. Cool!
Thanks for your help! I appreciate it.
just realised over lunch I blew that earlier query.. just in that I didn't specify what category, eg, bed and bath, to select.
SELECT * (wildcard meaning select all data) FROM COUPONS (your table name) WHERE MERCHANT (field name) = "Widgetstore" AND CATEGORY (field name) = 'bed and bath' AND EXPIRYDATE (field name) < TODAY.
To give you an example of relationships.. I could just have a single table with a category text field where in every column I enter 'bed and bath' or whatever category that falls into.. or I could (and probably should) split that off into a separate table:
COUPONS table
CouponID
CouponName
CouponMerchant
CouponDescription
CouponLandingURL
CouponExpiry
CouponCategoryID
CATEGORY table
CouponCategoryID
CouponCategory
That's tidier - I only have to type 'bed and bath' once in the category table, minimising the likelihood of typos, and gives me the option of perhaps adding another field to the category table - eg, a supercategory.
BUT it still restricts me to each coupon being shown in one category only - a one : one relationship.
Realistically, I probably want a coupon to be able to show in more than one category, so may be I go to a three table system that allows a many:many relationships, eg:
COUPONS table
CouponID
CouponName
CouponMerchant
CouponDescription
CouponLandingURL
CouponExpiry
COUPONCATEGORY table
CouponID
CategoryID
CATEGORY table
CouponCategoryID
CouponCategory
... in that layout a coupon could easily be entered into, say, both the 'bed and bath' category and the 'gifts for her' category.
See where I'm going?
Anyways. There's a kickstart for you. Now go forth and conquer