Current location: Hot Scripts Forums » Programming Languages » PHP » A little confused


A little confused

Reply
  #1 (permalink)  
Old 06-20-03, 08:44 AM
sparky sparky is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Question A little confused

Need a little help here. I dont even know if this is right I think it is but It is my first attempt at table joins I have been reading but i just dont get it yet any help would be great thanks


PHP Code:

// open connection to database

$connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!");

// get site survey details
// use a join to get data from different tables
$query = "SELECT survey.cir_id, survey.cust_name, survey.cust_contact, survey.cust_phone, survey.ext, phonelist.phonelist, survey.altphnum, survey.cust_address, power.power, survey.dist_power, powerstrip.powerstrip, equptmount.equptmount, space.space, survey.concerns, ilecextend.ilecextend, focalextend.focalextend, survey.addinfo, survey.tech_name, survey.tech_phone, survey.lec_foc, survey.focal_foc, city.city, survey.survey_date from survey, phonelist, power, powerstrip, equptmount, space, ilecextend, focalextend, city WHERE phonelist.id = survey.f_altphone AND power.id = survey.f_power AND powerstrip.id = survey.f_powerstrip AND equptmount.id = survey.f_eqptmount AND space.id = survey.f_space AND ilecextend.id = survey.f_ilecextend AND focalextend.id = survey.f_focalextend AND city.id = survey.f_city AND survey.cir_id = '$cir_id'";
$result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error());
 echo " <p>$query</p>";
 echo "<br>";
 //echo " <p>$result</p>";
// error check

 if (mysql_num_rows($result) <= 0)
{
 header("Location:error.php");
exit;
}
else
{

// obtain data from resultset
list($cir_id, $cust_name, $cust_contact, $cust_phone, $ext, $phonelist, $altphnum, $cust_address, $power, $dist_power, $powerstrip, $equptmount, $space, $concerns, $ilecextend, $focalextend, $addinfo, $tech_name, $tech_phone, $lec_foc, $focal_foc, $city, $survey_date) = mysql_fetch_row($result);
// clean up
mysql_close($connection);
?>


Html stuff here 


<?
}
?>

Ohh for get it I will attach the other script that this one runs off of


thanks again for all the help
Attached Files
File Type: txt survey_scripts.txt (7.8 KB, 362 views)
__________________
http://www.hitchcock-design.com/trou.../blue/logo.jpg

Smart People use Linux ( I'm trying to be one of them)
Reply With Quote
  #2 (permalink)  
Old 06-20-03, 08:52 AM
jv2222 jv2222 is offline
The Freshmaker
 
Join Date: Jun 2003
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
For a first attempt at a join it's a very complicated one!

Are you sure you need to do it that way?

What are you trying to acheive...

i.e. WHat's your problem.. (rather than your solution)?

J
Reply With Quote
  #3 (permalink)  
Old 06-20-03, 09:19 AM
sparky sparky is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
I am trying to achieve a html form with the input but the problem is that in one db some of the field have just another number which is referred to anothe table. In shot i am trying to pull the info from the db in multiple tables and then put it into a html form that is what i am trying to do If you want send me an email and i will zip all the scripts and send them to you so you can see for yourself what i am trying to do thanks for the help
__________________
http://www.hitchcock-design.com/trou.../blue/logo.jpg

Smart People use Linux ( I'm trying to be one of them)
Reply With Quote
  #4 (permalink)  
Old 06-20-03, 10:00 AM
jv2222 jv2222 is offline
The Freshmaker
 
Join Date: Jun 2003
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
But what is it for? Is it a car database, user database, user forum??

How are you tying all the tables together?
(i.e. based on what unique id system)

Do you really need to split it up into all those tables?

If so why?

(can we forget about the code and just talk in English about what you are trying to do)
__________________
Author of <a href=http://www.hotscripts.com/Detailed/18290.html target=_blank>ezSQL</a> (makes life soooo easy when working with databases)
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Does anyone know what type of script this site uses The Probuilder Script Requests 3 08-22-03 02:03 PM
New Members Please Read ... And Be Confused scrognoid New Members & Introductions 2 08-08-03 01:48 PM


All times are GMT -5. The time now is 07:38 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.