MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 6th, 2006, 09:26 AM
yorkshirelad yorkshirelad is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 3 yorkshirelad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 37 m 6 sec
Reputation Power: 0
Exclamation Searching and displaying results from mysql database using PHP

Hi there

I am new to this but i have been trying for a few days to get the result i want.

I have a table called phonebook and in there is the fields
pb_id
pb_surname
pb_forename
pb_tel_ext

I would like to be able to seach for forename or surname or forename and surename and it do display everything for them results including pb_ext_tel

Sounds like alot but i am learning and if anyone could help i would be most thankful

Reply With Quote
  #2  
Old December 6th, 2006, 11:48 AM
yorkshirelad yorkshirelad is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 3 yorkshirelad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 37 m 6 sec
Reputation Power: 0
Ok...

As an update i have it working

My code is

PHP Code:
<?php
$conn 
mysql_connect ("localhost""******""******") or die ('I cannot connect to the database because: ' mysql_error());
$selected mysql_select_db ("bdct")
or die (
"Could not select database");


// PHP Search Script

$sql "select * from phonebook, where pb_surname = '".$_POST['seek']."' or pb_forename = '"$_POST['seek'] ."' or pb_job_title = '"$_POST['seek'] ."'";
$result mysql_query($sql,$conn)or die (mysql_error());


if (
mysql_num_rows($result)==0){
echo 
"No Match Found";
}else{
while (
$row mysql_fetch_array($result)){
echo 
"Name: " .$row['pb_forename']." ".$row["pb_surname"]."<br>";
echo 
"Job Title: ".$row['pb_job_title']."<br>";
// echo "Department: ".$row['department_name']."<br>";
// echo "Directorate: ".$row['directorate_name']."<br>";
//echo "Site: ".$row['site_name']."<br>";
echo "Phone #: ".$row['pb_tel_ext']."<br>";
echo 
"Email Address: ".$row['pb_email_address']."<br>";
echo 
"<br>";
echo 
"---------------------------------------------------------------------"."<br>";
}
}

mysql_close();
?>


SO i am learning hehe but now i would like to do something more complicated

I have 1 other tables called Sites and in that table is a site_id

Now back in the table phonebook there is a pb_site_id which every record has and that corispondes to the site_id in sites.

How can i get it to go and get the right information from the sites table using the pb_site_id of each record and then echo that out with the the rest of the information.

Please help or advise, i am enjoying learning this

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Searching and displaying results from mysql database using PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT