Current location: Hot Scripts Forums » Programming Languages » PHP » Need Help Searching SQL database with PHP


Need Help Searching SQL database with PHP

Reply
  #1 (permalink)  
Old 07-18-05, 06:17 PM
jasonweaver jasonweaver is offline
New Member
 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Need Help Searching SQL database with PHP

I have a database set up with one table called Number. I am trying to query the database with a search button to display the searched results. In my code I have connected to my database but I am having trouble to display any results that are searched. Here is the code I am using after I connect:

$SQL = "SELECT * FROM Number WHERE Number LIKE '%$box%' LIMIT 10";


$result = mysql_query($SQL) or die(mysql_error("Error in query"));


while($row = mysql_fetch_array($result))
{
echo $row['Number'];
}

?>

If anyone has any better code or know how to add this search feature to my site that would be great. Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-18-05, 07:27 PM
sszettella sszettella is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
What are the columns on the Number table? What column are you trying to display? My guess is that there is no column called "Number", and therefore you are getting nothing from $row['Number']. If you want to display all columns in the matched row, you might try something like:
Code:
while($row = mysql_fetch_array($result)) {
  foreach($row as $col) {  // for every element in the $row array, get the value
    echo $col;
  }
  echo "<br>"; // to seperate the rows
}
Hope that helps
__________________
Steve Szettella
4word systems
http://www.4wordsystems.com
http://szettella.blogspot.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
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
PHP multi-dimensional array sorting issue aqw PHP 2 06-25-05 12:09 AM
PHP search database korro Script Requests 0 04-17-05 06:17 AM
how do u do database search in php and sql? genux33 PHP 0 09-16-04 02:42 AM
How Can i connect sql database with php? I'm New in PHP zahid PHP 1 06-01-04 11:12 AM
change my field in this example sal21 ASP 3 07-14-03 03:49 AM


All times are GMT -5. The time now is 09:32 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.