Making webpages using PHP/MySQL?
Moderator: General Moderators
-
snappydesigns
- Forum Commoner
- Posts: 28
- Joined: Tue Feb 13, 2007 11:37 am
Making webpages using PHP/MySQL?
Hi,
I'm new here and quite new to this world. I've researched PHP & MySQL and have only scratched the surface on what they can do. I will say that I have been able to set up PHP order/contact forms (YAY for me), but that's as far as my experience goes.
The project at hand for me is to take hundreds (maybe even thousands) of stationery products (invitations, notecards, labels, etc.) and to put them on a website for customers to view and order. Of course, I could design a page for each product, but after doing this 50 times with no end in sight I know there must be a better way.
Here's the goal: When a customer clicks on a category, a thumbnails page is brought up with each product in that category. The customer will then click on a thumbnail which will then go to the individual product page that has the larger image to view, price, product info, color choices, and a short order form specific to the product to be emailed to the seller (at this point, there no shopping cart or anything). Basically, this is what the seller wants to be able to do: http://www.groovypaper.com/detail.asp?c ... 00&PID=268
Here's my client's website (still a major work in progress): http://www.twinpapers.com
Can anyone guide me through this or give me resources on where to begin with this task? I would want to be able to use PHP to make thumbnails pages for each category and individual product pages. I suppose I would need to set up a database (MySQL possibly) with all the product info. I have searched and searched but have not found any information close enough to what I'm trying to do.
Many thanks to anyone who would be willing to help!
Jen H.
I'm new here and quite new to this world. I've researched PHP & MySQL and have only scratched the surface on what they can do. I will say that I have been able to set up PHP order/contact forms (YAY for me), but that's as far as my experience goes.
The project at hand for me is to take hundreds (maybe even thousands) of stationery products (invitations, notecards, labels, etc.) and to put them on a website for customers to view and order. Of course, I could design a page for each product, but after doing this 50 times with no end in sight I know there must be a better way.
Here's the goal: When a customer clicks on a category, a thumbnails page is brought up with each product in that category. The customer will then click on a thumbnail which will then go to the individual product page that has the larger image to view, price, product info, color choices, and a short order form specific to the product to be emailed to the seller (at this point, there no shopping cart or anything). Basically, this is what the seller wants to be able to do: http://www.groovypaper.com/detail.asp?c ... 00&PID=268
Here's my client's website (still a major work in progress): http://www.twinpapers.com
Can anyone guide me through this or give me resources on where to begin with this task? I would want to be able to use PHP to make thumbnails pages for each category and individual product pages. I suppose I would need to set up a database (MySQL possibly) with all the product info. I have searched and searched but have not found any information close enough to what I'm trying to do.
Many thanks to anyone who would be willing to help!
Jen H.
Phew. This is quite an undertaking for your apparent knowledge level. Let me see if I can summarize what you want to have:
A category page: This doesn't necessarily require a database, but it's probably your best bet. You should set up a database with 1 table that holds all your categories & their information (category id, human readable name, etc)
A 2nd product page with all the products in a category: Again - you should use a database. Add a table to your database that holds all your products. In that table, store the id of the category it's part of, the URL to the thumbnail, and any other information that you have about the product
Thumbnails of the products: This will involve working with either GD (which will have to be compiled into your PHP installation), or ImageMagik (which doesn't require a recompilation).
An order form: You said you know how to do this so I won't get into it.
This isn't a particularly simple or small project for someone new to PHP & MySQL. I recommend you get yourself acquainted with PHP/MySQL integration (write something simple that requires passing queries to MySQL & reading the results). It would also be advisable to play around with whichever image library you want to work with before you try & go whole hog into the project. Search these forums (& Google for that matter) for something along the lines of "PHP thumbnails". There's bound to be some tutorials out there.
In short, break this project up into smaller projects you can learn from (and ask accurate questions on). Once you've got a good handle on what you need to do, start plugging away at the main project.
Good luck, & welcome to PHPDN!
A category page: This doesn't necessarily require a database, but it's probably your best bet. You should set up a database with 1 table that holds all your categories & their information (category id, human readable name, etc)
A 2nd product page with all the products in a category: Again - you should use a database. Add a table to your database that holds all your products. In that table, store the id of the category it's part of, the URL to the thumbnail, and any other information that you have about the product
Thumbnails of the products: This will involve working with either GD (which will have to be compiled into your PHP installation), or ImageMagik (which doesn't require a recompilation).
An order form: You said you know how to do this so I won't get into it.
This isn't a particularly simple or small project for someone new to PHP & MySQL. I recommend you get yourself acquainted with PHP/MySQL integration (write something simple that requires passing queries to MySQL & reading the results). It would also be advisable to play around with whichever image library you want to work with before you try & go whole hog into the project. Search these forums (& Google for that matter) for something along the lines of "PHP thumbnails". There's bound to be some tutorials out there.
In short, break this project up into smaller projects you can learn from (and ask accurate questions on). Once you've got a good handle on what you need to do, start plugging away at the main project.
Good luck, & welcome to PHPDN!
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
snappydesigns
- Forum Commoner
- Posts: 28
- Joined: Tue Feb 13, 2007 11:37 am
Hey pickle-
Thanks for taking the time to read through my lengthy situation and respond with suggestions. Yes, I totally realize that I have lots to learn and set up. I've seen people mention that there are ways to import excel data into MySQL database tables. So for now, I'm going to set up simple tables in Excel that have product names, item numbers, image names, thumbnail names, vendor name, etc for as many products as I can. The nice thing is that a few of the vendors have already set up basic information in Excel that I just can copy and paste.
I did find a short tutorial in my only PHP/MySQL book (one of those Visual QuickPRO Guides) that actually outlines much of what I need to do. I suppose I will just work slowly on this and then ask questions in increments--like you suggested
.
Thanks again! It's good to know that I'm not just being blown off because of my vast lack of knowledge here. I'll just learn as I go.
Jen
Thanks for taking the time to read through my lengthy situation and respond with suggestions. Yes, I totally realize that I have lots to learn and set up. I've seen people mention that there are ways to import excel data into MySQL database tables. So for now, I'm going to set up simple tables in Excel that have product names, item numbers, image names, thumbnail names, vendor name, etc for as many products as I can. The nice thing is that a few of the vendors have already set up basic information in Excel that I just can copy and paste.
I did find a short tutorial in my only PHP/MySQL book (one of those Visual QuickPRO Guides) that actually outlines much of what I need to do. I suppose I will just work slowly on this and then ask questions in increments--like you suggested
Thanks again! It's good to know that I'm not just being blown off because of my vast lack of knowledge here. I'll just learn as I go.
Jen
Excel spreadsheets cannot be directly imported into MySQL tables. To the best of my knowledge, the closest you can get is having Excel save the spreadsheet as a comma separated version (CSV). Then you'll have to write a script to open the CSV file, dynamically create queries to insert the data, then execute those queries. Or, you'll have to set up phpMyAdmin to do the import for you. Ideally, you could set up a back-end to the system that would allow you to, through a web page, add the data directly to your tables using PHP.
Unless you need to start collecting data right now, I'd start playing around with setting up the back end & leave the data collection until a later point. It's actually a pretty simple concept. Since you already know how to make forms & submit them, the next step is to take the data submitted in said form & put it in the database.
We in the forums pride ourselves on helping those that help themselves - skill level doesn't really matter as long as the person appears to be making an attempt to learn. You are, so I'm happy to help
Unless you need to start collecting data right now, I'd start playing around with setting up the back end & leave the data collection until a later point. It's actually a pretty simple concept. Since you already know how to make forms & submit them, the next step is to take the data submitted in said form & put it in the database.
We in the forums pride ourselves on helping those that help themselves - skill level doesn't really matter as long as the person appears to be making an attempt to learn. You are, so I'm happy to help
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Do you have Apache, MySQL and PHP installed on your local computer? If not, I would recommend you start with that.
Then I would move on to creating your tables for housing the data you plan to serve. Do this on your local machine. Then start working on the code to talk to the database. Do this on your local machine as well. Continue to develop and test on your local machine, including all the data entry, then, when things seems to work in your local development environment, push them into production.
What you want to do is fairly common and fairly simple. It is not easy work (it will be time consuming) but it is certainly achievable with PHP and MySQL. And it will be a great learning experience.
Then I would move on to creating your tables for housing the data you plan to serve. Do this on your local machine. Then start working on the code to talk to the database. Do this on your local machine as well. Continue to develop and test on your local machine, including all the data entry, then, when things seems to work in your local development environment, push them into production.
What you want to do is fairly common and fairly simple. It is not easy work (it will be time consuming) but it is certainly achievable with PHP and MySQL. And it will be a great learning experience.
-
snappydesigns
- Forum Commoner
- Posts: 28
- Joined: Tue Feb 13, 2007 11:37 am
Thanks so much for the info.
pickle-
I figured out how to get an excel table exported into a MySQL table. I used your suggestion of saving the Excel doc as .csv. Then went to phpMyAdmin to import it--worked like a charm. It took a few attempts, but now I've got the hang of it. I mainly wanted to have a solid set of data to work with and didn't want to type all that in MySQL by hand (since someone already went through the trouble of typing most of it into Excel).
Everah-
The webhost that the client uses (Dream Host) has phpMyAdmin set up for all the databases. What would be the advantage of installing the programs on my local computer rather than working with the phpMyAdmin directly on the server and using Notepad to write the php files? I did install MySQL to see how to use it. I found that phpMyAdmin is much more user friendly for someone like me (who's very new to this).
For now, I'm going to do some research of making the thumbnails page. Any suggestions or resources you can recommend for this task?
I can't thank you enough for the help I've received already. You'll probably be seeing me a lot around here
.
Jen
pickle-
I figured out how to get an excel table exported into a MySQL table. I used your suggestion of saving the Excel doc as .csv. Then went to phpMyAdmin to import it--worked like a charm. It took a few attempts, but now I've got the hang of it. I mainly wanted to have a solid set of data to work with and didn't want to type all that in MySQL by hand (since someone already went through the trouble of typing most of it into Excel).
Everah-
The webhost that the client uses (Dream Host) has phpMyAdmin set up for all the databases. What would be the advantage of installing the programs on my local computer rather than working with the phpMyAdmin directly on the server and using Notepad to write the php files? I did install MySQL to see how to use it. I found that phpMyAdmin is much more user friendly for someone like me (who's very new to this).
For now, I'm going to do some research of making the thumbnails page. Any suggestions or resources you can recommend for this task?
I can't thank you enough for the help I've received already. You'll probably be seeing me a lot around here
Jen
Well, since phpMyAdmin is already set up, it makes sense to make up the Excel spreadsheets.
Don't use Notepad to code in. I cringed when I read that
. It doesn't have any syntax highlighting or auto-indenting or any other coding niceties. You can make your coding life SOOOO much nicer by using a proper PHP Editor. I personally like PSPad. It's got an integrated FTP client, so you don't need to download the files, edit them, save them, upload them to the server to see your changes - you just open the file, edit & save it. Voila!
Just do a search for 'PHP thumbnails' in Google - that's bound to turn up something useful.
Don't use Notepad to code in. I cringed when I read that
Just do a search for 'PHP thumbnails' in Google - that's bound to turn up something useful.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Eclipse is another editor that you could use that will help out tremendously, but for those just starting out, PSPad a nice little editor that will serve you well. Since we are not really talking about editors... 
As for working locally, there are a number of reasons I do that:
As for working locally, there are a number of reasons I do that:
- You can set all of your error reporting and display error settings to show all issues you have with your code
- You can break everything to you hearts content without the world seeing it
- You always have a backed up, up to date version of the site code on your machine
- If you ever switch hosts, you don't have to download the site then upload since you already have it locally
- You can test new pages in your local environment before pushing them live (so every time you make a change you don't have to FTP up)
ontop of everything other members have mentioned... what you're looking for is called a 'shopping cart'. there are many available for free on the internet (each with their own pros and cons) and there are plenty for purchase as well (each under their own liscense agreements). if your client wants you to write a shopping cart (which will more than likely involve building a content management system for it, as well) then i suggest you charge them a pretty penny. however, it doesn't seem like you have the skills yet to build a piece of software of this magnitude. building an effective shopping cart with a cms is an incredibely involved procedure and takes a skilled programmer to write the software.
- in my opinion.
- in my opinion.
- SmokyBarnable
- Forum Contributor
- Posts: 105
- Joined: Wed Nov 01, 2006 5:44 pm
-
snappydesigns
- Forum Commoner
- Posts: 28
- Joined: Tue Feb 13, 2007 11:37 am
Thanks for all the replies...
pickle-
All I can say is thank you for opening my eyes to such an easy system. All this time I've been using notepad to make any non-HTML files (even for some HTML, too), but there's much easier ways to do things...whooda thunk! So I downloaded PSPad and figured it out fairly quickly and even uploaded a .php document directly to the server from the interface. It literally took me the same time to type this as it did to download, install, create, upload a .php doc in PSPad. Awesome!
Everah-
I totally understand and agree with your points. Is there anyway to have a user interface similar phpMyAdmin loaded locally. My brain just doesn't function properly outside of windows-based programs? For example, I tried creating a table using the local MySQL. I kept making typos and had to start over several times and eventually gave up and went to the phpMyAdmin to create the table
.
visitor-Q & SmokyBarnable-
The client and I have already looked into shopping cart solutions. However, since she sells stationery from several vendors who each have different prices for different quantities, charge different prices for number of lines personalized on the stationery, etc., we just decided that we'll forgo the shopping cart option for now. In the meantime, we're just going to have an order form that a client fills out and gets emailed to the seller. Seller then contacts customer with pricing info...
I did pickle's suggested GOOGLE search 'PHP thumbnails', and only came up with how to generate thumbnails from larger images. I already have most of the thumbnails (some of the vendors were nice enough to create them) that correspond with the larger images. What I want to do is take the thumbnails that already exist in the database and display them in a table 4 columns across and however many rows that each link to the product info page. The book I've got actually goes through a good example that I've almost got to work.
Here's what I've got so far for my thumbnails page:
http://twinpapers.com/browse_flats.php
It's a mess, I know. Here's the php file code:
Can anyone guide me through putting the thumbnails into table 4 columns across? Thanks in advance for any help!
pickle-
All I can say is thank you for opening my eyes to such an easy system. All this time I've been using notepad to make any non-HTML files (even for some HTML, too), but there's much easier ways to do things...whooda thunk! So I downloaded PSPad and figured it out fairly quickly and even uploaded a .php document directly to the server from the interface. It literally took me the same time to type this as it did to download, install, create, upload a .php doc in PSPad. Awesome!
Everah-
I totally understand and agree with your points. Is there anyway to have a user interface similar phpMyAdmin loaded locally. My brain just doesn't function properly outside of windows-based programs? For example, I tried creating a table using the local MySQL. I kept making typos and had to start over several times and eventually gave up and went to the phpMyAdmin to create the table
visitor-Q & SmokyBarnable-
The client and I have already looked into shopping cart solutions. However, since she sells stationery from several vendors who each have different prices for different quantities, charge different prices for number of lines personalized on the stationery, etc., we just decided that we'll forgo the shopping cart option for now. In the meantime, we're just going to have an order form that a client fills out and gets emailed to the seller. Seller then contacts customer with pricing info...
I did pickle's suggested GOOGLE search 'PHP thumbnails', and only came up with how to generate thumbnails from larger images. I already have most of the thumbnails (some of the vendors were nice enough to create them) that correspond with the larger images. What I want to do is take the thumbnails that already exist in the database and display them in a table 4 columns across and however many rows that each link to the product info page. The book I've got actually goes through a good example that I've almost got to work.
Here's what I've got so far for my thumbnails page:
http://twinpapers.com/browse_flats.php
It's a mess, I know. Here's the php file code:
Code: Select all
<?php
include('header.html');
require_once ('stationery_flats_connect.php'); // Connect to the database.
$query = mysql_query ("SELECT * FROM donovandesigs") or die ("invalid query");
echo '<table width="746" border="0" bgcolor=#FFFFFF align="center">
<tr>
<td align="left" width="20%"><b></b></td>
<td align="left" width="40%"><b></b></td>
</tr>';
while ($row = mysql_fetch_array ($query)){
echo "<tr bgcolor=#FFFFFF><td><a href=\"view_donovanflat.php?pid={$row['product_name']}\"><img src=$row[thumb_name]></a></td><td><a href=\"view_donovanflat.php?pid={$row['product_name']}\">$row[product_name]</a></td></tr>";
}
echo "</table>";
mysql_close();
include('footer.html');
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Congrats at getting how far you have come. As for phpMyAdmin, you can install it locallay after you get the server set up on your machine. Essentially what you are going to do is mimic your hosted environment on your local computer. That means that after apache is running on your machine, and after PHP is installed and is talking with Apache, you can literally unzip the phpMyAdmin tarball into the C:\Program Files\Apache Group\Apache2\htdocs folder, rename the folder to phpMyAdmin, edit the config file as per their instructions and call it by hitting http://localhost/phpMyAdmin/
it maybe not much of an advice but i would suggest checking out
http://www.tutorialized.com/tutorials/PHP/1
i learned half of the things i learned there(the other half here)
really usefull
good luck on your project
http://www.tutorialized.com/tutorials/PHP/1
i learned half of the things i learned there(the other half here)
really usefull
good luck on your project
There is an easy way to create thumbs that would require less php code. Instead of trying to use a table to generate rows and columns. Use floated divs.
It's a simpler method and achieves the same results without too much code.
Code: Select all
<html>
<head>
<style type="text/css">
#container {
width: 700;
}
#container .block {
float:left;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<div id="container">Code: Select all
<?php
$query = mysql_query ("SELECT * FROM donovandesigs") or die ("invalid query");
while($row = mysql_fetch_array($query, MYSQL_ASSOC){
echo "<div class=\"block\">";
echo "<a href=\"view_donovanflat.php?pid={$row['product_name']}\"><img src=$row[thumb_name]></a>";
echo "</div>";
}
?>Code: Select all
</container>
</body>
</html>A couple other pointers, you don't need to call mysql_close(). Also, when ever you are submiting information to a mysql database, mysql_real_escape_string($string) and when retrieving it use htmlentities($string, ENT_QUOTES, "UTF-8"); These funcitons will keep you safe from many potentially annoying consequences
.