-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
How to reverse order of <td>'s in a <table> using jQuery?
cyberRobot replied to smn's topic in Javascript Help
You could use getElementsByTagName() to get the table and then all the columns for the table. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName Then you could loop through the columns, rebuild the table, and replace the old table with the new one. -
edit row if hashtag field already exists with the varible
cyberRobot replied to dropfaith's topic in PHP Coding Help
You could add a query that checks if the hashtag exists already. For the hashtags that exist, you would skip the insert query. -
The longest month ever
-
Yep, I'm sure the tool would have been handy when I spent more time taking screenshots. For what it's worth, the tool is still available on Windows 10, but the name changed to Steps Recorder.
-
Alternate solution: <?php $y = date('Y'); $yearRange = range($y+1, $y-11); foreach($yearRange as $currYear) { echo '<option value="' . $currYear . '">' . $currYear . '</option>' . "\n"; } ?>
-
What does the code for creating the <option> tags look like?
-
seperating an array at a certain index
cyberRobot replied to Michael_Baxter's topic in PHP Coding Help
With each line split into an array, you could loop through the array looking for the start point. Then store each of the following lines in a separate variable until the stop point is reached. Yep, that would be problematic. -
seperating an array at a certain index
cyberRobot replied to Michael_Baxter's topic in PHP Coding Help
You could use the strpos() function to locate the two strings. And then use substr() to get the content between the two points. -
Change background color based off value returned
cyberRobot replied to Tmod's topic in PHP Coding Help
In addition to Psycho's code, you can use the lvl1-4-5 class to add a default color. <style type="text/css"> .lvl1-4-5 { background-color: #FF95FF; } .brandHonda { background-color: #FFD9D5; } /* ... */ </style> -
My preference is to list the common name first. So something like "LoginAttemptsLog-SQL", "LoginAttemptsLog-MongoDB", etc. That way if all your include files are stored in the same directory, the login attempt classes are grouped together when the files are sorted alphabetically.
-
What does $departure_date->format('j M Y') output?
-
What does the code echo now? Have you tried outputting the various variables to see if you are getting expected values?
-
Note that the original post was made in June 2014. The OP also hasn't been back since August 2014. I locked the topic to prevent it from being resurrected a third time.
-
Sorry, I meant array_fill_keys(). And it would only replace the part where you initialize $defaults. Here's a quick example: <?php $defaults = array_fill_keys(array('first_name', 'last_name', 'username', 'password'), NULL); print '<pre>' . print_r($defaults, true) . '</pre>'; ?>
-
If you are initializing a lot of variables with the same value, you could consider using array_fill(). More information can be found here: http://php.net/manual/en/function.array-fill.php Wrong function. See the post below.
-
I have an array that I need to get into a db
cyberRobot replied to elentz's topic in PHP Coding Help
Just to clarify, that was to replace step 1 of Psycho's solution. You should be able to use array_chunk() next, etc. https://forums.phpfreaks.com/topic/302791-i-have-an-array-that-i-need-to-get-into-a-db/?do=findComment&comment=1540606 Would there ever be a case where it uses "\r\n" instead of just "\n"? I honestly don't know. -
I have an array that I need to get into a db
cyberRobot replied to elentz's topic in PHP Coding Help
Have you tried preg_split() and the white-space character (\s) for the pattern? Here is an example found through the Google link provided earlier: $oparray = preg_split('/\s+/', trim($output)); -
MySQL has built in date functions. More information can be found here: https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html Also note the first example that uses INTERVAL Side note: In case you are not aware, the mysql_* functions were removed in PHP 7.0. More information can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php
-
Yeah, sorry about that. I only "quoted" you to refer to the unnecessary function. As soon as I hit post, I realized that wasn't the best way...but was in too much of a rush to correct it. I figured it would be better to ask for forgiveness. Edit: I removed the quote since it was misleading and unnecessary. Yep
-
You should use mysqli_connect() to select the database. More information can be found here: http://php.net/manual/en/function.mysqli-connect.php Note: the documentation recommends that you only use mysqli_select_db() to change the default database. More information can be found here: http://php.net/manual/en/mysqli.select-db.php
-
I have an array that I need to get into a db
cyberRobot replied to elentz's topic in PHP Coding Help
Searching Google, the solution seems to come down to using explode() or preg_split() to break the string based on the white-space character. https://www.google.com/search?q=php%20get%20an%20array%20from%20shell_exec -
I have an array that I need to get into a db
cyberRobot replied to elentz's topic in PHP Coding Help
For what it's worth, shell_exec() returns the output as a string. More information can be found here: http://php.net/manual/en/function.shell-exec.php -
endforeach is the alternate syntax. More information can be found here: http://php.net/manual/en/control-structures.alternative-syntax.php
-
With the effort he puts into his responses and the depth of knowledge he shows on a regular basis, I'm somewhat surprised he only has 1000. Congrats Barand!
-
That...and $montharray is a property of a class. So you would need to use $this->montharray to get the value.