Search String Problem: MySQL SELECT * FROM Dir WHERE Multiple Columns
The search form works but it won't show results for multiple search string words that come from from multiple table fields (columns). i.e. Search String: dave smith new york [dave smith (appears in the name column) new york (appears in the city column)]. Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Mysql Or For Search (select Part Of String)
I am creating a search function and i want to select say only 100 characters (or pref. 40 words) before and after the returned phrase in the results. so far i am using: $get = mysql_query("SELECT * FROM posts WHERE content LIKE '%".quote_smart($query)."%' ORDER BY $order") or die("Cannot search: ".mysql_error()); i tried to use SELECT id, title, tid, uid, LEFT(content, 50) FROM POSTS.... but the query returned none of the content? any ideas? Code:
View Replies !
Searching Multiple Mysql Columns
I'm currently building a database of local businesses, I'm quite new to using php and mysql. While I'm mostly managing to stumble my through it, a couple of things are confusing me. This is one of the things. If anyone can help, that would be really great. Ok, so I've build a search page, and a results page and it works great but there is one problem. Currently it will only search through the 'name' column, but I'd also like it to search through the 'type' column at the same time. This is the code I'm using to fetch the results $colname_Businesses = "-1"; if (isset($_POST['search_par'])) { $colname_Businesses = $_POST['search_par']; } mysql_select_db($database_HBBA_DATABASE, $HBBA_DATABASE); $query_Businesses = sprintf("SELECT * FROM Businesses WHERE name LIKE %s", GetSQLValueString("%" . $colname_Businesses . "%", "text")); $query_limit_Businesses = sprintf("%s LIMIT %d, %d", $query_Businesses, $startRow_Businesses, $maxRows_Businesses); $Businesses = mysql_query($query_limit_Businesses, $HBBA_DATABASE) or die(mysql_error()); $row_Businesses = mysql_fetch_assoc($Businesses); I'm not sure what to add in to make it also search through the 'type' column or where to put that. Can anyone point me in the right direction?
View Replies !
MySql Querying Multiple Columns.
Trying to achieve a like function where the match is achieved if the data is contained in column1 and/or column2 but if the keyword is 2 or more words it looks at both columns not just the one (make sense - if not look at my examples) If the $q variable is Blue Widgets and I use the following query I will get rows returned if Column1 contains Blue Widgets Code:
View Replies !
Multiple Select Box Search Queries
I am trying to create an elegant query together with a multiple select box, tbl_level linked by a foreign key. Sample code below: $sql = "SELECT DISTINCT Firstname,.... FROM .... "; //conditional statement to determine whether WHERE clause is needed if($_POST["FirstName"] != "" { $sql .= "WHERE "; if($_POST["Firstname"] != "") { $sql .= "Firstname LIKE "".addslashes($_POST["Firstname"]).""" } //select box entries array Level if($_POST["Level"] != ""){ $i=0;$query.="( "; foreach ($_POST["Level"] as $val{ if ($i >0){$query.= " AND ";} $query .= "tbl_level.LevelCatID LIKE $val "; $i=1;} $query.=" )"; $query.= " AND tbl_name.NameID = tbl_level.NameID"; } //query database I can't use this as only a single Level select selection works, if user selects more , I can' t search the Level column for 2nd input from the select box using this. I am trying to avoid too many calls to the database, As I have several multiple select options for user to input for searching.Am trying to call single complex query at the end of code.
View Replies !
Multiple Select Into Mysql
I want to insert multiple selection into mysql like this: <select name="time" multiple="multiple"> <option></option> </select> i tried this $arr = $_POST['position']; foreach($arr as $position){ $time=$position; } . $insert = mysql_query("insert into $table values ('NULL', '".$_POST['time']."' but it's not work it insert into mysql just one value i want when the user ctl+click to choose more than one to insert all selected values into mysql.
View Replies !
Multiple Select And Mysql
<select name="time" size="4" multiple="multiple"> <option selected="selected">None Selected</option> <option>Full Time</option> <option>Part Time</option> <option>Contract</option> <option>Temporary</option> you know this select but who know how to enter all of selected values to database couse when i tried to submit the form it's insert just one value from all values selected so how can i fix it.
View Replies !
How To Add Multiple Select From Array To MySQL?
For the last couple of weeks I've been absolutely stuck on inserting multiple select array (medewerker_voornaam[]) values from the field voornaam in table medewerker (employee) into the table software as medewerker_voornaam. I don't get any error message but the values are just not inserted into the database. I've searched just about the whole forum but still got no clue. All the other field values are inserted perfectly except the field medewerker_voornaam upon pressing the submit button. What could be the cause? I suspect that there might be something wrong with _POST not sending the array values to $medewerker_voornaam. Please ignore the names given to the field values in the tables or the code itself (Dutch). Code:
View Replies !
MySQL SELECT Statement - Search A Field In Table
I am trying to search a field in my table for more than one likeness. Can I create a query that says: PHP Code: <?php $query = "SELECT * FROM $table WHERE $search_field (LIKE '%$this%) || (LIKE '%$that%')"; ?> OR, should I just do two different query statements and concatenate the results?
View Replies !
Is There Any Way To Select A MySQL Row By The Length Of A String?
Since there's no forum where I can ask about MySQL, I'm guessing the next best one would be here. Is there any way to select a MySQL row by the length of a string? For example, let's say I have a table with three fields : ID, Name, and Comment. Essentially what I want to do is select rows where the length of Comment is greater than 50 characters.
View Replies !
Displaying Select Multiple Box And Using Mysql Join
i have an edit page where the query lists all the information from the database about a business. each business can have multiple types so i made a many-to-many database and now i need to be able to show all the types that are in the db for each business on the edit page. here is what i have so far but it's only selecting the last type of business in the result. PHP Code:
View Replies !
Select Multiple Dates' Records From MySQL DB
I need to select multiple records from a MySQL DB based on one date value that I get from a form. When I get the date from the form I need to get the values for that date and for the six days before that to display the full week's data. Code:
View Replies !
Select A Number Of Words From A String In Mysql
I have a series of long documents stored in mysql rows. I am trying to figure out how to select a section of of one of those documents to be displayed on the web. Example. Document 2000 words. Query (or php) to select 500 words from the document. (sometime from word 1-to-500, but also sometimes from the middle of the string). Does anyone have any ideas on how to break these large chunks of data into smaller chunks? (I would ideally like to use a SQL query to speed things up, but whatever gets the job done...) .
View Replies !
Multiple Table Search With Mysql
i want to search multiple tables to see whether a certain user has posted more than three times in any category in my database. how can i do a search for the same field in different tables?
View Replies !
MySQL Allows Multiple Words To Search
I need a search that allows multiple words. I got started on the following by code others posted here before. $search = 'S 1' $searcha = Array(); $searcha = explode(" ", $search); $query = "select * from Story where 1=1 "; reset($searcha); while (list($key, $val) = each($searcha)) {$query.= "and Description LIKE '%$val%'"; } Description is a field in my table that contains the description of the story and the story number. ("This story is about garden planting, S 18"). Basically, the code works fine. The thing is when I search for "S 1" (story number 1), because of the "LIKE '%$val%'" clause, the query will basically return everything that starts with a "S" and everything that starts with an "1". So even though I search for "S 1", "S 18" will come up as well.
View Replies !
MySql PHP Multiple Search Prob
Hope am posting in right place, am working on a real estate site, normally i just filter the records by one field but this time they want them filtered by Town, Type, Price and Bedrooms. I have the selection boxes taking their information from the database, but I can't seem to get the form to pass the variables correctly to the next page, either that or my MySql query is all wrong. Was hoping someone might be able to tell me what i'm doing wrong, this is my form on the properties_search.php page: Code:
View Replies !
MySQL Search Function With Multiple Words
I'm using a search function I found online, and I modified it to fit in with my website. Now, I can pretty much understand everything it does, except for this one part, and this part seems to be the problem. When I enter a search, and it searches articles by their title, it will only return one word titles. Anything with multiple words, even if it's the exact same as the title in the database won't come up. Code:
View Replies !
Problems With Multiple Select Form, And MySQL ENUM Types.
I have a form on a PHP page, to add entries to a MySQL database. I have the simple string fields working fine, but I am having trouble with a multiple select listbox filling a MySQL ENUM type. I have assigned my values in the listbox, to match the ENUM values, and if I add a dump_var of the value of listbox posted to the PHP code, it looks sensible: array(3) { [0]=> string(1) "0" [1]=> string(1) "2" [2]=> string(1) "4" } The problem is, how do I parse this into a format I can pass into the MySQL query for the ENUM field?
View Replies !
Combining Two Columns In A Select
I have two tables with the same fields, and I wish to select one field from them. However, i don't want two columns in the result, i want one column which is the first table's column and the second table's column combined. (this is so I can order them and have the order include both tables) Code:
View Replies !
Search Multiple Fields In A Single Table In MySQL
I am trying to create a search facility for my website and need to be able to search multiple fields in a single table in MySQL, I am using dreamweaver, and my PHP and SQL knowledge is minimal, I don’t have a problem being able to search a single field in the database and displaying the results as dreamweaver generates the code for me. The table I am trying to create the search for is called LEWISHAM and the fields within the table I need to search are; towna, townb, townc, postcodea, postcodeb, postcodec. If someone could please help me or point me in the right direction where I could learn more about searches or give me some tips to help that would be fantastic.
View Replies !
String Search - Search A String Of Text & Return A TRUE Value.
I'm trying to do something pretty simple but I'm stuck on what function I need to use. Basically, I have a script where you can type a message and submit it. But I don't want people to use bad words, so if they do, it displays an error message. Example: $string = "Fudge off!" Let's say I don't like the word "fudge" if ( stringcontains('fudge', $string) { echo "No cussing!" } else { Post the string } Does that make sense? I'm basically trying to find some kind of search that will search a string of text looking for the word "fudge" and if it finds it, return a TRUE value. Does such a function exist?
View Replies !
Select Distinct Values In Only 2 Columns
I have a table where a customer may have multiple accounts. I want to eliminate duplicate values for Customer_ID and Account_ID -- regardless of their state or region. I tried this, SELECT (DISTINCT Acct_ID, Cust_ID), Address, City,State, Zip,Country, Contact, State_ID,Region_ID, FROM t_table but it doesn't work. This (below) does work, but it gives 2 records. One record when a person is listed once in a target state, and a second record if that person is listed in an overlapping region. SELECT DISTINCT Acct_ID, Cust_ID, Address, City,State, Zip,Country, Contact, State_ID,Region_ID, FROM t_table (this is the same as) SELECT DISTINCTROW Acct_ID, Cust_ID, Address, City,State, Zip,Country, Contact, State_ID,Region_ID, FROM t_table Is there any other way to select distinct values in only 2 columns?
View Replies !
Columns In A Form Select Element
Can this be done. I am wanting to have columns in my forms select element. I have data of varied length from three fields. Can this be done, or should I try and stuff spaces into the select element to asume columns
View Replies !
SELECT Sorting With Two Columns Not Working.
I've got a problem getting a SELECT query to sort two columns in ascending order. Both the BroadCategory and SubCategory table columns need to sort in alphabetical order. In other words, the BroadCategory needs to sort Art, Automotive, etc.. The SubCategory needs to sort alphabetically within each BroadCategory. Code:
View Replies !
SELECT Query With Information From Other Columns
Table_1 contains name column and yes/no column Table_2 contains name column and number column Typical rows from Table_1: John, yes Bill, no Pete, yes Typical rows from Table_2: John, 2 John, 435 John, 34 Bill, 234 Bill, 19 Here is my question - I want to run a query that says if Table_1 yes/no column = no, then ignore that person. And, if Table_1 contains yes, but the person is not found in Table_2, then ignore that person. Else return people in a SELECT query with information from other columns in both Table_1 AND Table_2. Code:
View Replies !
Select Query Using Mulitple Columns
I have a table with 4 columns called workcat1, workcat2, etc. Whats the best way to write a Select from all the categories against one variable, in this case $ID.?Here's my code. Is there a better way to do this? $query = mysql_query("select * from contractors where workcat1 = '$ID' or where workcat2 = '$ID' or where workcat3 = '$ID' or where workcat4 = '$ID' ");
View Replies !
How To Search Strings Escaped By Mysql Real Escape String()?
I am currently developing an article script and there are Titles and Contents. To prevent sql injection, people say we must use mysql_real_escape_string(). So let's say if there is a Title that says "My Friend's best friend", if I look into the MySQL table record, the text will be saved as "My Friend's best friend", where the apostrophe is escaped. Code:
View Replies !
Updating Multiple Columns.
I have this code: PHP Code: @mysql_select_db(godofgod_p_bb1) or die( "There has been an error in your request. Please try again! Error: Unable to select database."); $query = "UPDATE articles SET Email address = $email, title = $title, body = $article WHERE id = $id"; $result = mysql_query($query); mysql_close(); if($result){ echo "Modified</font>"; }else{ echo"Error: Unable to modify database</font>"; It returns with "Error: Unable to modify database" but why doesn't it execute the query correctly?
View Replies !
Increment Multiple Columns
This looks to me as if it should work to display a list of items in a database, then update a field named "views" for each one (to record the number of views/day or whatever). I just found out that I had a typo. But the question remains: is this the "right" way? while ($row = mysql_fetch_array($sql_whatever)) { if ($row[type] == "Something") { echo ''.$row[pretext].'<A HREF="/?a='.$row[id].'">'.$row[anchor].$row[tracker].'</A> <BR><BR>' $sql_views="UPDATE aff SET views = views + 1 WHERE id = '$row[id]'"; if(!mysql_query($sql_views)) die(mysql_error()); } }
View Replies !
Grouping Multiple Columns
Is there a way to group over multiple columns and still retain the unique count over those columns. Sorry I can't explain it better For instance if I had the structure like this, I'm wanting to group all numbers in column 'c1' and 'c2' and get the overall count. But the tricky part is in 'id' #3 where the same number spans two columns, I want it to count that as 2 and not 1 instance. Code: +----+----+----+ | id | c1 | c2 | +----+----+----+ | 1 | 1 | 3 | | 2 | 1 | 1 | | 3 | 2 | 3 | | 4 | 4 | 1 | | 5 | 3 | 1 | +----+----+----+ What I'm looking to get is: Code: [1] = 5 [3] = 3 [2] = 1 [4] = 1
View Replies !
Adding Multiple Columns
I'm planning on migrating the existing table (member table as is, data and schema) and then wish to add the new columns after an existing column (eg password) and am wondering do I have to add each column at a time with multiple sql statements or can I add them all in one sql. Additional columns: `invisible` set(Ƈ',Ɔ') default Ɔ', `pmfolders` text NOT NULL, `saveogpm` char(3) NOT NULL default '', `emailonpm` char(3) NOT NULL default '', `useoldpm` char(3) NOT NULL default '', `webcam` varchar(75) default NULL,
View Replies !
Multiple Columns On While Loop
I am very familiar with using the while loop command but i would like to use it and put the results into two columns the html code when finished, should look like this. <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td align="left" valign="top">$sponsor1</td> <td align="left" valign="top">$sponsor2</td> </tr> <tr> <td align="left" valign="top">$sponsor3</td> <td align="left" valign="top">$sponsor4</td> </tr> </table> I can make my while loop with them all in a single row single column scheme, but how do i make them go say, 2 across and 10 down?
View Replies !
Updating One Columns With Multiple Fields
I want to update column, teamid. I am trying to update all 12 fields for teamid at same time using Form Processor (HTML). When I send it to next page to update the database, I am getting one result for all fields so I am not telling it how to update properly. The row# for each column is fixed and will not increase above 12 rows and the goal is to update team name based on seed #1-12. There is seed column next to teamid column, which is fixed and will be important for other purpose. Code:
View Replies !
Pagination - Multiple Rows And Columns
i would like to paginate a set of results. i would like 12 results per page, ideally 4 columns over 3 rows. i can do the pagination and rows part no problem but am struggling with writing the columns. could any point me to a good tutorial or provide some sample code?
View Replies !
Multiple Select From Listbox And Execute A Sql Query Select Statement
Supposing i have a html form with 2 listbox and i name it status and resolution. So it goes <select name='status[]'>... <select name='resolution[]'> Then i have a another php page. $status = $_POST['status']; $resolution = $_POST['resolution']; Now my question is, how do i do the sql query statement? mysql_query("SELECT * from bugs where status=$status and resolution=$resolution"); The problem is, i select 3 options form the status listbox eg. new, closed, duplicate. And from the resolution, i chose fixed, invalid.
View Replies !
Sorting DB Entries Over Multiple Pages (and Columns)
I am making an image gallery, and have previously had problems sorting the database entries over several columns, that is now sorted. However, I don't know how to make the entries on page 2 to begin from image 10, page 3 to begin from image 19 etc (given that I am using a 3x3 table so 9 images per page. Here is the code that prints the URLs of the images (i am working with text, rather than IMG tags until it works): PHP Code:
View Replies !
Displaying Data From Multiple Tables, Allowing User To Narrow Down By Certain Columns
I've got a three table database, with tables member, race, and results. The site is just for a running club to record their race results and keep details on each member. I want to have a page where users can view race results, i.e. display the members name (stored in member) the race they took part in, the data of the race (stored in race), and the time they achieved (stored in results). I understand i will need a join query to do this, this isn't the part thats bothering me.. Code:
View Replies !
Search DB Using Multiple Search Criteria On Web Form
I have a mysql database with a table with fields ( surname, company, speciality etc..) I created a simple form so people can search using criterias ( a search field which query all fields , a drop down with the list of surname, drop down with the list of speciality, drop down with a list of countries ). My system works perfectly well as long as I use only one criteria, However if I select "Plumber" as the speciality and "Scotland" as country, I will get all the entries for Scotland ( even if the speciality is not "plumber") and I will get all the entries for "Plumber" ( even if the coutry is not "Scotland"). Code:
View Replies !
|