PHP Webboard. Tables and files 2 Tables(Webboard and Reply) Webboard.php for show all question NewQuestion.php for creating new question ViewWebboard.php.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
Advertisements

PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
© 2014 Irish Titan Anatomy of a Magento Extension Jon Saverda.
Day 3 - Basics of MySQL What is MySQL What is MySQL How to make basic tables How to make basic tables Simple MySQL commands. Simple MySQL commands.
PHP Upload image. 1. Upload filename into database Create 6 files and 1 folder myfile 1.Include.php for connect PHP and database 2.Upload1.php for input.
Group X7 – Year 2010/2011 – First Year Team Project.
Quick-and-dirty.  Commands end in a semi-colon ◦ If you forget, another prompt line shows up  Either continue the command or…  End it with a semi-colon.
Objectives Connect to MySQL from PHP
Intermediate PHP & MySQL
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
PHP on a Fast Track a quick introduction to PHP programming by Jarek Francik.
PHP & MySQL Mahak Arora Vivek Bangera. Outline How PHP works Basic scripting in PHP Forms in PHP(GET & POST Variables) SQL basics PHP and MySQL connection.
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
MySql In Action Step by step method to create your own database.
U NIT 4 F ILE U PLOAD. I. C REATE AN U PLOAD -F ILE F ORM - With PHP, it is possible to upload files to the server.To allow users to upload files from.
What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables. A table is a collections of related data entries and.
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
1 Chapter 8 – Working with Databases spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
Slide 8-1 CHAPTER 8 Using Databases with PHP Scripts: Using MySQL Database with PHP.
INTERNET APPLICATION DEVELOPMENT For More visit:
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Dbwebsites 2.1 Making Database backed Websites Session 2 The SQL… Where do we put the data?
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Introduction to MySQL Lab no. 10 Advance Database Management System.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
PHP MySQL. SQL: Tables CREATE TABLE tablename { fieldname type(length) extra info,... } Extra info: –NULL (allows nulls in this field) –Not NULL (null.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
MySQL PHP Web Technology. Logging in to Command Line Start -> Programs -> AppServ -> MySQL Command Line Client Enter Password, then you’ll be working.
CSC 2720 Building Web Applications Database and SQL.
Database and mySQL Week 07 Dynamic Web TCNJ Jean Chu.
Welcome to the Web! Session By: Infero - Programming Club, IIT Hyderabad.
CAKEPHP Blog tutorial. what you’ll need examples/blog/blog.html 2  A running web server  A database server.
PHP Cart. Tables, folder and files 3 Tables(Orders, Orders_detail and Products) Folder img for store all picture Product.php for show all product Order.php.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
PHP MySQL Image Gallery. The admin section contain the following : Add New Album Album List Edit & Delete Album Add Image Image List Edit & Delete Image.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
Bulletin Board Part 1 – Files and Changes CIS 254.
SQL Structured Query Language 1. Data Definition Language (DDL) is used to manage table and define data structure i.e. CREATE, ALTER, DROP Data Control.
Truckee River Information Gateway TRIG Training Session Sept. 13, 2006 David Waetjen Information Center for the Environment (ICE)
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
Using Flash with php Very quick introduction to Flash Homework: work on projects.
Creating A Database Driven Website 1.Setting Up Your Web Server 2.Creating a Database 3.Creating a Webpage to Display Information From a Database 4.Creating.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
SQL has several parts: Major ones: DDL – Data Definition Language {Defining, Deleting, Modifying relation schemas} DML – Data Manipulation Language {Inserting,
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
CHAPTER 10 PHP MySQL Database
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
Working with MySQL A290/A590, Fall /07/2014.
MySQL API( c ) & SQL2 강동훈.
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
DEV Training Sahana Developer Training. DEV Training PHP.
Tried my best to simplify it for you!
Storing Images Connect to the server using the correct username and password. $conn = mysql_connect(“yourserver”, “joeuser”, “yourpass”); Create the database.
Session 4 PHP & MySQL.
PHP Graph.
MySQL tutorial.
Web Programming– UFCFB Lecture
Chapter 4 Introduction to MySQL.
Conection
Presentation transcript:

PHP Webboard

Tables and files 2 Tables(Webboard and Reply) Webboard.php for show all question NewQuestion.php for creating new question ViewWebboard.php for show question,replies and create new reply And include.php for connect database

CREATE TABLE Webboard CREATE TABLE `webboard` ( `QuestionID` int(5) unsigned zerofill NOT NULL auto_increment, `CreateDate` datetime NOT NULL, `Question` varchar(255) NOT NULL, `Details` text NOT NULL, `Name` varchar(50) NOT NULL, `View` int(5) NOT NULL, `Reply` int(5) NOT NULL, PRIMARY KEY (`QuestionID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE Reply CREATE TABLE `reply` ( `ReplyID` int(5) unsigned zerofill NOT NULL auto_increment, `QuestionID` int(5) unsigned zerofill NOT NULL, `CreateDate` datetime NOT NULL, `Details` text NOT NULL, `Name` varchar(50) NOT NULL, PRIMARY KEY (`ReplyID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

Webboard.php New Topic <? include ("include.php"); $strSQL = "SELECT * FROM webboard "; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 10; // Per Page $Page = $_GET["Page"];

if(!$_GET["Page"]) {$Page=1;} $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) {$Num_Pages =1;} else if(($Num_Rows % $Per_Page)==0) {$Num_Pages =($Num_Rows/$Per_Page) ;} else {$Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL.=" order by QuestionID DESC LIMIT $Page_Start, $Per_Page";

$objQuery = mysql_query($strSQL); ?> QuestionID Question Name CreateDate View Reply <? while($objResult = mysql_fetch_array($objQuery)) { ?>

"> <? } ?>

Total Record : Page : <? if($Prev_Page) {echo " "; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) {echo "[ $i ]"; } else {echo " $i "; }

if($Page!=$Num_Pages) {echo " Next>> "; } mysql_close(); ?>

NewQuestion.php <? include ("include.php"); if($_GET["Action"] == "Save") {//*** Insert Question ***// $strSQL = "INSERT INTO webboard "; $strSQL.="(CreateDate,Question,Details,Name) "; $strSQL.="VALUES "; $strSQL.="('".date("Y-m-d H:i:s")."','".$_POST["txtQuestion"]."','".$_POST["txtDetails"]."','".$_ POST["txtName"]."') "; $objQuery = mysql_query($strSQL); header("location:Webboard.php"); }

?> Question Details

Name <? mysql_close(); ?>

ViewWebboard.php <? include ("include.php"); if($_GET["Action"] == "Save") {//*** Insert Reply ***// $strSQL = "INSERT INTO reply "; $strSQL.="(QuestionID,CreateDate,Details,Name) "; $strSQL.="VALUES "; $strSQL.="('".$_GET["QuestionID"]."','".date("Y-m-d H:i:s")."','".$_POST["txtDetails"]."','".$_POST["txtName"]."') "; $objQuery = mysql_query($strSQL);

//*** Update Reply ***// $strSQL = "UPDATE webboard "; $strSQL.="SET Reply = Reply + 1 WHERE QuestionID = '".$_GET["QuestionID"]."' "; $objQuery = mysql_query($strSQL); } ?> <? //*** Select Question ***// $strSQL = "SELECT * FROM webboard WHERE QuestionID = '".$_GET["QuestionID"]."' "; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $objResult = mysql_fetch_array($objQuery);

//*** Update View ***// $strSQL = "UPDATE webboard "; $strSQL.="SET View = View + 1 WHERE QuestionID = '".$_GET["QuestionID"]."' "; $objQuery = mysql_query($strSQL); ?>

Name : Create Date : View : Reply : <? $intRows = 0; $strSQL2 = "SELECT * FROM reply WHERE QuestionID = '".$_GET["QuestionID"]."' "; $objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL."]");

while($objResult2 = mysql_fetch_array($objQuery2)) {$intRows++; ?> No : Name : Create Date :

<? } ?> Back to Webboard &Action=Save" method="post" name="frmMain" id="frmMain"> Details

Name <? mysql_close(); ?>

Include.php <? mysql_connect("localhost","root","1234"); mysql_select_db("test"); ?>