I writed SQL like:
– phpMyAdmin SQL Dump
– version 2.7.0-pl2
– http://www.phpmyadmin.net
– Host: localhost
– Generation Time: Mar 13, 2012 at 03:58 AM
– Server version: 5.0.18
– PHP Version: 5.1.2
– Database: example
–
– Table structure for table products
CREATE TABLE products
(
id
int(10) NOT NULL auto_increment,
name
varchar(25) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
–
– Dumping data for table products
INSERT INTO products
VALUES (1, ‘Computer’);
INSERT INTO products
VALUES (2, ‘Telephone’);
And 2 file:
1. index.php
<?php
$host=“localhost”;
$username=“root”;
$password=“”;
$db_name=“example”;
$con = mysql_connect(“$host”, “$username”, “$password”)or die(“cannot connect”);
$tbl_name=“products”;
mysql_select_db(“$db_name”)or die(“Eror…”);
$sql=“SELECT * FROM $tbl_name”;
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count<>0)
{
while($row=mysql_fetch_assoc($result))
{
$id=$row[id];
$name=$row[name];
echo"<li><a href='test.php?t=".$id."'>$name</a></li>";
}
}
else
{
echo"Product is zero";
}
?>
2. test.php
<?php
$host=“localhost”;
$username=“root”;
$password=“”;
$db_name=“example”;
$con = mysql_connect(“$host”, “$username”, “$password”)or die(“cannot connect”);
$t=$_REQUEST[“t”];
$tbl_name=“products”;
mysql_select_db(“$db_name”)or die(“Eror…”);
$sql=“SELECT * FROM $tbl_name”;
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count<>0)
{
while($row=mysql_fetch_assoc($result))
{
$id=$row[id];
$name=$row[name];
if($t==$id)
{
echo"$name</li>";
}
}
}
else
{
echo"Product is zero";
}
?>
I want to when click link “Computer”,“Telephone” on file index.php.
and file : test.php will change title like : “Computer”,“Telephone”
HELP ME!
Thanks Everyone…