Excluding String In Select
I have been working on modifying this code to exclude the genre of Christmas from the query. No matter where I add a genre != 'Christmas' I get errors. Any ideas? I want to exclude any genres that are Christmas. PHP Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How Can I Use Getdate(...) Excluding TZ.
My timezone is GMT +2 So when I do a $date = getdate( 0 ); I get: $date = { ['seconds'] (integer) = 0 ['minutes'] (integer) = 0 ['hours'] (integer) = 2 //<-- Hour is not 0 but +2 ['mday'] (integer) = 1 ['wday'] (integer) = 4 ['mon'] (integer) = 1 ['year'] (integer) = 1970 ['yday'] (integer) = 0 ['weekday'] (string) = "Thursday" ['month'] (string) = "January" [Ɔ'] (integer) = 0 } I cannot do: $date = getdate( 0 - (2*3600) ); as negative numbers are not accepted, (on the window server). So how can I do getdate( 0 ) and return the value without it been converted by the server TZ. Using setlocal(...) is also a bit of a Hacky kind of way of doing things.
Select From Table Where Field = String
How to select all lines containg a string (located in $pastmove) in the moves column. I tried several ways, for example: $requete="SELECT moves, opening_id FROM suitemove where moves like '%".$pastmove."%'"; but did not succeed;
Select Each Word Match On A String
here if we give the keyword as sony discman shock . the keyword is the product name. here i have to select datas. here sony discman is the product name of same. shock is another product. here i separate the string using explode function, what the thing three records are retrieved. ie.,the same record of product name is retrieved twice.how to solve this .
How To SELECT Records WHERE Field Contains A Particular String?
I need to SELECT records WHERE a string matches the content of a field... eg. I have field values like: Phone namePhone name pinkPhone name bluePhone name polka-dot What I want is to have a MySQL query which selects ALL records which match the search term, eg. 'Phone name' returns all of the above, but not 'Phone': Currently my query looks like this: SELECT * FROM [table_name] WHERE [field_name] LIKE '%s' ORDER BY [value] ASC
Excluding Records From Repeat Region In PHP
PHP 4 MySQL 4.0.20 DW MW 2004 7.01 This problem is giving me a bit of a headache, and I'm getting nowhere with it so thought I'd open it up to all, any help would be greatly appreciated. OVERVIEW -------- I am creating an ecommerce site for an IT reseller. Customers must log in to use the purchasing side of the site. Individual customers that log in have certain products that they are not allowed to see but this varies between users, so no two customer may have the same hidden products. To set this scenario up, I have a main table containing the whole range of products the reseller sells, and a table referencing the hidden products, consisting of a "User ID" column and a "Product ID" column. In MySQL 4.1 I would have no problem running a subselect query and pulling just allowed products into a recordset, unfortunately I am running 4.0 which does not support this and I am not in a position to upgrade the server. I am currently getting around the problem by creating an 'Allowed products' table rather thatn 'hidden' and listing "User ID" and "Product ID" for all products they are allowed to view. This causes a bit of a problem as the reseller has about 6500 purchasing customers and 20000 products, so the 'allowed' table would grow incredibly huge, thats 130,000,000 records if all are allowed! ---- The way I am planning to get around this problem is keep the 'Hidden' table, create TWO recordsets on a page - one, rsFetchProducts, a "SELECT * FROM Products" and the other, rsFetchHiddenProducts, "SELECT Product_ID from HiddenProducts where User_ID = 'users id number'". I then apply a repeat region to rsFetchProducts to list all data from the recordset. ****************** What I need to do next is to filter this repeat region with PHP, basically saying - if any of the Product_ID(s) in rsFetchProducts is equal to any of the Product_ID(s) in rsFetchHiddenProducts, DON'T include them in the repeat region. ****************** This must be possible, but by background on PHP isn't too great, I know I need an if condition in the repeat region, but am not sure if I need to filter directly from the recordset or pop it into an array first and then filter.
Ordering Alphabetical In Secondary Select String
Does anyone have a suggestion how I can order a list with names in a secondary select string. The first string selects a number of locations where people work From this string I get several id's form people (in the location table there are no names but id's form the people table) that work on those locations No I make another select to get the name form the people table using the id I got before. I would like to have the table ordered alphabetical by the name of the people Since the number op people is very long is will be to slow working the other way around (first selecting people and then looking for the location) Example: Location 1 Name A Name B Name C Location 3 Name D Name E Location 5 Name F Location 2 Name G Location 9 Name H Location 7 Name I
PHP String Concatination With Html Select Combo Box
I have problem in PHP String concatination with html select combo box. There are 3 files addressbook.sql : concat1.php concat2.php In concat1.php , if we select User Name in combo box & give input as 3 in text box. It display following output subhash kanade,3 sk@yahoo.com But, it is not display in that way. So, please see that code & tell me correction. addressbook.sql -- Table structure for table `addressbook` -- CREATE TABLE `addressbook` ( `id` int(11) NOT NULL auto_increment, `name` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; -- -- Dumping data for table `addressbook` -- INSERT INTO `addressbook` (`id`, `name`, `email`) VALUES (1, 'pramod kumar', 'pk@hotmail.com'), (2, 'vinod wagh', 'vinod@rediff.com'), (3, 'subhash kanade', 'sk@yahoo.com'), (4, 'ketan patil', 'kp@hotmail.com'); concat1.php <?php mysql_connect("localhost","root")or die("Database Failed"); mysql_select_db("pradeep")or die("Failed to Connect Database"); $arr=array("concat(concat(name,','),id)","email"); $str="select ".$arr[0].", ".$arr[1]." from addressbook"; $res=mysql_query($str) or die("resultset error"); echo "<table><tr><th>User</th><th>Email</th></tr>"; while($row=mysql_fetch_array($res)){ echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td></tr>"; }
List Files In Directory Excluding Directories
I have the following code which I require to get the list of files in a given directory. However in that given directory I have other directories as well. I thought the second if condition was taking care of excluding the directories, but its not. I get a bunch of directories listed along with the files. PHP Code:
Excluding Parenthesis, Space And Dashes From Phone Number
I store phone number in mysql as integer, e.g. (123) 456-7890 is stored as 1234567890. though, in search form they usually type in a phone number with parenthesis/space/dashes. I have to extract numbers before I search through mysql. currently, I use eregi_replace() function, several times, to do the job:...
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.
Select Statement - Select Random ID #
I have made up a page that pull info on 13 branches of stores onto one main page. It's basically there to display all the branches on one page... then you click on the one you're interested in and then you go to a more detailed page. Back to the main page. On the top, there's kind of a featured branch that has a bigger picture and bigger title but it's still getting pul pulled from the same table etc etc etc. In order for me to avoid favortism to one branch (and for other branches to start complaining) I want to ramdomized the order every time someone came to page but I have no idea how. right now I have a super simple select statement.
Attaching A String To A Normal Word Without Loosing The String
In my database I have content rows that are either called <contentname>_title or <contentname>_fulltext. now when someone clicks a link on the site it goes to index.php?action=<contentname> so I guess you see where im going.. when someone goes to such a section index.php sees $action is used and attaches it to _title and _fulltext, so u get: $action_fulltext.. basicly of cuz php now sees it as one string '$action_fulltext' and not '$action'_fulltext.
Help - Regexp For Extracting A String From A Larger String
I am developing a very basic CMS for a website I'm working on. One of the requirements is for the client to be able to post an image in their news posts, as well as links. I've got the links working (sort of, because I fear the way I have set it up may break images). Ideally I would like something like BBcode but can't wrap my head around regular expressions.
Parse Part Of String (mid String Function ?)
Can someone tell me how to parse part of a string? I can use the following: <?php $text = $_SERVER['PHP_SELF']; //$PHP_SELF //(document.url); echo $text; ?> to get this result: "Your currently at /test.php " I just want to get "test.php " without the dash. I also need to parse out parts of other strings. I know how to use Mid(), Left(), and Right() in VB, but no clue for PHP.
Search A String And Return String Between Char?
I have a string like this; Full Name (Department) How can I split that string into seperate strings for Full Name and Department, so that everything before the () is the full name and everything between the () is the department?
Partially Replace A String With Data From The Same String...
I'm trying to write a script to help import some old HTML files as blog post for my website, these HTML files are 300-2000 lines long. I am currently using fgets() to read the files one line at a time, clean them and write them to the database in the appropriate format once the entire article is completed. My issue is many of the links included on these post no longer exist (some date into the '90s) and I want as part of my importing function to "fix" these links as so. Code:
Searching For A Recurring String In A String
I am teaching myself PHP. I have an HTML page with various products each with a specific reference in the form "Reference XXX". I would like to put an email link below each product with the product reference as part of the subject of the email link. What kind of procedure would you use? Could you please put me in the...
String To Filename-friendly-string
I've got a database whith titles of pages and I want to use them in my filenames (with Modrewrite). But, I have to use a function to convert them to filename-friendly-strings. e.g. title:"What's thàt!?" should become something like: whats-that(.html) title:YOU & M€ should become you-m.html [ignoring strange characters] Someone who has got that function?
Converting A Hex String To A Binary String?
I have a situation where I have an 8-byte string which is represented as 16 hex digits. How do I convert a 16 hex digit string to an 8-byte binary string? I know I can use bin2hex to go from a binary string to a hex string (very useful)but is there a way to go the other direction? Right now I have a solution, which is to use a loop to go through the hex string one byte at a time, but that doesn't seem like a good way to do it. It seems like I should be able to use the pack() command, but I can't get it to work.
Replacing A String In A Larger String
i want to remove an email from a list of emails stored in a text file. using str_replace i can replace an email with nothing, but if the list is serated by commans, that would result in this: email@...,,email@...,email@... with no email between 2 commas. if i replace the email address with a comma on the end with nothing, it wouldn't work for the last one. if i replace the email address with a comma at the beginning, it wouldn't work for the first one. how can i avoid this or work around it?
Search String Delimited In Another String
I have a string (Website referrer). Example: http://www.google.com/search?q=MY STRING HERE&hl=tl&client=firefox-a&channel=s&rls=org.mozilla:en-US:official&hs=dXZ&start=30&sa=N I need to extract the keywords searched (example in the above case: "MY STRING HERE"). I think I need the string between "q=" and the next appearing "&". How can I do this?
Matching String To String
Is there a way to search a string so that if there is a match it simply returns true? I have tried many functions and they seem to not work. What i am trying to do is if i have one string, say a url (e.g. http://www.games.com), and another string (e.g. games), how do i compare one to the other whether it is in the first string? And another thing, is there any way of finding the third occurence of a certain character in a string, something like the strchr() function?
How Do I See If One String Is Found Within Another String?
How do I see if one string is found within another string? or how many instances of one string, is found within another. ie. a="Sheree smells of poo" b="smells" I'd like a function that would return 1, (for true, or that the word smells, if found once) PHP is ace. There must be a simple way of doing this. I mean, its got loads of useless functions that noones ever going to use. Im sure if PHP has a built-in function to convert hebrew, then Im sure it can do this.
How To Insert A String Into Another String?
This one has me stumped... Let's say I have a string consisting of n words (where n > 0). I would like to insert string 'abcd' between the first and second characters of each word of the string. I could probably use a combination of explode, implode and substr, but I was wondering if there is a more elegant way of doing it using regular expressions?
SELECT *
If I have a lot of articles, all with a unique IDs. First I would like to search for that ID, I could do SELECT * from ARTICLE where ID = xx But I also want to display the 5 articles before and after that article. SELECT * from ARTICLE where ID > xx LIMIT 0, 10 and SELECT * from ARTICLE where ID < xx LIMIT 0, 10 (I choose a limit of 10 in case the ID is one of the first one or one of the last one, that way I will always have at least 10 articles). Is it possible to do the above in one single query? Should I even bother doing that? does it make the whole operation faster to do it that way?
Select Box
I have a problem that I'm not quite sure what algorithm will help me on. I'm bringing in records from MySQL using PHP and need to spit this records into a select box. Fairly simple, here's my code for the first select box: <option selected value="<?=$currentCatID?>"><?=$currentCategoryName?><option> <?php while($rowGetCat = mysql_fetch_array($resultGetCat)){ if($rowGetCat['pCatID'] != $currentCatID){ echo "<option value="".$rowGetCat['pCatID']."">".$rowGetCat['pCatName']."</option>"; } } ?> </select> Problem is - based on their choice with the first select box, I need to query the DB and populate a second select box. So basically, I need a 2nd select box that is populated on the fly based on their choice from the first select box. The only solutions I have found so far use their own form, and the form I have now has numerous other options and values that I need to save the state of for editing. I was thinking AJAX might help, or maybe just regular javascript, but without having the entire page reload I'm not sure.
Sub Select
I have this line of code: $result = mysql_query("SELECT jobnumber, projectname, description FROM timesheets WHERE description IN(SELECT distinct jobnumber, projectname FROM timesheets)",$db); But this returns nothing. What I want it to do is display the 3 fields jobnumber, projectname and description where the jobnumber,projectname combination is unique.
Select The Id And The Name
I have this code that when the user provide his email address he will participate in a raffle, my problem is that i want to select the id and the name but my selection is not workin Code:
Select From
Is there a way to select from multiple mysql tabels?
Value To Use To Select All
I have done the following query: $query = sprintf ("SELECT * FROM users WHERE country LIKE '$selCountry'"); $result = mysql_query($query,$link); I want to obtain the users that are from a certain country but when $selCountry is equal to "All" I want to obtain all of them. I have tried the query in mysql webpage using '%' and it works but when using this character from the php file it doesn't work.
SELECT *
What would I have to put within the $sort variable to have that request display all rows starting with a number? right now I have to put 1,2,3,4,5,6,7,8,9 seperate. Anyway I can include it all in one variable that would work below? $q = 'SELECT * ' . ' FROM `company_details` ' . ' WHERE `cname` LIKE '' . $sort . '%'' . ' ORDER BY `cname` ASC'; $r = mysql_query($q);
SELECT MAX()
$f1 = mysql_query("SELECT MAX(id) FROM topics WHERE fid = '$f'"); $f2 = $f1+1; now, I can't see any errors...but when I ran my code $f2 should have equalled 4, but somehow it came out with 12? what's wrong with it??
Select Box
I have a select box coded that displays MySQL data as options in the pull down menu. What I need to know is if and how I can make it so that each option has given background. Can I assign a class to each option? The code for my select box looks like this: Code:
<select>
I have a query regarding <select> name: The script runs through a for loop for each select which gets the qty's from the DB, so the user can only select the maximum thats available in stock. Each select is given a name, which is the record ID from the DB ($wsi_id_arr[$num]). So the first select will be <select name="VB001"> for example. However, the problem i am having is how do I get at this in another script, for example, so far I have: for($ordercnt=0;$ordercnt<$num;$ordercnt++) { if(...................
Cannot Pass @ For A SELECT... WHERE
From a cycling database, to put to screen the Clubs whose Secretary has email, this works just fine in phpMyAdmin - select email from clubs where email like "%@%" order by club I want to do it in php but from the manual and these DevShed files, it seems the @ character stops all further progress along the line it's on???? I've tried all kinds'v variations of the following, brackets on and off, double and single quotes, till I'm blue in the face.
Help With Select Count In PHP
I'm trying to do a script that tells me how many orders I got in on a particular day. The script loads, but nothing shows up. Any help would be greatly appreciated! Here it is: <? //create connection $connection = mysql_connect (localhost, xxxxxx, xxxx) or die ("Couldn't connect to server."); // select database // substitute your own database name $db = mysql_select_db (MyDB, $connection) or die ("Couldn't select database."); $date = "02/05/02"; // create SQL statement $sql = "SELECT COUNT(*) FROM CUSTOMER as mycount WHERE CREATED='$date' AND STATUS=Ɔ'"; // execute SQL query and get result $sql_result = mysql_query($sql,$connection) or die ("Couldn't execute query."); //start results formatting echo "<br><br><div align=center>"; echo "<table cellpadding=5 cellspacing=0 width=ྛ%'>"; echo "<tr bgcolor='#336699'> <td width=100% valign=top><font face='verdana,arial,helvetica' size='-2' color='#ffffff'><b>Orders Today:</b></font></td> </tr>"; // format results by row while ($row = mysql_fetch_array($sql_result)) { $mycount = $row["mycount"]; echo "<tr> <td width=100% valign=top><font face='verdana,arial,helvetica' size='-2' color='#000000'>$mycount</font></td> </tr>"; } echo "</table>"; echo "</div>"; /free resources and close connection mysql_free_result($sql_result); mysql_close($connection); ?>
Select The First Letter
I'm trying to do a query, but i want the query to be done using only the first letter of the values in lname. ("SELECT * from wisdom where lname == '$letter' "); "Letter" is the value that i want generated coming from the previous page. I want all the data from lname with A as the first letter selected so i can display them.
MySQL Select
Just a qucik question. I need to display everything from the table where the data is not null, apart from username, as they'll always have a username. So far I just have this, which is on the assumption they have entered their name. $get = "SELECT * from profiles WHERE name IS NOT NULL LIMIT 30"; Is there a way I can basically make it say. Select * from profiles where * but username is NOT NULL?
|