Skip to main content

PHP Tutorial–Lesson 4: Introduction to PHP- Part II

 

Getting Started with MySql:

•Here am going to demonstrate MySql queries, and all examples demonstrate only how to write correct MySql syntax.

•So you might run these commands at your MySql db on your own host, at a window called SQL, and fill your query on the text box then click run.

•At end of this Lesson, you’ll get PHP built-in functions that deal with MySql db, and be able to run MySql query through PHP script.

Logging to MySql through your localhost server:

In order to log in to your MySql db that it is installed on your localhost, simply open your internet explorer, on the address bar, write: http:localhost:port/phpmyadmin

where port is the port number where your web server installed on it. for example suppose your web server installed on port number 81 then the address will be:

http://localhost:81/phpmyadmin

remember, you had specified the port number of your web server at installation time.

after that then a prompt will ask you for username and password of MySql administrator, type them and enter.

in case you face a problem don’t hesitate to post it and tell us about it.

Queries

•Each instruction in MySql you do, called a query.

What does query mean?

•When you ask your db to do some functions in your application, you query it.

•Query is a syntax from you as a programmer, to the db as a software.

•This syntax is known for db as an instruction that does some actions, depending on the syntax.

•At our PHP tutorial we’ll talk about basic queries that we’ll use in our applications.

for complete reference about MySql queries go to www.mysql.com

CREATE Query:

•This query used to create something (objects) not exist.

•We use CREATE to create database and tables or any object.

How to create database?

Syntax:

CREATE DATABASE db_name

Example: CREATE DATABASE company

Notes:

•MySql is not case sensitive, but it is preferred to write MySql query capitalized, and it does not matter your variable-name capitalized or not.

•CREATE DATABASE: tells your RDBMS to create an empty db.

•To make this query executed successfully, you have to keep in mind that db_name must be unique, i.e. db_name is not used before in the same host. db_name naming rules are: must begin with only char or underscore, and might contain numbers.

• User must be granted a privilege for  creating new databases, in order to execute this query successfully.

How to create table?

Syntax:

CREATE TABLE table_name

(

Table properties…

)

Notes:

•table_name name must be unique, i.e. there is no other table in the same db has same name.

•Table properties are columns of the table, or the attributes your table has.

•Successful programmer chooses descriptive names for table name, and group related information in same table.

•Table properties are very important, often, we reach this stage after analysis for the project we need to run.

To download this lesson click here: PHP Tutorial–Lesson 4: Introduction to PHP- Part II

Best Wishes,

Anas Jaghoub

Comments

Popular posts from this blog

سلسلة تعلم برمجة تطبيقات الاندرويد - إعداد بيئة العمل - الحلقة رقم 1

في هذه الحلقة سنقوم بتجهيز بيئة العمل، وإعداد كافة الأدوات والبيئة اللازمة للبدء في برمجة تطبيقات الاندرويد، لنتمكن في الحلقات القادمة من العمل والتطوير باستخدام الأدوات التي سنقوم بإعدادها في هذه الحلقة. 1. للبدء في تطوير أي برنامج على الاندرويد لا بد من توفر حزمة التطوير الأساسية وهي Android SDK . هذه الحزمة هي حجر الأساس لعمل أي تطبيق على الاندرويد حيث تحتوي على مجموعة كبيرة من الوظائف الاساسية والبرامج التي تمكننا من التحدث مع نظام التشغيل الاندرويد، وطلب تنفيذ العمليات والحسابات إلى غيره من الوظائف بحسب طبيعة كل تطبيق ووظائفه. وتمكننا أيضا من إنشاء أجهزة افتراضية Virtual Machines تساعدنا على تجربة التطبيقات حتى بدون وجود جهاز اندرويد  2. حزمة الجافا JDK والتي تقوم بترجمة النص البرمجي لحزمة الاندرويد وكذلك النص البرمجي للتطبيق وتحويله إلى نسخة تنفيذية قابلة للعمل على أي جهاز اندرويد 3. بيئة العمل IDE وفي هذه السلسلة سنقوم باستخدام Netbeans وذلك لسهولة استخدامه وسهولة التطبيق عليه. كما يمكن أيضا استخدام بيئة العمل Eclipse . ولغايات تبسيط هذه الحلقة و...

سلسلة تعلم برمجة تطبيقات الاندرويد – إنشاء أول تطبيق للاندرويد – الحلقة رقم 2

تحدثنا في الحلقة السابقة عن إعداد بيئة العمل، وأهم الأدوات والحزم اللازمة للبدء في تطوير تطبيقات لنظام التشغيل الاندرويد. سنتحدث في هذه الحلقة عن كيفية إنشاء تطبيق للاندرويد، وما هي مكونات تطبيق الاندرويد والبنية الهيكلية ﻷي تطبيق على الاندرويد. إنشاء تطبيق باستخدام بيئة العمل Netbeans : 1. اضغط على قائمة File 2. اختر New Project. 3. اختر نوع المشروع Android 4. اضغط زر Next. 5. اضبط إعدادات المشروع كالتالي: Project Name: اسم المشروع، يفضل أن يكون اسم المشروع هو نفس اسم التطبيق وذلك لتمييزه عن باقي المشاريع الأخرى Package Name: اسم حزمة المشروع، وهنا يجب اتباع قواعد تسمية الحزم في لغة Java إذ يجب أن تتكون من مقطعين على الأقل ويفصل بين كل مقطع بنقطة، ولا يوجد فراغات. Target Platform: رقم نسخة نظام التشغيل الاندرويد التي يدعمها هذا التطبيق، وهنا لا بد من اختيار أقل رقم يتوافق معه هذا التطبيق لمزيد من التفاصيل شاهد الصورة التالية: 6. اضغط على زر Finish وهكذا نكون قد أنشأنا بمساعدة بيئة العمل Netbeans أول تطبيق للأندرويد حيث تم تصميم هيكل التطبيق، واستدعاء كافة ال...

Web Development Best Practices (PHP Best Practices)

Websites development is one of the most challenging projects ever to develop, according to the large number of components you deal with, integrate, and manage in your application. For example, most web projects Deal with databases as their data source, and I ntegrate with external services called web services and APIs. As well the application M anages its own objects and components from views to models to controllers to plugins and so on. A skilled web developer should have a great/deep knowledge in most of components used in his system, and as well should ha ve intensive focus on how each component work and how can be used, what can be done, and what cannot. On the other hand, the huge amount of requirements, components to manage, and time frame given to you to accomplish your mission, and number of people in your team, all these factors together requires from you to organize your tasks, and priorities your requirements, do deep analysis and planning in order to have a hi...