How To Remove Last Comma From A Multiple List?
I have a multiple select list in my site where the values are inserted in a database table, in a column named available_country. I enter these values in the db separated with comma. I don't know however how to remove the last comma so it will be something like this:
USA, Europe, Asia
and not:
USA, Europe, Asia,
Here's what I tried but it didn't worked: ...
View Complete Forum Thread with Replies
Related Forum Messages:
Remove First Comma
I have this string: ",c2=5,c3=6,c4=5......" Now I need to remove the first comma. I know it is simple, but I can find the right command.
View Replies !
Remove Ending Comma
I have this code: <?php $sql = "SELECT * from cfm_lower_level_story_categories WHERE tl_section_id=1"; $result = mysql_query($sql) OR die(mysql_error()); while ($row = mysql_fetch_assoc($result)){   rtrim( ', ' );   echo '"';   echo $row['subsection_name'];   echo '"';   echo','; } ?>
View Replies !
How To Check If It's The Last Result And Remove Comma
I am wondering if anyone could help. I have a loop that displays my results and places a comma after each. The problem is that when the last result is displayed, it shows the comma. Example: for loop{ echo $row['test'].', '; } displays... test1, test2, test3, Notice after test3, there is still a comma? How do I remove it and have it display... test1, test2, test3
View Replies !
Re Comma Separated List - Another Question
I can do the match perfectly but what i also need to do is create a third list of comma separated values that are in both eg: List 1 => 1,2,3,4,5,6,7,8,11 List 2 => 1,3,4,5,6,7,10,23 Therefore List 3 => 1,3,4,5,6,7 How do I populate this third list - I'm really stuck ....
View Replies !
Comma Seperated List Comparison
is it possible to compare acomma separated list aginst another eg comma list 1 => 1,2,3,4,5 comma list 2 => 3,5 can you check that 3 is in both, and 5 is in both, therfore they match? the comparison is to check that if product a who supplies products 1,2,3,4,5 can be used instead of product b who supplies 3,5 as product a already supplies them
View Replies !
Comma Separated List In MySQL Field
say I have a list of categories in a field, and a page that is supposed to pull from the db based on a category. Is there any way I can do a query where it searches the contents of that field for the category in question? like SELECT FROM table WHERE category = $category but have it search the category field (the comma separated list for each entry) for the $category var
View Replies !
Array Form A Comma Delineated List
What's the best way to create an array from a comma delineated list? I have a string assigned to a variable that looks like this: 1,2,3,4 And I would like to create an array so that $arr[0] = 1 and $arr[1] = 2 etc. It seems so simple but I just can't crack it.
View Replies !
Regular Expression :: Find Word Matches To Words In A Comma-delimited List
What's the *right* way to find word matches to words in a comma-delimited list. For example, if I have the following comma-delimited list of categories in a mysql db field: gameboy, nintendo, playstation and I do a search, I know I can use regexp to do something like: select * from categories where regexp 'gameboy,' Notice that I have the comma in there to match the whole word and the comma without matching part of a word (to prevent unwanted matches such as "play" to "playstation" or "game" to "gameboy"). The problem I'm running into is words that match that match the end of each word next to the comma (in this example, "boy" and "station"). What's the right way to match a word *exactly* using regexp *without* also matching *part* of a word.
View Replies !
How To Remove "comma, Full Stop" From A Sentence
I have sentences as follow: $quote[1] = "To be or not to be, that is the question."; $quote[2] = "Love looks not with the eyes, but with the mind."; $quote[3] = "Love all, trust a few. Do wrong to none."; now I would like to do the following, 1) for each quote[$i], remove all ","(comma) or "."(full stop)...does anyone know how? I have the following code but it does not work. What should I write in $patterns? for ($i=1; $i<4; $i++) { $quote[$i] = strtolower($quote[$i]); echo "$quote[$i]<BR>"; $pieces = explode(" ", $quote[$i]); for ($j=0; $j< (count($pieces)); $j++) { echo "$pieces[$j] "; $patterns = "."; $replacement = ""; print preg_replace($patterns, $replacement, $string); echo "$pieces[$j] <BR>"; } } 2) also, I would like to count a) number of frequecy of each term (e.g. "to" has a frequency of 2 in qoute[1]) and b) number of frequency for all three quotes (i.e. "to" has frequency = 3) but I have no idea how? can anyone please give me an idea?
View Replies !
Remove From Mailing List Via Variables In URL
i have often joined other mailing lists and i notice that when emails are sent out there is usually an option to delete your email from the mailing list. i was wondering which is the best way to go about this. would it be a matter of sending a link in the email which is something like... http://wwwmysite.com/deletemail.php?somebody@somewhere.com deletemail.php being a simple script that takes that email addy and deletes it from the database? or is there a better way to do it?
View Replies !
Remove Index And .htaccess From A List
I have this script to list files in the same directory; <? $dir=opendir("."); readdir($dir); readdir($dir); while ($conteudo = readdir($dir)) { echo "<a href=./$conteudo>$conteudo</a><br>"; } closedir($dir); ?> How can I remove from the list two files, index.php and .htaccess. I tried using 'if' but without success.
View Replies !
Remove File Extensions From A Directory List
I'm running a small script which lists files in a directory by last modified and with under scores in file names replaced with spaces. I'd also like to remove the file extension, but cant figure out how. I found this code. $ext = substr($value, -4); ....though i'm unsure how to implement it PHP Code:
View Replies !
How To Remove Multiple Line Breaks?
I'm am trying to remove multiple line breaks (" "). Here's my code: $imageStr = trim($_POST['images']); $imageStr = str_replace(" ", " ", $imageStr); ---------- $_POST['images'] is a textarea field, and I am trying to remove extra hard returns that a user types into the text area. When I change the code to: $imageStr = str_replace(" ", "%", $imageStr); it works fine. So I know the function works and I have the right character (" ").
View Replies !
Cannot Remove Module Mod_php5.c: Not Found In Module List
Today I see in my apache error log file an entry 'Cannot remove module mod_php5.c: not found in module list'. Anybody any idea where this is located or where I get this php5.c file or why this shows up since today in my error log file? Everthing still seems to work well except the anoying error entry.
View Replies !
Multiple Value List
I'm trying to input a form onto my page, where the user can select from a range of different sports, and more than one sport can be selected. I'm not sure how I go about writing the code so that it's entered into the mySql table that I have set up - I want it to go into one field in the table called Sport or something along those lines. I can write the code for just one value to go in but I'm not sure about when there's more.
View Replies !
List Box Multiple Select
I am trying to create a drop down list that permits a person to select multiple items from the list and have the results posted on a results page. I am using Dreamerweaver MX, PHP and a MYSQL database. I was able to select multiple items but only the last selected item would be displayed. I tried to modify the list box code and now it returns nothing. Code:
View Replies !
Multiple List Selection
I am still learning PHP, which is the best language for database driven sites. I am using Dreamweaver CS3 with the devleopers toolbox which is "ok" to help take the guess work out of things. I am using a simple registration form that i made with the toolbox, but when I come to a multiple list to choose from (populated from the database) it doesn't work correctly. Of course, out of the multiple items selected only the last one gets inserted. From what I have read, the selection must be turned into an array then looped for this to work. Is this correct? Next how would I code this to work right.
View Replies !
Multiple Select List Box
I have a task where I have to fetch datas from mysql and display it in the multiple select list box. I have fetched the datas and it is getting diplayed correctly in the multiple select box. I have used some thing like this. print "<select MULTIPLE SIZE=ƌ' name='db_test[]'>"; while($row = mysql_fetch_object($handle)) { if($num 0) /*num is number of rows*/ { print "<option value='$row->db_name'name='$row->db_name'>".$row
View Replies !
Multiple Select List
I have a form that inserts it's values into a table in a mysql database.. i also use another form to edit the contents of that table... My problem is that i have a multipe select list ... i imploded it's values into the table like this: $employees = implode(',',$_POST['emp_name']); that worked fine ... but i can't figure out how to make the same values selected on my edit form's list?
View Replies !
Multiple Entries In On Column/List Box
I'm creating a page where members can edit their research information. I'm going to have 12 List Boxes, each with about 20-25 words. I want the user to be able to choose as many as they need (by control+click) - and store them all in the database. I expect each member to only have about 4-5 .. but you never know. The information they submit, all 4 or 5 or however many keywords, will need to be easily searchable on the main page. I also am going to need to make it easy for them to edit/update their keywords. My question is - which is the best way to do this? Do I dumb all the selected values into one column of a table? then when doing a search just do a text search? And how do I implement the update page? I know how to show previous text in a text form field, but is there a way the options they chose can be pre-selected when they go to update their research?
View Replies !
Multiple List Values To One Field
I'm trying to figure out if there is a way to input multiple selections from a list in a form field into one field in MySQL. Right now my list is only inputing the first value selected and not the others.
View Replies !
Dynamic List Has Multiple Entries
On an input form there is a dynamic drop down list to select from a dozen different categories. The form inserts correctly into the database. The problem is that every time a category is selected the drop down menu list it an additional time. For example if the list has: apples, pears, oranges. If pears is selected the drop down list will display: apples, pears, pears, oranges. Code:
View Replies !
Multiple Delete From A List Of Records
If I have a list of records from a database on the screen, each with a check box beside them, how would I delete all the records that have been ticked? I assume I would use a variable similar to checked[], but not sure what syntax I would use to remove them from the database? Would I loop round each record comparing the checked[] value and it it's set, delete the record?
View Replies !
Passing Multiple Selections In A List To A Variable
I have a form with a Select box as follows: <SELECT NAME=msgtype SIZE=6 multiple> and in that are 6 options. If I pick one, it is passed to a query reading something like: SELECT * FROM mytable WHERE msgtype LIKE '$msgtype' This doesn't work if they chose two or more of the items in my SELECT box. How can I make it work if they do? I already have a "All of the above" that passes the value "%%" to the query to search in all of the six options, but want users to be able to search 2-5 of the options at once as well.
View Replies !
Retrieving Full Entry From Multiple Select List
I have a list box with multiple selects. I define the name as numList[]. I get the values from $picked = $_POST['numList']; It retrieves values for all those selected. If the entries are, say, First Second Third and the first and third are select then $picked[0] has "First" and $picked[1] has "Third". If, however, the entries are: First one Second one Third one Then the values are for $picked[0] and $picked[1] are "First" and "Third" respecticely. How do I retrieve the entire value and not just the first word?
View Replies !
Dealing With List (multiple Select) Submissions From A Form
If I have this in a form, how can I deal with the $_POST result if multiple items in the list are selected? I've been searching the net for such answers, but I think I'm searching for the wrong things as I can't seem to find what I'm looking for. From what I've tried just, only the last selected item in the list goes through on $_POST I basically want a list of items, which would have a certain operation done on them if selected on the following page.. but need to get ALL of the selected items first! Code:
View Replies !
Database Design For Multiple List Meny Entries
I have a database called nottsvcs with a design as follows: refno (primary key) organisation (char50) telephone (char50 activities (list menu)** My list menu of activities allows the user to pick more than one activity. My question is how do I change my db design to allow for storage more than one list menu selection?
View Replies !
List Values: Multiple Values
In dreamweaver I am trying to enter an "ALL" list value I have 3 labels and 3 corresponding values, but I am trying to create an option for the user to select "ALL" Should I just enter: 1,2,3 in the value section will this populate my recordset correctly ? Is this the correct format to use for multiple values for a label ? Code:
View Replies !
Comma Seperator
I have numbers retrieved from database which is quite big. Is it possible to give a comma seperator in the sql query or otherwise how can I format with a thousand comma separator?
View Replies !
Deleting Last Comma
The code below displays pet names like so: Fido, Bowser, Kittycat, Spot, and I want to delete only the last comma. I tried 'substr' and 'rtrim' and both of those delete the space and comma between each name, not just the last name as I'd like, so I end up with: Fido,Bowser,Kittycat,Spot, How would I delete only the last comma, so that it is this instead? Fido, Bowser, Kittycat, Spot Even with trim and substr, I end up with:
View Replies !
Exporting To CSV Contain Comma In It.
There are some text fields that I am exporting to CSV contain comma in it. And so when I open the csv file, everything is shifted. e.g. "Apple, Banana, Orange", "Excellent", "12345" gives me 5 columns instead of 3 in the csv: Apple Banana Orange Excellent 12345 How can I solve this problem?
View Replies !
Formatting With A Comma>
i inserted a salary into mysql with a text file but the command i said was to end field with comma, so i just made 750,000 like this in the txt file like this 750000. ok so how can i format my php to display it as the 750,000 and even better add a floating dollar sign would help as well Code:
View Replies !
Stripping Last Comma
When pulling flavors from a mySQL database, I want to strip the last comma from the array, however I'm not sure how to do this. The stripped down code is below with the comma I want stripped in bold red: $query2 = "SELECT flavors from chip_stan_flav"; $result2 = @mysql_query($query2) or Die("Couldn't execute query"); while ($row2 = mysql_fetch_array($result2)) { printf ("%s, ", $row2[flavors]); }
View Replies !
Sending Comma In Url
I have a page that has a drop down menu, when item is selected the request is send to info.php?item=selectedIndex. Everything works, however when I have selected value with a comma: "Comany, Inc" the url redirection does not work. Is there a function in php I should use to encode url, or commas are not allowed at all.
View Replies !
Only Split First Comma
i have to split a substring from a string how do it? my requirement is i have a variable $var =,1,4,7 out put should be like $var =1,4,7(split first comma from the value.
View Replies !
Chain Menu But The Menu Should Be Multiple Select Menu/list
I am looking for codes to be able to do the same thing with multiple select menu/list. PHP codes or javascripts codes are both fine. 1) javascript + php approach: Prefer to be javascripts codes to display the chain menu. I can use the php to get the all three levels menu data from the database, and assign these values to the javascript. 2) php codes only: Or use the pure php codes (the problem is if just using php codes then I have to submit the form to the server every time, when top level menu select changes to create new menu.).
View Replies !
Comma Separated Values
What i've done is when the user enters the client list separated by commas..... this works, but I need to know how to warn the user when they have enter the client list with no commas. Is there some sort of function which does this or is it a regular expression thing??
View Replies !
Seperating An Array With A Comma
I'm trying to seperate the output of an array with a comma. I can't figure out how to eliminate the last comma. Here is my code: $result = mysql_query($query,$connection) or die (mysql_error()); $fw = fopen("/var/www/html/ecast/windex/graph.html","w"); fwrite($fw, "/ "); if ($new_rows = mysql_fetch_array($result)){ do{ fwrite($fw, $new_rows[0]); fwrite($fw, ", "); }while($new_rows = mysql_fetch_array($result)); } fwrite($fw, " /"); fclose($fw); ?> Output: / 85, 86, 87, 89, / How can I eliminate that last comma?
View Replies !
Removing A Comma From The End Of An Array
I am reading a file into an array using this: $listFile = "add2db.txt"; if (!($fp = fopen($listFile, "r"))) exit("Unable to open the input file, $listFile."); $buffer = fread($fp, filesize($listFile)); fclose($fp); The very last character in that $listFile will always be a comma. What I need to do is remove that last comma (and only that comma) from $buffer before I can continue on. What do I need to do to accomplish this?
View Replies !
Comma Delimited File
I am trying to read comma delimited rows of text. The problem is that some fields may be encapsulated in "" - particularly the text fields but not numeric fields. Is there a simple efficient way to parse the fields with comma but also strip off the "" encapsulating some of the fields with php? The problem is the "" encapsulation is optional. Some fields will have it, some won't.
View Replies !
How To Instert Comma Into Number?
I am having users submit large numbers into a form, and when those values are returned to them later I want to have the commas in the correct places. ie. 123456.00 changes to 123,456.00. Is there a function that does this conversion? Also, how would I ensure that the number is always displayed with 2 decimal places, ie. 123 changes to 123.00, but 123.00 remains 123.00.
View Replies !
|