0

I want to create 200+ pages with products.

I have 5 categories.

I made a prototype .php file that it will include everytime the correct product1.php or product2.php each time (with GET).

Moreover I want to have each time different meta-tags. So prototype.php will include and the metatags.

I want advise b/c I dont know if my thinking is correct (To create 200 products php files that they will contains images, pagagraphs etc and 200 metatags php files that they will contain every product metatags with descriptions / keywords etc )

I have been confused b/c I think if I will try to create a database it will more easier.

But I want to know If I choose the msql solution will be faster or slower than the solution that I wrote before.

If you want any details or I miss something please tell me!


John
  • 31
  • 1
  • 3
  • 8

1 Answers1

1

A database is absolutely the way to go with this. No question.

I recommend looking into MySQL, and learning the PDO method of using it.

Community
  • 1
  • 1
Brad
  • 159,648
  • 54
  • 349
  • 530
  • No problem, and please use prepared queries! Stay away from the `mysql_*` functions for sure. Prepared queries keep you from having to deal with SQL injection attacks, as they separate the data from the command. – Brad Dec 29 '12 at 04:12
  • excuse me, but what do you mean with : "Prepared queries" ? Do you mean to not use the GET function ? (on url: www.domain.example/index.php?productID=1 ) and use POST fuction to hide it? @Brad – John Dec 29 '12 at 04:18
  • @John, No, not at all. Using POST doesn't hide anything. You should use GET when you are parameters that control what is being displayed (such as a product ID). Use POST when you are submitting a form or making an action that changes data in some way. What I am talking about has nothing to do with HTTP. I'm talking about the database. There is a common way to write SQL queries that involves just concatenating data into the query. Don't do this. Instead, use parameters that get filled in later. For instance, `SELECT * FROM products WHERE productId=:productId;`. – Brad Dec 29 '12 at 04:27
  • @John, When you execute the query, you pass in values for those parameters. (Or, you can bind them before executing.) I don't know how else to describe this to you at the moment. Please try to make a script that uses a database, and then ask questions. – Brad Dec 29 '12 at 04:28
  • I think you mean something like this example (1st example): http://php.net/manual/en/mysqli.prepare.php Here, Firstly bind parameters and then execute. Thanks for your patient :) @Brad – John Dec 29 '12 at 04:41
  • @John, Yes, that's exactly what I mean. You can use MySQLi for this, as well as PDO. I often recommend PDO over MySQLi as PDO allows you to connect to several databases, rather than just MySQL. You can use any database there is a PDO driver for, which may come in handy for you in the future. In either case, prepared queries are the most important part of the suggestion. – Brad Dec 29 '12 at 04:43