Log in

View Full Version : A strange problem.



sujith787
08-22-2007, 09:34 AM
hai
i have a mysql table named customer:

s.no name phone
----------------------------------
100 sam 2453
210 george 5637
98 mark 7382


i have a page name index.php
it displays s.no of the customer table like this


The source code is:
--------------------
<a href="phone.php">100</a>
<a href="phone.php">210</a>
<a href="phone.php">98</a>

ie output is
--------
100
210
98


phone.php page is simple. its displaying the phone number of clicked customer.
if a user click 100 phone.php should display 2453. (ie phone of s.no 100)
if a user click 98 phone.php should display 7382 (ie phone of s.no 98)


how can i do this.

tech_support
08-22-2007, 10:39 AM
You can use SELECT... to do this.

Here's a good place to start.
http://www.php-mysql-tutorial.com/

sujith787
08-22-2007, 10:42 AM
thank you tech_support.
select option is a good choice.

but with out using any form i want to solve this problem. using forms, using select option all r working fine

withour using this forms i want the solution.

thetestingsite
08-22-2007, 11:01 AM
Make your links like so:



<a href="phone.php?id={id_of_customer}">{id_of_customer}</a>


Then in phone.php make it look something like so:



<?php
require('connection.php'); //database connection

$id = $_GET['id'];

$info = mysql_query("SELECT * FROM `customers` WHERE `s.no`='$id'");
if (mysql_num_rows($info)) { //if found in table
while ($qry = mysql_fetch_array($info)) {
?>
Customer Name: <?php echo $qry['name'];?> <BR>
Phone Number: <?php echo $qry['phone'];?>
<?php
}
}
?>


Hope this helps.

sujith787
08-22-2007, 02:06 PM
thank you mr.thetestingsite.

i got the solution from your code.

thank you verymuch.

tech_support
08-23-2007, 06:56 AM
thank you tech_support.
select option is a good choice.

but with out using any form i want to solve this problem. using forms, using select option all r working fine

withour using this forms i want the solution.
I was talking about MySQL Select....