473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

No search result is displayed

Hi,
Im just stuck up with a small query. In my database ive a table called specialization which is dependent on qualification. In specialization i ve 3 fields: QualificationId, SpecializationId,SpecializtionArea. in specialization table there are SpecializationArea with same name but with diferent SpecializationId and QualificationId. Now when i enter search page and select to search based on specialization then it doesnt displays the results for search. In the userdetails table specialization and qualification are stored with thier id values.
Ive used the query below. Is the query correct?


Expand|Select|Wrap|Line Numbers
  1. //Create Query for Specialization
  2. if($dropdown == Specialization){
  3. $query= mysql_query("SELECT QualificationId,SpecializationId FROM specialization WHERE SpecializationArea='$search'");
  4. while($nt=mysql_fetch_array($query)){
  5. //echo "" .$nt['QualificationId']. "" .$nt['SpecializationId']. "<BR>";
  6. $result = "SELECT UserName FROM userdetails WHERE Qualification='$nt[QualificationId]' AND Specialization='$nt[SpecializationId]'" or die (mysql_error()); 
  7. $data = mysql_query($result) or die(mysql_error()); 
  8. }
  9. }
  10.  
Your help will be appreciated.

Thanks
Srushti
Mar 14 '08 #1
5 1405
debasisdas
8,127 Expert 4TB
First ensure that data exists in database as per your search conditions.

It is always better to use LIKE instead of using = for search operation.
Mar 14 '08 #2
First ensure that data exists in database as per your search conditions.

It is always better to use LIKE instead of using = for search operation.
Thanks. There is data in the userdetails table as per the condition.
Mar 14 '08 #3
code green
1,726 Expert 1GB
Your query looks fine it is the php code that looks wrong.
Some debugging statements would help!
Anyway[PHP]if($dropdown == Specialization){[/PHP] Here php will treat Specialization as a constant.
If you had error_reporting() switched on as recommended in this forum
then this would have flashed a warning
What is Specialization meant to be, a string?
[PHP]if($dropdown == 'Specialization'){[/PHP]
Mar 14 '08 #4
Here Specialization is a constant. Its the value that i ve assigned to it in drop down. The other constants work fine and displays the result. Its not going in this while loop even if matches are there. I dont think theres a problem with this loop coz it works well for other search criterias and displays the results.

Expand|Select|Wrap|Line Numbers
  1. $resultnum = mysql_num_rows($data); // Just print $resultnum if you want to show how many results returned
  2. if($resultnum>0) { // Echos out matches if anything was found
  3. while($info=mysql_fetch_array($data)){
  4. //Print it out to page 
  5. echo "" .$info['FullName']. "";
  6. }// end of while
  7. }//end of if
  8.  
Mar 14 '08 #5
code green
1,726 Expert 1GB
I am suprised this works [PHP]$result = "SELECT UserName FROM userdetails WHERE Qualification='$nt[QualificationId]'
AND Specialization='$nt[SpecializationId]'" or die (mysql_error()); [/PHP] Arrays in query strings always produce an error for me and require curly braces [PHP]$result = "SELECT UserName FROM userdetails WHERE Qualification='{$nt[QualificationId]}'
AND Specialization='{$nt[SpecializationId]}'" or die (mysql_error()); [/PHP] Don't understand what you mean
Here Specialization is a constant. Its the value that i ve assigned to it in drop down
Mar 14 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sheau Wei | last post by:
Below is my search engine code. I realize that the function was very limitied because i cannot searching the "NamaPealatan"(name of tools) compatible to the either categories Operasi or Balai or...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
1
by: abhijan | last post by:
We have come across a typical problem with Site Search Pro Gold 2.0 - Any text/word/searchkey having apostrophe mark are not getting indexed by the system as the search result is not displaying any...
10
by: jonathan184 | last post by:
Hi I tried getting this to work through dreamweaver but it did not. So i found a n example on the internet , i followed everything exactly the search script does not work. Could somebody help me...
4
by: bendlam | last post by:
I have a page that contains search criteria and when you click on the search button it causes a post back that populates a dataview on the same page. One of the gridview columns contains a link...
13
by: jfarthing | last post by:
Hi everyone! I am using the script below to search a db. If the is more than one match in the db, all goes well. But if there is only one match in the db, nothing gets displayed. Any...
7
by: =?Utf-8?B?SklNLkgu?= | last post by:
How to get search engines crawl data I have a web application that uses user controls and pulls data directly from database and shows it to users in the internet. So there is not html that has the...
8
by: agarwalsrushti | last post by:
Hi, Ive made a search page. It displays the name of the users which is the result of search. Now i want that if we click on the name it should open another page in which the profile of the user will...
5
by: Kalpana Durairaj | last post by:
I want to insert my image within search result anchor(say google search results). <a href="http://www.codeproject.com">Code Project <!-- Google search result link--> <img src="myimage.png"...
0
by: =?Utf-8?B?QW5pdGhh?= | last post by:
Hi, Currently for Announcement library a custom column "publish start date" is added and under the search result webpart changed the xslt by filtering the result based on the publish start date...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.