-
Posts
24,606 -
Joined
-
Last visited
-
Days Won
831
Everything posted by Barand
-
I've rewritten this section to use the [$m] in the arrays /********************************************************** * create table from array data ***********************************************************/ foreach ($data as $cid=>$cdata) { $trows .= "<tr><td>$cid</td><td class='cn'>{$cdata['name']}</td>"; foreach ($cdata['events'] as $m => $dates) { $trows .= "<td class='dt'>" . join('<br>', $dates) . "<div class='add_more' data-id='$cid' data-month='$m'>+</div></td>"; } $trows .= "</tr>\n"; }
-
Can PHP integrate with microsoft sql by using mysqli?
Barand replied to FooKelvin's topic in MySQL Help
Why do you want to change from sqlsrv if you are still using SQLServer? -
I was using "$m" as an example of a month number variable
-
Can PHP integrate with microsoft sql by using mysqli?
Barand replied to FooKelvin's topic in MySQL Help
No. mysqli_ functions, like mysql_ , are for the MySql database server just as sqlsrv functions are for MS SQL Server. PDO, however, is database independent so you could use that. -
I'd make use of data attributes. <div class='add_more' data-id='$cid' data-month='$m'>
-
How to obtain last id number, to submit in Picasso for App..
Barand replied to dave204's topic in PHP Coding Help
Topics merged. -
Display vs POST info in a mysql based dropdown
Barand replied to itgranny's topic in PHP Coding Help
if you have <option value='$id'>$name</option> then the name is displayed but the id (value) is posted. -
Topics merged
-
@maxxd, He is intent on doing this way regardless of attempts to advise otherwise http://forums.phpfreaks.com/topic/298429-imploding-a-multi-dimensional-array/?do=findComment&comment=1522337
-
Your form needs a submit button. Your select has name='site' therefore the value will be in $_POST['site']
-
use a function which takes an array as its argument. You can then use the same function for sites, people etc by just passing it a different array. <?php $sql1="SELECT Site_ID, Site_name_1 FROM `Sites`"; $result1=mysql_query($sql1); $site_array = array(); while (list($id, $name) = mysql_fetch_row($result1)) { $site_array[$id] = $name; } function get_options($arr, $current=null) { $opts = ''; foreach ($arr as $k => $v) { $sel = $k==$current ? 'selected="selected"' : ''; $opts .= "<option value='k' $sel>$v</option>\n"; } return $opts; } ?> <html> <body> <select name='site'> <?php echo get_options($site_array);?> </select> </body> </html>
-
foreach($cars as $a) { $tmp[] = join('||', $a); } $result = join('~', $tmp); echo $result; //--> goat||22||18~pig||15||13~rabbit||5||2~doe||17||15
-
read a cvs file and only displaying some data
Barand replied to manhattes's topic in PHP Coding Help
Then why don't you select STR_TO_DATE(completion_date, '%W, %M %d %Y') from your table so you have the format you need. It really is time you converted those dates in your table - it seems to be popping up often in your posts. -
use json_decode($json, true); to get an array as the result.
-
His original query (from opening post) was ... WHERE STR_TO_DATE(`Completion Date`, '%W, %M %e, %Y') BETWEEN CURDATE() AND CURDATE() + INTERVAL (90) DAY which does convert the date string, but contains an error in the BETWEEN clause (ie next 90 days instead of last 90 days). And the output from STR_TO_DATE() mysql> SELECT STR_TO_DATE('Tuesday, October 6 2015', '%W, %M %e %Y') as date; +------------+ | date | +------------+ | 2015-10-06 | +------------+ is definitely yyyy-mm-dd format and is human-readable, contrary to your statement.
-
@ginerjm, If you were to RTFM I think you would find it (str_to_date) does create a date in yyyy-mm-dd format mysql> SELECT STR_TO_DATE('Tuesday, October 6 2015', '%W, %M %e %Y') as date; +------------+ | date | +------------+ | 2015-10-06 | +------------+
-
No. Have another look at my BETWEEN clause. The earlier date must come first. It would be be more efficient to reformat the date once on import instead of in every query.
-
For last 90 days WHERE ... BETWEEN CURDATE() - INTERVAL 90 DAY AND CURDATE() And GROUP BY should be at the end of the query
-
The syntax is INSERT INTO `formular_client` (`client_cv`) VALUES ('$actual_image_name') or INSERT INTO `formular_client` SET `client_cv` = '$actual_image_name'
-
And as none of the OP's forms have an id attribute, and none of his inputs have a form attribute, then this is irrelevant.
-
You can do that, but if your aim is to reduce the array to a single string then use json_encode $cars = array ( array("Volvo",22,18), array("BMW",15,13), array("Saab",5,2), array("Land Rover",17,15) ); $str = json_encode($cars); echo $str; //--> [["Volvo",22,18],["BMW",15,13],["Saab",5,2],["Land Rover",17,15]] to recreate the array again, you then use $cars = json_decode($str, true);
-
Why is this not working when put in a variable?
Barand replied to WaxyChicken's topic in PHP Coding Help
this line if ($urlFile = "") sets the $urlFile to '' You need the comparison operator "==" and not the assignment operator "=" -
Does this version work for you - enclosing the search text in single quotes and no escape of the double quotes? UPDATE `testsig` SET `signature` = replace( signature, '<p style="text-align:center;"> </p>', '' ) ; mysql> UPDATE `testsig` -> SET `signature` = replace( signature, '<p style="text-align:center;"> </p>', '' ) ; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0
-
ginerjm told you what was wrong with that line (in reply #4)and re-wrote it for you