Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  Show Posts
Pages: [1]
1  General / How To's & Tutorials / Deleting data From mysql on: August 16, 2008, 09:56:09 AM
Syntax
 
"DELETE FROM table_name WHERE column_name=' value' ";
 
 
Overview
 
In this tutorial create 2 files
1. delete.php
2. delete_ac.php

Step
1. Create table "test_mysql" in database "test".
2. Create file delete.php.
3. Create file delete_ac.php.
 
1.Set up database 
 
CREATE TABLE `test_mysql` (
`id` int(4) NOT NULL auto_increment,
`name` varchar(65) NOT NULL default '',
`lastname` varchar(65) NOT NULL default '',
`email` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=7 ;

--
-- Dumping data for table `test_mysql`
--

INSERT INTO `test_mysql` VALUES (1, 'Billly', 'Blueton', 'bb5@phpeasystep.com');
INSERT INTO `test_mysql` VALUES (2, 'Jame', 'Campbell', 'jame@somewhere.com');
INSERT INTO `test_mysql` VALUES (3, 'Mark', 'Jackson', 'mark@phpeasystep.com');
INSERT INTO `test_mysql` VALUES (4, 'Linda', 'Travor', 'lin65@phpeasystep.com');
INSERT INTO `test_mysql` VALUES (5, 'Joey', 'Ford', 'fordloi@somewhere.com');
INSERT INTO `test_mysql` VALUES (6, 'Sidney', 'Gibson', 'gibson@phpeasystep.com');
 
2.Create file - delete.php
############### Code

<?php

$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="test_mysql"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// select record from mysql
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);

?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><table width="400%" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete data in mysql</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>
<td align="center" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td>
<td bgcolor="#FFFFFF"><a href="delete_ac.php?id=<? echo $rows['id']; ?>">delete</a></td>
</tr>
<?

// close while loop
}

// close connection;
mysql_close();

?>
</table></td>
</tr>
</table>

3.Create file delete_ac.php
############### Code

<?php

$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="test_mysql"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// get value of id that sent from address bar
$id=$_GET['id'];

// Delete data in mysql from row that has this id
$sql="DELETE FROM $tbl_name WHERE id='$id'";
$result=mysql_query($sql);

// if successfully deleted
if($result){
echo "Deleted Successfully";
echo "<BR>";
echo "<a href='delete.php'>Back to main page</a>";
}

else {
echo "ERROR";
}

// close connection
mysql_close();

?>
2  General / How To's & Tutorials / Updating data in mysql on: August 16, 2008, 09:53:47 AM
Syntax
 
"UPDATE table_name SET column_name1=' value', column_name2=' value' WHERE column_name=' value' ";

 Overview
 
In this tutorial create 3 files
1. list_records.php
2. update.php
3. update_ac.php

Step
1. Create table "test_mysql" in database "test"
2. Create file list_records.php
3. Create file update.php
4. Create file update_ac.php
 
1.Set up database
CREATE TABLE `test_mysql` (
`id` int(4) NOT NULL auto_increment,
`name` varchar(65) NOT NULL default '',
`lastname` varchar(65) NOT NULL default '',
`email` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=7 ;

--
-- Dumping data for table `test_mysql`
--

INSERT INTO `test_mysql` VALUES (1, 'Billly', 'Blueton', 'bb5@phpeasystep.com');
INSERT INTO `test_mysql` VALUES (2, 'Jame', 'Campbell', 'jame@somewhere.com');
INSERT INTO `test_mysql` VALUES (3, 'Mark', 'Jackson', 'mark@phpeasystep.com');
INSERT INTO `test_mysql` VALUES (4, 'Linda', 'Travor', 'lin65@phpeasystep.com');
INSERT INTO `test_mysql` VALUES (5, 'Joey', 'Ford', 'fordloi@somewhere.com');
INSERT INTO `test_mysql` VALUES (6, 'Sidney', 'Gibson', 'gibson@phpeasystep.com');
 
2.Create file - list_records.php
############### Code

<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="test_mysql"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="4"><strong>List data from mysql </strong> </td>
</tr>

<tr>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Lastname</strong></td>
<td align="center"><strong>Email</strong></td>
<td align="center"><strong>Update</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><? echo $rows['name']; ?></td>
<td><? echo $rows['lastname']; ?></td>
<td><? echo $rows['email']; ?></td>

// link to update.php and send value of id
<td align="center"><a href="update.php?id=<? echo $rows['id']; ?>">update</a></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
<?php
mysql_close();
?>

3  General / How To's & Tutorials / Selecting data From mysql on: August 16, 2008, 09:51:01 AM
Syntax
 
// Select all columns from all rows.
"SELECT * FROM table_name";
or
// Select some column from all rows.
"SELECT column_name1, column_name2 FROM table_name";
or
// Select all coulumns from one row.
"SELECT * FROM table_name WHERE column_name=' value in column '";
 
 
Overview
 
In this tutorial create 1 file
1. select.php

Step
1. Create table "test_mysql" in database "test".
2. Create file select.php.
3. test it!

If you don't want looping rows in mysql, replace
while($rows=mysql_fetch_array($result)){
........
<?php
}
mysql_close();
?>

replace with this
$rows=mysql_fetch_array($result);
.........
<?php
mysql_close();
?>

1.Create table "test_mysql" 
 

CREATE TABLE `test_mysql` (
`id` int(4) NOT NULL auto_increment,
`name` varchar(65) NOT NULL default '',
`lastname` varchar(65) NOT NULL default '',
`email` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=7 ;

--
-- Dumping data for table `test_mysql`
--

INSERT INTO `test_mysql` VALUES (1, 'Billly', 'Blueton', 'bb5@phpeasystep.com');
INSERT INTO `test_mysql` VALUES (2, 'Jame', 'Campbell', 'jame@somewhere.com');
INSERT INTO `test_mysql` VALUES (3, 'Mark', 'Jackson', 'mark@phpeasystep.com');
INSERT INTO `test_mysql` VALUES (4, 'Linda', 'Travor', 'lin65@phpeasystep.com');
INSERT INTO `test_mysql` VALUES (5, 'Joey', 'Ford', 'fordloi@somewhere.com');
INSERT INTO `test_mysql` VALUES (6, 'Sidney', 'Gibson', 'gibson@phpeasystep.com');
 
 
2.Create file - Select.php
############### Code

<?php

$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="test_mysql"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Retrieve data from database
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);

// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td width="10%"><? echo $rows['id']; ?></td>
<td width="30%"><? echo $rows['name']; ?></td>
<td width="30%"><? echo $rows['lastname']; ?></td>
<td width="30%"><? echo $rows['email']; ?></td>
</tr>
</table>

<?
// close while loop
}

// close connection
mysql_close();
?>

 

 
 
4  General / How To's & Tutorials / Inserting data into mysql on: August 16, 2008, 09:48:40 AM
Syntax:
"INSERT INTO table_name(column_name1, column_name2)VALUES('value1, 'value2')" ; 

Overview
 
In this tutorial create 2 files
1. insert.php
2. insert_ac.php

Step
1. Create table "test_mysql" in database "test".
2. Create file insert.php.
3. Create file insert_ac.php.
 
 1.Create table "test_mysql"
 
CREATE TABLE `test_mysql` (
`id` int(4) NOT NULL auto_increment,
`name` varchar(65) NOT NULL default '',
`lastname` varchar(65) NOT NULL default '',
`email` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=0 ;
 
2.Create file insert.php
############### Code

<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="insert_ac.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td colspan="3"><strong>Insert Data Into mySQL Database </strong></td>
</tr>
<tr>
<td width="71">Name</td>
<td width="6">:</td>
<td width="301"><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>Lastname</td>
<td>:</td>
<td><input name="lastname" type="text" id="lastname"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>

 
5  General / How To's & Tutorials / Connecting to MySQL database on: August 16, 2008, 09:45:56 AM
Syntax
 ---------------
mysql_connect("host", "username", "password")or die("cannot connect to server");

Overview
----------------
Define your database information,
* host="localhost" you don't have to change it. When it's on your computer or server it still be localhost

Username = youruser
Password = yourpassword
Database = yourDataBase
 
 1.step
$host="localhost";
$username="youruser";
$password="yourpassword";
$db_name="yourDataBase";

2.Creating file config.php 
-----------------------
$host="localhost";
$username="youruser";
$password="yourpassword";
$db_name="yourDataBase";


mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select db"); 
save this file as "config.php"
when you want to use this code include it to your main php file

example
<?php

include("config.php");

$tbl_name="member";
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>
 
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select db");

or

mysql_connect("localhost", "phpeaststep", "1234")or die("cannot connect to server");
mysql_select_db("test")or die("cannot select db");
 
 
6  General / How To's & Tutorials / Creating a simple PHP guestbook on: August 16, 2008, 09:38:39 AM
Overview
 
In this tutorial create 3 files
1. guestbook.php
2. addguestbook.php
3. viewguestbook.php

Step
1. Create table name "guestbook" in database "test".
2. Create file guestbook.php.
3. Create file addguestbook. php.
4. Create file viewguestbook.php

 1.Set up database
------------------------------
CREATE TABLE `guestbook` (
`id` int(4) NOT NULL auto_increment,
`name` varchar(65) NOT NULL default '',
`email` varchar(65) NOT NULL default '',
`comment` longtext NOT NULL,
`datetime` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

2.Create file guestbook.php
-------------------------------------
############### Code

<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong>Test Sign Guestbook </strong></td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form id="form1" name="form1" method="post" action="addguestbook.php">
<td>
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td width="117">Name</td>
<td width="14">:</td>
<td width="357"><input name="name" type="text" id="name" size="40" /></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="email" type="text" id="email" size="40" /></td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">:</td>
<td><textarea name="comment" cols="40" rows="3" id="comment"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong><a href="viewguestbook.php">View Guestbook</a> </strong></td>
</tr>
</table>


3.create file addguestbook.php
-----------------------------------------
############### Code

<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="guestbook"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");

$datetime=date("y-m-d h:i:s"); //date time

$sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')";
$result=mysql_query($sql);

//check if query successful
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='viewguestbook.php'>View guestbook</a>"; // link to view guestbook page
}

else {
echo "ERROR";
}

mysql_close();
?>


4.Create file viewguestbook.php
---------------------------------------------
############### Code

<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong>View Guestbook | <a href="guestbook.php">Sign Guestbook</a> </strong></td>
</tr>
</table>
<br>

<?php

$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="guestbook"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);

while($rows=mysql_fetch_array($result)){
?>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td>ID</td>
<td>:</td>
<td><? echo $rows['id']; ?></td>
</tr>
<tr>
<td width="117">Name</td>
<td width="14">:</td>
<td width="357"><? echo $rows['name']; ?></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><? echo $rows['email']; ?></td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">:</td>
<td><? echo $rows['comment']; ?></td>
</tr>
<tr>
<td valign="top">Date/Time </td>
<td valign="top">:</td>
<td><? echo $rows['datetime']; ?></td>
</tr>
</table></td>
</tr>
</table>
<BR>
<?
}
mysql_close(); //close database
?>
7  General / How To's & Tutorials / PHP Script tutorial on: August 16, 2008, 09:34:03 AM

Overview
-----------------------------
In this tutorial create 1 file
1. counter.php

Step
1. Create table "counter" in database "test".
2. Create file counter.php.
 
 1. Create table "counter"
--------------------------
CREATE TABLE `counter` (
`counter` int(9) NOT NULL default '0'
) TYPE=MyISAM;

2.Create file counter.php
---------------------------------
############### Code

<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect to server ");
mysql_select_db("$db_name")or die("cannot select DB")

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);

$rows=mysql_fetch_array($result);
$counter=$rows['counter'];

// if have no counter value set counter = 1
if(empty($counter)){
$counter=1;
$sql1="INSERT INTO $tbl_name(counter) VALUES('$counter')";
$result1=mysql_query($sql1);
}

echo "You 're visitors No. ";
echo $counter;

// count more value
$addcounter=$counter+1;
$sql2="update $tbl_name set counter='$addcounter'";
$result2=mysql_query($sql2);

mysql_close();
?>

 

 

8  General / How To's & Tutorials / CSS --tutorial on: August 16, 2008, 09:04:04 AM
There is a great deal of information on CSS all over the web. Since it’s a reasonably open web development methodology with lots of options this can quickly lead to confusion and frustration.

We are providing you with a basic tutorial of how CSS works and why you might want to start using it. The examples on this site are designed to be lean and mean and easy for you to understand.  Feel free to use what you find, all we ask is that you link back to us from your site.

What is CSS?

CSS is short for Cascading Style Sheets. It is a new web page layout method that has been added to HTML to give web developers more control over their design and content layout. Using CSS allows a designer to create a standard set of commands (either embedded inside the web page or from an external page) that controls the style of all subsequent pages.
With CSS you can add style (fonts, colors, spacing, size. links) to web documents. More advanced techniques control the layout of the page without the use of tables or other cumbersome HTML.

The most important thing for web designers to understand about CSS is that CSS separates the layout and the styles of a web page. This is often difficult for comprehend for web designers that are used to compiling their creative and HTML coding in a single web page document.

 Styles such as fonts, font sizes, margins, can be specified in one place, then the Web pages feed off this one master list, with the styles cascading throughout the page or an entire site.

What are the benefits of using CSS?

Until recently web page layout was not an exact science. It has been managed by inventive designers who mastered table-based HTML layouts enough to create compelling sites. With CSS all of that has changed as standards are finally being set for the present and future of web design.

CSS is beneficial to the designer because of the afore mentioned control they have over their web site design and how it will be appear across platforms and browsers.

Web sites designed in CSS are faster to change and update. Because the coding is reduced the pages are more efficient and require less bandwidth. Cost saving functions like these are causing businesses to demand CSS from their designers which is forcing less hold-out designers to convert because their clients demand it.

The main benefit to designers and to companies is that CSS speeds the time it takes to develop and update site layouts. Communication is easier among multiple developers because the workflow is standardized.

All in all, CSS is a development method that every designer will be using in the near future, and one that is very beneficial to everyone involved, from the designer through to the end user.

CSS RULES:-
Cascading Style Sheets are a set of rules that govern the display of the document through a web browser. The rules simply are lines of command codes that tell the browser how to display the information.  It is crucial with CSS to get the syntax of the command lines correct to keep any frustrating errors from popping up.
 
The SELECTOR selects (determines) which HTML element you’re working with. HTML elements are common tags like <body>, <H1>, <p>.  Often the selector is referred to as an element selector or a type selector.
 The DECLARATION tells the browser what to do with the Selected element. It consists of two parts:

 The PROPERTY, which identifies which attribute like font type, size and color, for example, is called into play.

 The VALUE, determines how the attribute works, in other words it causes the action that changes the font type, size and color to what the property asks for.

A declaration is always signaled by  a { bracket and is ended with a closing }.

A property is separated by a : and a ; ends each declaration.



9  Market Place / Site Promotion / free forum hosting website --with your own ads on: August 16, 2008, 08:44:52 AM
hi
look at this website www.php3b.com
here you can host your forum for free and
you can place your own adds on it

for more details www.php3b.com
10  Revenue & Traffic / Ad Revenue / Re: Adsense VS Adbrite comments on: August 16, 2008, 08:40:54 AM
i have been using both Adsense and Adbrite since long time..but some how i am more comfortable with googleAdsense rather than Adbrite ...i getting more CTR on Adsense ...
Pages: [1]
Powered by SMF | SMF © 2006-2008, Simple Machines LLC