-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by salathe
-
Having the quotes in the file is fine, that should not be anything to worry about. It might help if we can see the original file, without being manually saved or altered. Could you run the following on the CSV file as-downloaded (without being opened in Notepad++, calc or anything; you could use the URL of the file if you like) and let us know what it outputs? echo base64_encode(file_get_contents('GeneratedList.csv'));
-
In all of your if(…) statements, you are using = (the assignment operator) where you should be using == (a comparison operator). As for getting the header out of the way, you can do an initial fgetcsv() (and ignore the result, if you like) before the main loop that reads over the data.
-
loop through days 1 - 28 and then start again 1 - 28
salathe replied to brown2005's topic in PHP Coding Help
So you want the resulting calendar to have the "index" values like below? P.S. @Psycho, you seem to have entirely missed the point of a linear calendar. -
Using variable variables, as you are, seems a lot like going out of your way to make life more difficult. Why not use a nested array like $files[$file][1]. This will allow you to have a nice, single, object in Javascript containing all of the information for all of the files. If you just want to take what you have right now and do something with it, it sounds like you're looking for a way to reference the ahri variable from the this.id string. Assuming the variables are created in the window-level scope (it looks like they are) then you can, inside your onHoverCounter() function, use something like window[ChampID] to refer to that variable by name. For example: var file = window[ChampID]; var show1 = file[1]; ...
-
str_replace
-
Looks like you're trying to use iMacros; the best place is to (re)read their documentation. You're more likely to get an answer there, than taking your chances here that someone has used that software and can help you out.
-
As cpd said, there is no array at the moment (which is probably what is confusing us, and you). Your onHoverCounter() function takes the id of the <div> that you're attaching it to, e.g. ahri. This is a string value, not an array. Your function then gets the second letter of that string when doing ChampID[1] (JS, like PHP, allows you to access individual letters in a string by their zero-based offset). So in your example, show1 contains the string h.
-
How to insert string with dollar sign ($) into mysql table?
salathe replied to colap's topic in PHP Coding Help
Variable interpolation will still occur regardless of whether the variable exists or not. php-coder, as DavidAM showed you should be using single-quotes around that string (or backslash-escaping the dollar). -
XML element names don't have spaces. When you use something like <John Doh> it is the start tag of a John element with an empty Doh attribute. The errors that you are seeing are because </John Doe> is not valid XML (it expects only the element name there). It would probably make more sense to have a structure that does not rely on the model name being a valid XML element name, perhaps <model name="John Doh">…</model> then you can search the <model> elements by their name attribute. XPath makes this easy, and we can help you with that if you need it.
-
wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers The above is great if you're familiar with the "old" way of using mysql_* functions, but even if you haven't used those it's a good overview.
-
So does the PHP manual, but you don't hear anyone complaining because it hasn't (yet) been the subject of a smear campaign.
-
Could you elaborate a little more on precisely what you want? Is it such that, if the date is the last day of a month then show the last day of the next month? What about the next-to-last day, or the second-to-last day? What would you want to show for the following dates: 2013-02-25 2013-02-26 2013-02-27 2013-02-28 2013-03-01 2013-03-02 The strtotime() function will not do what you're wanting, so you'll need a little bit of code to handle whatever it is that you want to do. Once we can get a better idea of what you're aiming for, some code help shouldn't be too hard to come by.
-
Add string to beginning of each item in comma separated list
salathe replied to RyanMinor's topic in PHP Coding Help
Why not do all the hard work in the query? SELECT event.*, GROUP_CONCAT(CONCAT(?, photo_thumbnail) SEPARATOR '|') AS thumbnails … Then pass in the URL prefix as a query parameter, like you do with event_user. This would return the thumbnail URLs in the correct format that you can just plonk into the data-images attribute in your HTML. -
$products[0]['vendors_id'] = 15;
-
Add string to beginning of each item in comma separated list
salathe replied to RyanMinor's topic in PHP Coding Help
You say that the list comes from your database, but is the actual comma-separated string returned directly from there or do you have some PHP constructing that comma-separated list? -
Users followed by User 1 SELECT id, logo FROM users JOIN follow ON follow.user_id = users.id WHERE follow.follow_user_id = 1 Users following User 1 SELECT id, logo FROM users JOIN follow ON follow.follow_user_id = users.id WHERE follow.user_id = 1
-
When calling the function: saveXMLFile('menu.xml', $sxe); Inside the function: $dom->save($filename);
-
How to get number of days in a month and also knowing a leap year
salathe replied to 50r's topic in PHP Coding Help
Why would anyone choose to do that? There are several "huh, wha, why?" points in that single line of code. -
Is there a built-in hasNext property when looping MySQL results?
salathe replied to soycharliente's topic in PHP Coding Help
Good luck, and feel free to ask more questions here too. -
Is there a built-in hasNext property when looping MySQL results?
salathe replied to soycharliente's topic in PHP Coding Help
We do not recommend using the mysql_* family of functions when writing new code. The better and more up-to-date alternatives (MySQLi and PDO) have methods available for returning the whole result set into an array with one method call. -
Is there a built-in hasNext property when looping MySQL results?
salathe replied to soycharliente's topic in PHP Coding Help
Look at the example, it is used (number-of-results + 1) times. -
Is there a built-in hasNext property when looping MySQL results?
salathe replied to soycharliente's topic in PHP Coding Help
There is nothing built-in for your particular example. You could look at rolling your own iterator with the functionality that you need; something like a stripped-down version of a CachingIterator might be handy. -
How to get number of days in a month and also knowing a leap year
salathe replied to 50r's topic in PHP Coding Help
As jcbones suggests, the DateTime class is your friend. // OOP style $date = new DateTime; // uses current date and time by default echo $date->format('t'); // prints number of days in the month echo $date->format('L'); // prints 1 if leap year, 0 otherwise // Procedural style $date = date_create(); echo date_format($date, 't'); echo date_format($date, 'L'); See the date() manual page for the meanings of the letters used with format(). -
djburner, look at the arguments you are passing in to the function and how the function uses them. In particular, the $filename argument, which should be a string containing the path to the file that should be written. Also, there is no need to use fopen() and friends to write the file. Instead use $dom->save($filename).