User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 402,386 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,920 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums

mysql search and display data help....

Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: mysql search and display data help....

  #6  
Oct 26th, 2007
For all:
all the "%" do is tell MySQL it is a wild card. So "am" with "%am%" pulls up anything with any number of letters before the combo "am" and any number of letters after:

name - n am e
tame - t am e
madam - mad am
ambulance - am bulance

understand? So if you're searching the database for a userid, you do not want the LIKE scenario, you want the normal "userid" not, "%userid%".
Furthermore, "%am" will pull only words beginning with anything but ending with am, like "sam", and same as the other way "am%" pulls words like "ambuleance".

For your search page, if you only want one result, add this line to your SQL query: "LIMIT 1"
This way it will only return one result and not waste memory holding the other 200 results that are being unused.

For homienick
So, following the code above as I am not a PHP programmer, use it like below to pull your users info:
<?php
  $userid = $_POST["userid"];

  mysql_connect ("localhost", "myuser", "mypassword");
  mysql_select_db ("mydatabase");

  $query = "SELECT mycolumn FROM mytable WHERE mycolumn=$userid"
  $result = mysql_query ($query);
  if ($result) {
    //if this userid exists, do your coding here
  }else{
    //if this userid does not exist, do your coding here
  }
?>
Reply With Quote  
All times are GMT -4. The time now is 1:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC