Tag Archives: Database

Laravel 5 belongsToMany() by Using Pivot Table Example

Relationship using pivot table in Laravel 5? A method, belongsToMany(), is a part of Eloquent ORM in Laravel 5. It connects between tables and it has many to many relationship. In order to use it, you must have two models three tables.

How to Put Date from MySQL to Select HTML Tag with PHP

You may want to create editable data using PHP and HTML. You want to take your date type value to your <select> HTML tag. It is not difficult, but yes we need to be patient to code it. First, you should call a query to your MySQL such as: Second, you have to set the […]

How to Store Date from Select HTML Tag to MySQL

Storing a date from <select> HTML tag to MySQL database is not that easy. I spent three hours to find out how. First time I tried to, I was thinking that my script was not effective. But, after reading some tutorial I found my own way to do it. Here it is. MySQL script Put […]

WordPress “Error establishing a database connection” Checklist

If it is your first time to install WordPress, you can get annoying Error establishing a database connection. There must be some reasons why this annoying error message appears. Here are the checklist that may help you out: Check that your database is correct. When you create a database manually in cPanel. You must be […]

How to Order MySQL Data Ascending and Descending Based on Field

The syntax is easy to remember. SELECT * FROM <table> ORDER BY <field> <ASC/DESC> Example: mysql_query(“SELECT * FROM groceries ORDER BY shopname ASC”) mysql_query(“SELECT * FROM groceries ORDER BY shopaddress DESC”) mysql_query(“SELECT * FROM students ORDER BY department ASC”) If you don’t want to order it ascending or descending just remove ASC or DESC. It […]