phpForm.net

Home | Forums | PHP Tutorials | MySQL Tutorials | CSS Tutorials | PHP Forms | About Domains

Free PHP Scripts



 PHP Form Image Upload
 PHP Form File Upload
 Advanced PHP Contact Form
 Link Base L.1.0.
 Link Base 1.1.
 Link Base 2.0.
 Link Generator Script
 PHP Comments
 Comments 1.1.
 Captcha v1
 Meta Tags Generator 1.1.
 E-Cards 1.1.
 Feedback Form with Captcha
 Tell A Friend
 Contact Us - PHP Form
 Contact Us 2.0. - PHP Form
 Contact Us with Captcha
 HTML Button Generator
 PopUp Window Code Generator
 Site Recommendation
 Send This Link
 GuestBook
 Bookmark Script
 ShoutBox 1.1.
 ShoutBox 20.
 RSS Feeds

PHP Tutorials

 PHP Tutorials
 PHP Form Validation
 PHP Mail
 Sending HTML Email With Images
 Creating a CAPTCHA with PHP
 Creating a CAPTCHA with PHP 2
 Math CAPTCHA with PHP
 Bad Word Filter with PHP
 Bookmark Current Page
 Timed Redirect JavaScript
 PHP Redirect
 Upload Image With PHP
 Upload Image With PHP 2
 Upload and Resize with PHP
 Upload File With PHP
 PHP Cookies and Sessions

PHP Basic

 PHP Date
 PHP $_GET Function
 PHP $_POST Function
 PHP $_SESSION
 PHP str_replace
 PHP fwrite
 PHP explode
 PHP setcookie

MySQL Tutorials

 MySQL Basic Functions
 Create dynamic Web Pages with PHP & MySQL
 MySQL - Select from two tables
 RSS and MYSQL
 MySQL Inner Join

Image Functions

 imagecreate
 imageline

Smarty Tutorials

 Smarty Dynamic Web Pages with PHP & MySQL

CSS Tutorials

 Show/Hide Div with CSS
 Images In Textarea
 Email Link

Links

 Css Generators
 JaRobot.com
 Facesmail.com
 Hallo Oglasi
 PHP Resource Index

MySQL Inner Join

config.php
Code:
<?php 
//MySQL Configuration
//DB Host (Normally 'localhost')
$dbhost 'localhost';
//DB Database Username
$dbusername 'root';
//DB Database User Password
$dbpassword 'mypassword';
//DB Database Name
$dbname 'mydbname';
//mysql_connect function
$conn=mysql_connect($dbhost$dbusername$dbpassword);
if(!
$conn) :
   die(
'Could not connect: ' mysql_error());
endif;
$db=mysql_select_db($dbname$conn);
if(!
$db) :
   die (
'Cant connect to database : ' mysql_error());
endif;
?>
2.install.php
Code:
<?php
//make a MySQL connection
include('config.php');
//create a MySQL table in the selected database
mysql_query("CREATE TABLE `text` (
  `textid` int(11) NOT NULL auto_increment,
  `textvalue` text collate utf8_unicode_ci,
   PRIMARY KEY  (`textid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 
COLLATE=utf8_unicode_ci AUTO_INCREMENT=1"
)
or die(
mysql_error());
mysql_query("CREATE TABLE `numbers` (
  `numberid` int(11) NOT NULL auto_increment,
  `numbervalue` text collate utf8_unicode_ci,
   PRIMARY KEY  (`numberid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 
COLLATE=utf8_unicode_ci AUTO_INCREMENT=1"
)
or die(
mysql_error());
?>
3.index.php
Code:
<title>Index Page</title>
<center><h2>INDEX</h2></center><BR>
<?php
//make a MySQL connection
include('config.php');
echo 
"&nbsp;<a href=\"insert.php\">INSERT PHP</a><br>";
//Get data from 2 tables
//*=select everything from table
$result mysql_query("SELECT * FROM text 
INNER JOIN numbers 
ON numbers.numberid = text.textid"

or die(
mysql_error()); 
while(
$link=mysql_fetch_array($result)){
//echo (display) a link using $link
echo $link['numbervalue'];
echo 
"-";
echo 
$link['textvalue'];
echo 
"<br>";
}
?>
4.insert.php
Code:
<title>Insert Page</title>
<center><h2>INSERT PAGE</h2></center><BR>
<?php
//make a MySQL connection
include('config.php');
//to check if a submit button was clicked, use this...
if(isset($_POST['submit']))
{
$textvalue $_POST['textvalue'];
$numbervalue $_POST['numbervalue'];
//The INSERT INTO statement is used to add new records 
//to a database table.
mysql_query("INSERT INTO text (textvalue)
VALUES ('$textvalue')"
)
or die(
mysql_error());  
mysql_query("INSERT INTO numbers (numbervalue)
VALUES ('$numbervalue')"
)
or die(
mysql_error());  
}else{
?>
<TABLE><TR><TD>
<form method="post" action="insert.php">
Textvalue: 
</TD>
<TD>
<input name="textvalue" size="60" maxlength="255">
</TD></TR>
<TR><TD>
Numbervalue:
</TD>
<TD>
<input name="numbervalue" size="60" maxlength="255">
</TD></TR>
<TR><TD>
<input type="submit" name="submit" value="submit">
</form>
</TD></TR></TABLE>
<?php
}
?>


discuss this topic to forum



© PHPForm.net 2007 All Rights Reserved | Privacy Policy