Results 1 to 2 of 2

Thread: Array in MySQL used to find rows?

  1. #1
    Join Date
    Sep 2008
    Posts
    899

    Array in MySQL used to find rows?

    I've got a need to insert mulitple town names into one MySQL field named "towns". I then need to access information in a query from all the rows that have certain town names. Not a combination of town names, but from a list of town names or just one town name. In other words, row A, field "towns" would have Buffalo, Youngstown, Pittsburgh. row B, field "towns" would have Atlanta, Philidelphia, Roanoke...etc. My query wants the information from field "Event" from all rows with Roanoke in the "towns" field. How should the array in "towns" appear in the dbase so I can query by Roanoke successfully?

    I put simply

    Atlanta, Philidelphia, Roanoke,

    in the "towns" field, but my query won't recognize the single town Roanoke even when I use the "like" condition.

  2. #2
    Join Date
    Nov 2008
    Posts
    25
    hi
    i just attempted to put up the data in the database as u told and
    tried to get the row from the database that matches the specified string within the data in each row
    sorry i don't got a solution through a query but
    we may use php functions as shown below

    $query="select towns, events from table";
    $result=mysql_query($query) or die("Couldn't execute query :".mysql_error());
    while($row=mysql_fetch_array($result))
    {
    $value="delhi";
    if(strchr($row['data_value'],"delhi"))
    {
    echo $row['data_value'];
    echo "-----------Match Found!!<br>";
    }
    else
    {
    echo "-----------No Match Found!!<br>";
    }

    we may fetch the value of string to be matched from the previous form (here i use "delhi") and further match accordingly
    and perform further functions after it gets matched as per requirement
    instead of just echo it
    sorry if i misunderstood it

Similar Threads

  1. New Free MySQL GUI
    By expert-database in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 21 Dec 2006, 05:45 PM
  2. insert values from indexed array into html form button (PHP)
    By boognish in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 10 Jan 2006, 07:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •