Page 1 of 1

Another DropList problem

Posted: Thu Jan 12, 2006 9:55 am
by galligraph
I need the following information from the database(2 tables, question and category). Other table includes CategoryId and CategoryText.

Code: Select all

$query = ("select Id, Answer, Type, QuestionText, Points, CategoryText FROM question, category where question.CategoryId=category.CategoryId and question.Id='$question'");
Id value comes from the list. So I'm tryin 2 get 1 particular questions information so u can change the information if needed. I'm using droplist and I need 2 get questions CategoryText 2 the Droplist. It should show the feeded CategoryText first but u can change it if needed. So how 2 get those values 2 the droplist. Now I get only the feeded CategoryText there, nothin' else. So it should show the feeded first but there should be other Categories also...

Code: Select all

while ($row = mysql_fetch_array($query)){

	echo "<option value='".$row['CategoryId']."'>".$row['CategoryText'];}"</option> ";
         "</select>"; "<td> </tr>";
If somebody understand what i'm tryin' 2 say and could help me I'll appreciate it. :)

Posted: Thu Jan 12, 2006 10:10 am
by shiznatix
first off, PLEASE use the word "to" instead of "2", its only 1 more key you have to press.

second, i think your problem is in your query. use LEFT JOIN (search it on google) and you will be able to do it properly if your 2nd table has the id of the first to where you need to link it to. it will be somthing like

Code: Select all

SELECT
  Id, Answer, Type, QuestionText, Points, CategoryText
FROM
  question
LEFT JOIN
  category ON question.CategoryId = category.CategoryId
WHERE
  question.Id='$question'
this is not gaurenteed to work but it might steer you in the right direction.

Posted: Thu Jan 12, 2006 11:08 am
by galligraph
Thx for the reply but it did't help me this time. I think my query is exactly the same as yours just made differently(brings same value). Do I need more than one query or is it possible to make this with one? Maybe need some other changes also.. Don't know. :wink:

Posted: Fri Jan 13, 2006 9:56 pm
by galligraph
Hello ya'll! I know ur much more into this subject than I'm so hopefully somebody could help my ass out... I just dont know how to fix this one... damn.. If u got any suggestions I'll apprecieate... Pz! :wink:

Posted: Fri Jan 13, 2006 10:27 pm
by RobertGonzalez
Post your table structure from a phpMyAdmin structure dump, then post what value you want as the option id and what value you want for the option text.