# php and SQL.



## r04DiE (18 Dec 2019)

Hello all,

I dabble in web design and graphics design and I would really like to learn to make databases using SQL and php for the front end. Can anybody recommend me a book for learning this? I just want to start with a simple database, like a library list or address book or something and then move on to bigger and better things.

Thanks!


----------



## newfhouse (18 Dec 2019)

I’ve knocked a few systems together over the last few years for various projects at work. I’m a hardware engineer really so as a coder I’m a self taught idiot rather than an expert. There are lots of good online resources including w3schools.com but I found the best way for me was to set up a LAMP server on an Ubuntu VM or a Pi and hack away. My code won’t win prizes, and much of it is plagiarised from online resources, but it does the job.

Sorry, not a book recommendation, but encouragement to just get stuck in.


----------



## r04DiE (18 Dec 2019)

newfhouse said:


> I’ve knocked a few systems together over the last few years for various projects at work. I’m a hardware engineer really so as a coder I’m a self taught idiot rather than an expert. There are lots of good online resources including w3schools.com but I found the best way for me was to set up a LAMP server on an Ubuntu VM or a Pi and hack away. My code won’t win prizes, and much of it is plagiarised from online resources, but it does the job.
> 
> Sorry, not a book recommendation, but encouragement to just get stuck in.


OK, thanks for that - I have MySQL workbench set up on my Mac, which should be helpful and I also have a couple of NAS boxes here at home that I can run phpMyAdmin on. Maybe I should just start dabbling but i do like the structure that a book brings.


----------



## Edwardoka (19 Dec 2019)

Do you have any experience with other programming/scripting languages and RDBMS? That will inform any recommendations. 
PHP's barrier to entry is insanely low - probably the lowest barrier to entry except maybe Python.


----------



## r04DiE (19 Dec 2019)

Not really. I messed about with HTML a long while ago and before CMS like Joomla! and Wordpress became so popular, when I lost interest in it a bit, due to the fact that the CMS just made it all so much quicker and easier. I can get by making very simple webpages with HTML, but that's about it. I have always been really interested in databasing though, its something that I would really like to do, I love being able to automate things and manage large amounts of data.

Good to hear that php has a low entry barrier as that's what I need! Willing to put the time in and learn though.


----------



## si_c (19 Dec 2019)

I've dabbled here and there with PHP/MySQL websites for various projects. SQL I use all day every day in work so I'm fairly competent with that, but in terms of building websites I found using a framework to be very helpful in getting the structure right. Take a look at something like Laravel which should allow you to build the front end using PHP and abstracts away a lot of the database stuff you might find in a primer for PHP, plus it makes sense as it contextualises things.


----------



## Edwardoka (19 Dec 2019)

I did wonder how long it would be before someone mentioned Laravel 

It's a fine framework, but if you're trying to learn what's going on under the hood you've no chance. I've been using PHP on and off for the best part of 20 years and I still struggle when dealing with Laravel's hand-wavy magic.

As for books, I can't recommend one for true beginners - but would say that while the fundamentals haven't substantially changed since PHP5, look for one relatively recent, as the ecosystem has come on in massive leaps and bounds with the creation and widespread adoption of things like composer and the PSR standards.


----------



## Edwardoka (19 Dec 2019)

More helpful than my last post:
Don't worry about best practices or which framework to use as there's a lot of dogma attached to the various options.

if you're using a mac you already have apache and php installed. The best way to learn is to get stuck in.

I just skim-read this tutorial and it seems like a good jumping off point for what you want to achieve without getting mired into architectural choices.

https://www.taniarascia.com/create-a-simple-database-app-connecting-to-mysql-with-php/


----------



## BoldonLad (19 Dec 2019)

Don't know what you background / expertise is, but, IMHO, there are at least two, if not three aspects to your question:

1. Database design, ie which table, relationships, columns etc
2. SQL to extract the data
3. Web coding to "drive" the SQL

I have always found the "Dummies guide" books quite a good grounding, plus, as mention above "learning from" (ie copying) code snippets from websites etc.


----------



## contadino (19 Dec 2019)

On the PHP front, this is pretty much gospel...

https://phptherightway.com/

It won't make much sense to start with but keep going back to it and you'll understand more each time.


----------



## Edwardoka (19 Dec 2019)

BoldonLad said:


> Don't know what you background / expertise is, but, IMHO, there are at least two, if not three aspects to your question:
> 
> 1. Database design, ie which table, relationships, columns etc
> 2. SQL to extract the data
> ...


Yes, for some reason I had it in my head that the OP was already up to speed with databases. Reading comprehension fail on my part.
Database design and SQL are separate subjects from PHP, even though PHP/MySQL are often lumped together.


----------



## contadino (19 Dec 2019)

And before going anywhere near any of the frameworks, get a good understanding of Composer/Packagist...

https://getcomposer.org/
https://packagist.org/

Just my advice.


----------



## r04DiE (20 Dec 2019)

si_c said:


> I've dabbled here and there with PHP/MySQL websites for various projects. SQL I use all day every day in work so I'm fairly competent with that, but in terms of building websites I found using a framework to be very helpful in getting the structure right. Take a look at something like Laravel which should allow you to build the front end using PHP and abstracts away a lot of the database stuff you might find in a primer for PHP, plus it makes sense as it contextualises things.


Great stuff, thanks for that and Laravel looks very interesting, but I think I will try to learn from the ground up, but this is defo something I might try in the future, it looks great!


----------



## r04DiE (20 Dec 2019)

Edwardoka said:


> More helpful than my last post:
> Don't worry about best practices or which framework to use as there's a lot of dogma attached to the various options.
> 
> if you're using a mac you already have apache and php installed. The best way to learn is to get stuck in.
> ...





BoldonLad said:


> Don't know what you background / expertise is, but, IMHO, there are at least two, if not three aspects to your question:
> 
> 1. Database design, ie which table, relationships, columns etc
> 2. SQL to extract the data
> ...





contadino said:


> On the PHP front, this is pretty much gospel...
> 
> https://phptherightway.com/
> 
> It won't make much sense to start with but keep going back to it and you'll understand more each time.





contadino said:


> And before going anywhere near any of the frameworks, get a good understanding of Composer/Packagist...
> 
> https://getcomposer.org/
> https://packagist.org/
> ...


OK, this is all golden and many, many thanks to you all for this advice - I am going to try to get stuck in. Think I might try it on my NAS first or maybe even in a directory on my website. Thanks again to you all and I really appreciate this. Might be back with more questions though!


----------



## r04DiE (20 Dec 2019)

Book wise, I am thinking of this one.


----------



## Ming the Merciless (21 Dec 2019)

r04DiE said:


> Book wise, I am thinking of this one.
> 
> View attachment 497236



I don't have that one but years ago I bought two or three from that brand and in general easy to follow and jump to the bits you are Interested in.

I quite like https://code.visualstudio.com as a minimalist code editor. There will be a plugin for syntax checking of PHP 7 and MYSQL etc.

I also have net beans which is good for integrating with Git repositories for code management. But is overkill and not always intuitive for a lot of stuff, particularly if just dabbling.

Little bit of maintenance advice. Try and keep the PHP code that accesses your database in a few core functions in a few files as possible. Ultimately this leads to developing APIs for the data access / functions. So if the underlying database structure changes or the database moves, the code calling the APIs doesn't need to know or change. The PHP SQL syntax are one of the things that has changed the most over the years. If it's spread throughout your code it can make maintenance difficult / time consuming, when upgrading PHP versions.


----------



## r04DiE (10 Jan 2020)

Thak you @YukonBoy, great advice in there and I am loving the code editor - I have been looking for something like this for AGES!


----------

