Jump to content


Photo

Recalling specific data through PHP.. (SOLVED)


  • Please log in to reply
3 replies to this topic

#1 SephirGaine

SephirGaine
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 01 August 2006 - 08:50 PM

Hey ya'll. Not sure if anyone's going to remember this (doubt it), but I've got a work-order request form working on my website, and I've got a drop-down box that recalls data from a row named 'Name' from a database and returns all the entries into the drop-down. Now here's where I'm having trouble.

When they submit the form I'd like to recall all the information on a technician that's within the database (only 3 rows per tech), depending on what Name they choose on that dropdown box. I've got two problems here. One, how do I assign a variable to the dropdown option? Is it as simply as giving the <option> tag a name?

My second question is more of a statement. I have very little experience with recalling and displaying data from a database. My first instinct would be to just use the echo statement, which may or may not work. But here's my biggest problem, how would I recall the data on the specific tech that they chose? Just to expand/clarify, I have three rows per technician: Name, Email, and Phone. Every entry within 'Name' is displayed as an option in the form. Depending on which option they choose, I want the next page to display all three rows of data for that technician.

Hope I don't sound too confused -- because I am. Kinda tough to explain what I'm looking for.

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 01 August 2006 - 10:09 PM

The answer to the first question is "Yes, it's that simple".

The answer to the second is ... I can't see how what you want is possible unless there is an obvious relationship between a technician's name, phone, email.  Why don't you have name, phone, email all in the same 'row' (database record)?  The order of rows in a MySQL database has no relevance to relationships between rows and data contained in them.
Legend has it that reading the manual never killed anyone.
My site

#3 jcbarr

jcbarr
  • Members
  • PipPipPip
  • Advanced Member
  • 219 posts

Posted 01 August 2006 - 10:14 PM

Each tech should have their own row, and then you just select the data from the fields in the same row with the name that they selected and ech othat to the page.

#4 SephirGaine

SephirGaine
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 01 August 2006 - 10:33 PM

Sorry, that's what I meant. They each have their own row, and with entries named 'Name', 'Email', and 'Phone'. Unfortunately I wasn't sure what the name for it REALLY was.

But, after looking through some of my own previous code, as well as a few other threads here I was able to piece together some PHP and it seems to work just fine. This is what I came up with..

<?php
	$query = "SELECT * FROM `Techs` where name='$Tech'";
		$result = mysql_query($query) or die(mysql_error());
		while ($text = mysql_Fetch_assoc($result)) {
			echo ''.$text['Name'].'<br>
			'.$text['Phone'].'<br>
			'.$text['Email'].'';
  }
?>

If anything looks horrendous, lemme know.. but it seems to work.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users