Breaking Up A Comma Seperated List
i have a list seperated by commas: 1. 3. 5. 7. 9 actually is a varible
$members ="1, 3, 5, 7, 9"; what would be the best way to break that up to insert the values into a table in a loop.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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
Seperate Links From Comma Seperated Value In A Databse
I have a value which is $keywords in my database The key words are separated by commas, like: fun, funny, exciting, weird I want to make each of those keywords link to "link.php" I can only get them all to be one link, how would I make them each into seperate links.
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 ....
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: ...
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
Easy Comma-delimited List To Dropdown Box Converter
I was working on a simple converter when I realized that by not setting the id param of the option tag, it wasn't going to send the value of the dropdown box to my php script. I had this to start with: Code:
How To Get A Dynamic Javacript Form Variables Seperated In PHP
PROBLEM: I have this form that allows the user to dynamically create additional fields (see javascript code bellow). I am trying to retrieve the values entered into these fields from my php script. I ultimatly need to pick out the variables and place the values into my php script page. I have worked with a little code I found on php.net (see php code below), but I wan unable to grasp the knowledge on how to seperate the variables in the address bar. Please reply. QUESTION: How do I create variables in my php script from my dynamic javascript form? PHP CODE: foreach($_GET as $name => $value) { print "$name : $value<br>"; } JAVASCRIPT CODE: <HEAD> <!-- Begin function createForm(number) { data = ""; inter = "'"; if (number < 16 && number > -1) { for (i=1; i <= number; i++) { if (i < 10) spaces=" "; else spaces=" "; data = data + "URL " + i + " :" + spaces + "<input type='text' size=10 name=" + inter + "url" + i + inter + "'><br>"; } if (document.layers) { document.layers.cust.document.write(data); document.layers.cust.document.close(); } else { if (document.all) { cust.innerHTML = data; } } } else { window.alert("Please select up to 15 entries."); } }
Breaking Strings?
I have a string (actually 100's of these, but lets take one): $string ="TI: Some journal title AU: SomeAuthor,-S; Smith,-A; Jones,-B SO: SomeSource. 2002 Jan 9; 287(2): 188; discussion 189-90 JN: Some Journal Title"; This needs to be turned into an array: $entry = array( 'Some Item Title', 'SomeAuthor,-S; Smith,-A; Jones,-B', 'SomeSource. 2002 Jan 9; 287(2): 188; discussion 189-90', 'Some Journal Title'); As you can see, each array item should be defined by what comes after either/all of the following: 'TI:' 'AU:' 'SO:' 'JN:' So, I need to be able to create a pattern that can look through the string and return everything in between TI: and AU:, then AU: and SO, etc. for example: eregi(???, $string, $entry); I'm fairly new to this and can't seem to figure out the regex I need for the pattern. Is this even the way to go about it?
Breaking Out Of An Iframe
I cannot figure this one out. My script is being displayed in an iframe (a wiki page) and I have one option won't give me the correct results unless the page is displayed in either a) new tab in NS browser b) new browser instance. The option in question is used to print forms, and I use the browser Print Preview for the page setup. It's all pretty useless if I have the page and iframe content in my preview. I thought using header() would do the trick.
Breaking A Page Down.
What is the best solution to break down a php page into certain section using MySql, For example i'm looking at designing a page that reffers to a MySQL database that contains the html code for the navigation. So that in future if the navigation changes I'll only need to changed the html code in the database and all the pages will be sorted. I'm also looking at doing the same for the information on the footer of the page, with teh contact details.
Breaking Out Of Quotes
I know I can use stuff like in front of " so that it can't break out of a "" and start doing bad things, but it seems there are other situations where, E.G., if the string is hex for " then it has the same effect, and stuff like that, and it gets tricky escaping it all, so I'm wandering, is there some kind of option I can enable or extension I can install that just simply prevents objects/variables/arrays from breaking out of single/double quotes and also for mysql queries? And also for html so E.G. echo"<img src='$asdf'>"; can't be exploited to do other things? I don't care if it isn't free as long as it works good and isn't to expensive..
Breaking Up Querys
I have a page that updates a table every workday. (these are standard updates, like if someone has moved, or has a different phone number or something.) It is too big of a query to run the entire table all at once, so it is split out. The split is grouped by the first letter of a first name field. Right now it is broken up into 5 parts, and each part has a group of letters (i.e. "a" to "d" is one group, "e" to "k" is the next, and so on. As you can see, these do not have an even number of letters, but that is because some letters have a lot more entries, and need to be in smaller groups.) The reason it is split out into 5 groups is that I can run one group on each workday (Monday through Friday), and I can have the PHP check what day of the week it is. (I use a case statement, the first case is for Monday, the second is for Tuesday, etc.) Code:
Breaking A Loop.
I have one going through rows of a sql database until it matches some data with user input. I need to put a break command in there but can't seem to find out how to achieve this.
Breaking Rows
I am using a while statement to pull results from my database. Now if I have like 40 results how would I make it break into rows. So instead of; result result result result result result result result result result result result result result result result result result I want; result result result result result result result result result result result result result result result result result result result result
XML Parser Breaking Up URLs
I'm having a problem parsing an xml file in which one of an elements character data is a url which contains multiple "&" characters. For some reason the parser breaks up the data into multiple pieces. For instance, when I call this function(abbreviated): function characterDataHandler ($parser, $data) { global $element; global $url; if ($element == "URL") { $url = $data; echo "url=".$url."<br>"; } } I get some output like this: url=http://www.somewebsite.com/index.jsp?s=af url=& url=filter=1 url=& url=show=all Do urls with querystrings have to be handled differently then regular character data?
For Loops Breaking At A Certain Multiple
Can someone help me out with writing a script that will make will loop 500 times, but at every 4th multiple, it will insert a peice of code? I tried all day to get this, and so far, nothing has worked.
Characters Breaking My Query
Im using encrypted data to store cc info. The PHP code encrypts and sends the result to the database. the problem is that the encrypted string contains lots of characters that will break my sql query. I can do a replace but there are lots of characters. for example, a character will look like this: g%$^'GDF$%^//"@#$%/||''$#"/|#dfsa. how can I put this information in a different format... and then retrieve the data to decrypt the string?
Not Breaking Loop In Function
I get this error: <b>Fatal error</b>: Cannot break/continue 1 levels in <b>file.php</b> on line <b>128</b><br> This happens when I call a function. In the function there is a break; This is cause the break is in a function and not in the loop. But it gets called inside the loop. Is there a fix for this?
E-Mail Not Breaking Lines
I'm sending an e-mail via a contact form, but somehow the lines aren't breaking in the text, it always looks like this: lorem ipsum dolor sit amet lorem Which is of course not readable at all. What am I doing wrong here? I'm using a few security checks and such for cleaning the field up; $text = trim($text); ... $text = stripslashes(strip_tags($text)); ... $text = mysql_real_escape_string($text); ..... #and then the part where it's included in the message: $message .= "Nachricht: {$text} "; Can any of those be causing the display problem?
Script Breaking On Mysql_result
I was trying to figure out why one of my scripts was failing and by using an "or die" statement for the SQL narrowed it down to this bit of code: $md5 = md5_file("swf/" . basename($jpg_link)); $dupe = mysql_result(mysql_query("select count(gId) from games where gSwfFile='$md5.swf"), 0); if(!empty($dupe)) { continue; } This is giving the following error - "Warning: mysql_result(): supplied argument is not a valid MySQL result resource" The thing is, I've checked that SQL query by running other values in place of $md5 through it and it appears to be fine. select count(gId) from games where gSwfFile='Flat War july 30th 2007.swf'; Any ideas?
Breaking Backwards Compatibility - Good Or Bad?
If you have any PHP scripts which will not work in the current releases due to breaks in backwards compatibility then take a look at http://www.tonymarston.net/php-mysq...everything.html and see if you agree with my opinion or not.
Breaking Survey Into Seperate Parts?
I have a very long survey form with 4 different sections. Is there anyway with php to split this form into 4 popup windows so the person can click on the section they wish to fill out and when they are done, go back to the host survey form and continue on? I know there must be a way to do it, i'm just at a loss as to how i would pass the variables off? Cookies perhaps?
Breaking Up Text For Multiple Pages
I was recently put in charge of heading up my company's website, and while I have a lot of experience on the design side of things, I'm still very new to the programming side. When I started, the website had just gotten a revision, but the site was an utter mess, so I've been trying to fix it up. As I've gone along, I've learned some aspects of PHP, but my knowledge is still very limited. Here is the problem I'm trying to fix. A backend is used to enter information into our MySQL database, and then a page template pulls it out to make the page. For our reviews, the PHP coding currently breaks up the review's text so that it can be places across multiple pages. The problem is, the way the text breaking was set up, the end of one page and the beginning of the next are totally chaotic, with breaks often coming mid-sentence. Here is what I'd love: other coding automatically puts an HTML break at the end of paragraphs, and then another in the space between one paragraph and the next. I'd love to have the code search for when those double breaks come up, and then break up the text after, say, every sixth pair of HTML breaks. I'd also like the option to break the text myself by putting in some sort of text code in the original text. At this point, though, anything that can make the breaks more elegant would be a huge improvement. I really appreciate any help anybody can give me in this one. Please remember that I know very little of PHP, and I'm not much of a programmer anyhow, so things that you may take for granted that people would understand about PHP, I might not know. I tried to pull out what I thought was the current coding for the text break. Here it is. I'd also like to get rid of the part1/part2 factor. Before, they had the text breaking to help in fitting into the layout around an image, but I've fixed that so I no longer need the break. So, that portion no longer needs to be a factor. if ($page == ""){ $page = 1; } $no_letters = strlen($Game_Full_Story); $times = ($no_letters / 3800) +1; $Game_Full_Story = wordwrap($Game_Full_Story,3800,"*#^"); $Game_Full_Story = explode ("*#^", $Game_Full_Story); $pages = array(); for ($i=0; $i<$times ; $i++){ $part[$i] = $Game_Full_Story[$i]; if ($i != 0){ array_push($pages, $i); } } $page = $page-1; $story = $part[$page]; if (strlen($story) < 460){ $parts1 = $story; }else{ $story = wordwrap($story,460,"*#^"); $story = explode ("*#^", $story); $parts1 = $story[0]; $count = count($story); $parts2=""; for ($i=1; $i<$count; $i++){ $parts2 .=$story[$i]; $parts2 .=" "; } }
Breaking Up A String Into Individual Words
I have a text box that I will use to search a database. I would like to use it so that it will not use a whole string (ie. 'red striped top') but instead break it up into individual words (ie. 'red', 'striped', 'top') and maybe put it into and array. I will then use the words in the array to search the database. How do I break a string up this way? Also, is this the most common way of creating a means of searching a database?
Breaking Up The Query String Dynamicly?
using $Get_string = $_SERVER['QUERY_STRING']; to receive a query string such as month=may&$day=15&year=2006 so that $Get_string = "month=may&$day=15&year=2006" can I separate the values and turn them into variables? (like a normally would with a url get) $month = "may" $day= "15" etc it would be great to just do $_GET on the url but I'm sending the string as a variable to another script... so i can't just go the easy route.
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?
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:
Breaking The BACK Button (Refresh Problem)
I have a php page which serves up multiple pages based on how the user interacts with it - there are links on the first page that will reload (from the same php file) a new page with form fields and submit buttons, and when a user posts from that new page (or cancels), then the same php file is again loaded, detecting how the user responded and generating the appropriate html for whatever should be none next. All very typical. What I want to know is, is there a way so that once a user has posted from some submit button from one page (we'll say he Cancel's from a page that had a form Cancel button so he returns to the original non-form default page generated from the php file), can it be made so if the user then "refreshes" the new page (hits the Refresh or Reload browser button) he does NOT get the browser's "The page cannot be refreshed without resending the information. Click Retry to send the information again, or click Cancel to return to the page that you were trying to view." dialog? In other words, what I'd like is a way to have the browser think that there was no posting done (even though there was) once I've generated this certain 'home' page with my php code, so that user ReLoad's of the page won't get this warning. This is probably related also to problems I've had with "breaking the BACK button" on sequences of php pages: if the user BACK's up to a page that was generated by a post, it may not even be possible to regenerate the original page.
Return Data Breaking Input Field
My return data is: (I have nothing to do with how the og person choose to input this) <font color="#800080">CASE</font> and I am setting the value of a input text form field equal to that return $input = "<input type="text" name="queOpt". $i ."" value="". $this->_queArr[$i] ."" />"; im lost on how to fix this. addslashes doesnt make sense - maybe it is the double quote thing
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??
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?
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?
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.
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.
Exploding Comma Separated In Array
I'm looking to explode the comma separated values in an array like this: Array ( => 10811 [1] => 7527,7556 ) and then add the exploded value as a new key in the array...like this: Array ( => 10811 [1] => 7527 [2] => 7556 )
Seperator Instead Of A Comma For Listed Items In DB?
I'm making a recipe database, and need to have DB fields in mySQL that will have lists of values that would get sent to an array to be worked on. I anticipate that at times a comma will need to be used in the value itself. So, what's a commonly used symbol or something that people tend to use as a separator of a list that would then be used in the split() function to send the elements into an array?
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
Comma Separated Text Files
A client has requested that I make a php app which takes an uploaded image, reads the values and enters them into a database. I've made the upload script which works fine, and the script which enters the values into the database, the only thing left now is how do I make PHP read the file and extract the values? The file is a text file, each field comma separated.
Comma Delimited Csv Has Commas Inside Fields
I need to import a CSV file into a database daily. That operation in itself is simple enough but the trouble is that some fields are quoted because they have commas inside them. How do I handle this with my import script? It would be much better if the CSV was created with all fields quoted or used a different delimited but sadly that is not an option.
Regular Expression For Comma-delimited Pairs
I have a textarea form field for inputting (or pasting) pairs of data. I need a regular expression pattern to validate each line for the following double quote number double quote comma double quote alpha string double quote carriage return The following comes close, but doesn't check for a carriage return at the end of each line: ^"([0-9]?)+"([,]s?"([A-Za-z0-9]+)")*$ For example the following would return true: "1","John" "2","Paul" "3","George" "4","Ringo"
Looping Thru Array And Creating Comma Sep String
I'm trying to loop through the elements of an array and create a comma separated string of the values, and then trim off the last comma. Here's the code I have which only displays the last element of the array in the string: PHP Code:
Stripping Quotes Out Of A Comma Delimited File?
I have a flat file that I'm trying to stick into a MySQL database. One record per line, multiple fields per record, and many of them are null fields which are just double quotes without a space between. It's probably nothing really major for people who have done this before, but I'm a bit stumped. The file is comma delimited. Every field is surrounded by double quotes. I've done quite a bit of searching, on the php site and elsewhere, but I can't seem to get it to strip the quotes out so I can explode the file line by line to grab the fields.
List Contents Of A Folder, Make List Of Links
Does anyone know how I can write a script that: - reads in all the files in a particular directory - displays the file names in a html list and makes a link of them: <ul> <li><a href="filelocation1">filename 1</li> <li><a href="filelocation2">filename 1</li> <li><a href="filelocation3">filename 1</li> </ul> etc.? So basically it creates a list of links with the contents in that directory, so you can download them from there.
Get List Of Messages From One Table, Message List Indicator From
I have two tables. One has a list of messages left by users using fields named mbxno for the mailbox and msgno for the message number. I have another table that has mailbox settings for each user that contains a field named "messagelist" to indicate if they want to be included on the message list or not. What I'm trying to create is a list of the most-recent messages with a lookup on the users table to indicate whether a message in the list should be included in the message list based on the user's mailbox settings. SELECT messages.msgno, messages.mbxno, users.messagelist FROM messages, users WHERE (users.messagelist = Ƈ') ORDER BY msgno DESC LIMIT 100 What I'm getting, though is a list that looks like this: mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 I think what's happening is that I'm using the wrong type of join and more rows are being created than necessary. If I add "DISTINCT" to the query, I get a list of the most-recent messages as I expect, but the "messsagelist" value is sometimes wrong (again, probably because the data is getting jumbled). For example, the messagelist value for the second row (2214) should be 0, not 1. mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 2214 msgno: 0412141622 msglist: 1 mbxno: 2189 msgno: 0412141408 msglist: 1 mbxno: 0000 msgno: 0412141213 msglist: 1 mbxno: 0003 msgno: 0412141213 msglist: 1 mbxno: 2265 msgno: 0412132029 msglist: 1 mbxno: 0000 msgno: 0412131950 msglist: 1 How should I be doing this? If nothing else, what kind of join will work with a long list compared to a value from a short list?
|