Jump to content

Barand

Moderators
  • Posts

    24,603
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. Also post the query/ies that are giving the problem. Rewriting the SQL can often have significant performance increase.
  2. Oops! typo. Remove the "pm" after "ON" UPDATE pm INNER JOIN Users2 u ON pm u.mxitid = pm.ip SET pm.username = u.username
  3. $a = [1,2,3] was introduced in 5.4
  4. What version of PHP are you using? If it's an old version try return array( .... ) instead of return [ .... ]
  5. UPDATE pm INNER JOIN Users2 u ON pm u.mxitid = pm.ip SET pm.username = u.username
  6. Plan C <?php $narray[]="Trump denounces violence after supporters beat Mexican man"; $narray[]="Doyle: What my dad could teach Donald Trump"; $narray[]="Bush slams Trump, defends using anchor babies"; $narray[]="Coming up Trumps: could a British TV star do a Donald and enter politics?"; $narray[]="Watch Rachel Maddow Explain Donald Trump’s ‘Genius’ Campaign on Tonight Show"; $narray[]="Trump touts making Time cover while taking heat over attack"; $narray[]="First Draft: Today in Politics: Rivals Can No Longer Ignore Donald Trump’s Long Shadow"; $narray[]="Donald Trump insists he’s conservative"; $narray[]="GOP candidates hold dueling town halls"; $narray[]="New York City has no way to fire Donald Trump"; $narray[]="Donald Trump pushes birthright citizenship to forefront of political debate"; $narray[]="Jeb Bush takes fight to Donald Trump in N.H."; $narray[]="Rand Paul explains why he wants to stop ‘birthright citizenship’"; $narray[]="Trump attacks Facebook over foreigners"; $narray[]="Donald Trump tops GOP field in Florida, Pennsylvania, second in Ohio"; $narray[]="Donald Trump draws New Hampshire town hall crowd wild; jabs Jeb Bush"; $narray[]="While in Vegas, O’Malley makes an appearance in front of Trump’s hotel"; $narray[]="Trump’s immigration plan has GOP rivals on edge"; $narray[]="Donald Trump calls out Mark Zuckerberg on immigration"; $narray[]="Deny citizenship to babies illegal immigrants in US: Donald Trump"; $narray[]="Donald Trump takes a break from the campaign trail to join a long list of celebrities to perform jury duty"; $narray[]="Trump: Deny citizenship to babies of people illegally in US"; $narray[]="Trump Says He Would Deport Illegal Immigrants"; $narray[]="From campaign to court: Trump reports for jury duty in NYC"; $narray[]="Donald Trump says he will ‘deport millions of illegal immigrants’"; $narray[]="Trump outlines immigration specifics"; $narray[]="Donald Trump to Iowa boy: ‘I am Batman’"; $narray[]="Trump blunt but vague: No birthright citizenship, millions of illegal immigrants ‘have to go’"; $narray[]="Trump: end ‘birthright citizenship’"; $narray[]="Trump: Deport children of immigrants living illegally in US"; $narray[]="DNC blasts Donald Trump , Jeb Bush for comments about women"; $narray[]="Trump says would raise visa fees to pay for Mexican border wall"; $narray[]="What does Donald Trump think of immigrants, Saudi Arabia and the Iran nuclear deal?"; $narray[]="Donald Trump Releases Plan to Combat Illegal Immigration"; $narray[]="Donald Trump releases his immigration policy on his GOP presidential campaign website"; $narray[]="Donald Trump warns that Iran deal will lead to Nuclear Holocaust"; $narray[]="Trump details domestic, foreign policies, answers critics, matches fellow challengers"; $narray[]="Donald Trump’s legacy of luxury"; $narray[]="Clinton defends, Trump attacks Saturday at the high-profile Iowa State Fair"; $narray[]="Donald Trump says he would deport all illegal immigrants as president"; $narray[]="Donald Trump breaks the rules at the Iowa State Fair"; $narray[]="Thanks, Donald, but I don’t want to be ‘cherished’ | Barbara Ellen"; $narray[]="Front-runners skirt the soapbox"; $narray[]="Hillary Clinton, Donald Trump and the Trumpcopter descend on the Iowa State Fair"; $narray[]="Op-Ed Columnist: Introducing Donald Trump, Diplomat"; $narray[]="Trump forced to break from campaign trail for jury duty, skipped five summonses since 2006"; $narray[]="Donald Trump forced to take break from campaign trail for jury service"; $narray[]="Tables turned on Trump’s chief tormentor"; $narray[]="Donald Trump will serve jury duty in NYC next week"; $filtered = filter_my_array($narray); // keywords only array $kwindex = index_keywords($filtered); // index of keywords $keywords = array_keys($kwindex); // // find items with no keywords // $otheritems = []; foreach ($filtered as $k=>$v) { if (count($v)==0) $otheritems[] = $k; } // // combine indexes // uasort($filtered, function($a,$b) {return count($b) - count($a);}); $k = count($filtered); for ($x=0; $x<2; $x++) { for ($i=0; $i<$k-1; $i++) { for ($j=$i+1; $j<$k; $j++) { $a = $filtered[$i]; $b = $filtered[$j]; if (array_intersect($a, $b)) { $filtered[$i] = array_unique(array_merge($a,$b)); $filtered[$j]=[]; } } } } foreach ($filtered as $k => $kwarr) { if (count($kwarr) == 0) { continue; } elseif (count($kwarr) > 1) { sort($kwarr); $newkw = join(' - ', $kwarr); $occurs = []; foreach ($kwarr as $kw) { if (isset($kwindex[$kw])) { $occurs = array_merge($occurs, $kwindex[$kw]); // combine individual lists unset($kwindex[$kw]); // then remove them } } sort($occurs); $kwindex[$newkw] = array_unique($occurs); // add the combined index } } // // create highlighting replacement textss // $replace = []; foreach ($keywords as $kw) { $replace[] = "<span class='hi'>$kw</span>"; } // // create output of the indexed list // ksort($kwindex); $output = ''; foreach ($kwindex as $kw => $items) { if (count($items)==0) continue; $output .= "<h4>$kw</h4><ul>"; foreach ($items as $i) { $output .= "<li>" . str_ireplace($keywords, $replace, $narray[$i]) . "</li>\n"; } $output .= "</ul>\n"; } if (count($otheritems) > 0) { $output .= "<h4>Non-keyword items</h4><ul>"; foreach ($otheritems as $i) { $output .= "<li>{$narray[$i]}</li>\n"; } $output .= "</ul>\n"; } /******************************************************************************* * helper functions ********************************************************************************/ function filter_my_array($array) { // reduces the lines of text to arrays of the keywords in the line $results = []; foreach ($array as $k => $str) { $str = no_punc($str); $a = array_filter(explode(' ', $str), 'remove_noise'); $results[$k] = $a; } return $results; } function remove_noise($x) { $stopWords = array('about','an','and','are','as','at','be','by','com','de','en','for','from', 'how','in','is','it','la','of','on','or','that','the','this','to','was','what','when','where', 'who','will','with','und','the','www','donald','trump'); return strlen($x) > 4 && !in_array(strtolower($x), $stopWords); } function index_keywords($array) { // gets the line numbers containing each keyword $results = []; foreach ($array as $k => $kwarr) { foreach ($kwarr as $kw) { $results[$kw][] = $k; } } return $results; } function no_punc($str) { $allow = array_merge([32], range(ord('a'), ord('z')), range(ord('0'), ord('9'))); $k = strlen($str); $res = ''; $str = strtolower($str); for ($i=0; $i<$k; $i++) { if (in_array(ord($str[$i]), $allow) ) { $res .= $str[$i]; } else $res .= ' '; } return $res; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Keyword Index</title> <style type='text/css'> .hi { font-weight: 700; color: red; } </style> </head> <body> <?=$output?> </body> </html> output <html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Keyword Index</title> <style type="text/css"> .hi { font-weight: 700; color: red; } </style> </head> <body> <h4>after - anchor - arabia - attacks - babies - birthright - blunt - border - break - breaks - british - calls - campaign - celebrities - children - citizenship - clinton - combat - coming - could - court - debate - defends - denounces - deport - descend - doyle - draft - enter - explain - explains - facebook - fight - first - forced - forefront - foreigners - genius - hillary - holocaust - ignore - illegal - illegally - immigrants - immigration - living - longer - maddow - mexican - millions - nuclear - outlines - people - perform - policy - political - politics - president - presidential - profile - pushes - rachel - raise - releases - reports - rivals - rules - saturday - saudi - service - shadow - since - skipped - slams - specifics - state - summonses - supporters - takes - teach - think - today - tonight - trail - trumpcopter - trumps - using - vague - violence - wants - warns - watch - website - would - zuckerberg</h4><ul><li>Trump <span class="hi">denounces</span> <span class="hi">violence</span> <span class="hi">after</span> <span class="hi">supporters</span> beat <span class="hi">mexican</span> man</li> <li><span class="hi">doyle</span>: What my dad <span class="hi">could</span> <span class="hi">teach</span> Donald Trump</li> <li>Bush <span class="hi">slams</span> Trump, <span class="hi">defends</span> <span class="hi">using</span> <span class="hi">anchor</span> <span class="hi">babies</span></li> <li><span class="hi">coming</span> up <span class="hi">trumps</span>: <span class="hi">could</span> a <span class="hi">british</span> TV star do a Donald and <span class="hi">enter</span> <span class="hi">politics</span>?</li> <li><span class="hi">watch</span> <span class="hi">rachel</span> <span class="hi">maddow</span> <span class="hi">explain</span> Donald Trump’s ‘<span class="hi">genius</span>’ <span class="hi">campaign</span> on <span class="hi">tonight</span> Show</li> <li><span class="hi">first</span> <span class="hi">draft</span>: <span class="hi">today</span> in <span class="hi">politics</span>: <span class="hi">rivals</span> Can No <span class="hi">longer</span> <span class="hi">ignore</span> Donald Trump’s Long <span class="hi">shadow</span></li> <li>Donald Trump <span class="hi">pushes</span> <span class="hi">birthright</span> <span class="hi">citizenship</span> to <span class="hi">fore<span class="hi">front</span></span> of <span class="hi">political</span> <span class="hi">debate</span></li> <li>Jeb Bush <span class="hi">takes</span> <span class="hi">fight</span> to Donald Trump in N.H.</li> <li>Rand Paul <span class="hi">explain</span>s why he <span class="hi">wants</span> to stop ‘<span class="hi">birthright</span> <span class="hi">citizenship</span>’</li> <li>Trump <span class="hi">attack</span>s <span class="hi">facebook</span> over <span class="hi"><span class="hi">foreign</span>ers</span></li> <li>Trump’s <span class="hi">immigration</span> plan has GOP <span class="hi">rivals</span> on edge</li> <li>Donald Trump <span class="hi">calls</span> out Mark <span class="hi">zuckerberg</span> on <span class="hi">immigration</span></li> <li>Deny <span class="hi">citizenship</span> to <span class="hi">babies</span> <span class="hi">illegal</span> <span class="hi">immigrants</span> in US: Donald Trump</li> <li>Donald Trump <span class="hi">takes</span> a <span class="hi">break</span> from the <span class="hi">campaign</span> <span class="hi">trail</span> to join a long list of <span class="hi">celebrities</span> to <span class="hi">perform</span> jury duty</li> <li>Trump: Deny <span class="hi">citizenship</span> to <span class="hi">babies</span> of <span class="hi">people</span> <span class="hi">illegal</span>ly in US</li> <li>Trump Says He <span class="hi">would</span> <span class="hi">deport</span> <span class="hi">illegal</span> <span class="hi">immigrants</span></li> <li>From <span class="hi">campaign</span> to <span class="hi">court</span>: Trump <span class="hi">reports</span> for jury duty in NYC</li> <li>Donald Trump says he will ‘<span class="hi">deport</span> <span class="hi">millions</span> of <span class="hi">illegal</span> <span class="hi">immigrants</span>’</li> <li>Trump <span class="hi">outlines</span> <span class="hi">immigration</span> <span class="hi">specifics</span></li> <li>Trump <span class="hi">blunt</span> but <span class="hi">vague</span>: No <span class="hi">birthright</span> <span class="hi">citizenship</span>, <span class="hi">millions</span> of <span class="hi">illegal</span> <span class="hi">immigrants</span> ‘have to go’</li> <li>Trump: end ‘<span class="hi">birthright</span> <span class="hi">citizenship</span>’</li> <li>Trump: <span class="hi">deport</span> <span class="hi">children</span> of <span class="hi">immigrants</span> <span class="hi">living</span> <span class="hi">illegal</span>ly in US</li> <li>Trump says <span class="hi">would</span> <span class="hi">raise</span> visa fees to pay for <span class="hi">mexican</span> <span class="hi">border</span> wall</li> <li>What does Donald Trump <span class="hi">think</span> of <span class="hi">immigrants</span>, <span class="hi">saudi</span> <span class="hi">arabia</span> and the Iran <span class="hi">nuclear</span> deal?</li> <li>Donald Trump <span class="hi">releases</span> Plan to <span class="hi">combat</span> <span class="hi">illegal</span> <span class="hi">immigration</span></li> <li>Donald Trump <span class="hi">releases</span> his <span class="hi">immigration</span> <span class="hi">policy</span> on his GOP <span class="hi"><span class="hi">president</span>ial</span> <span class="hi">campaign</span> <span class="hi">website</span></li> <li>Donald Trump <span class="hi">warns</span> that Iran deal will lead to <span class="hi">nuclear</span> <span class="hi">holocaust</span></li> <li><span class="hi">clinton</span> <span class="hi">defends</span>, Trump <span class="hi">attack</span>s <span class="hi">saturday</span> at the high-<span class="hi">profile</span> Iowa <span class="hi">state</span> Fair</li> <li>Donald Trump says he <span class="hi">would</span> <span class="hi">deport</span> all <span class="hi">illegal</span> <span class="hi">immigrants</span> as <span class="hi">president</span></li> <li>Donald Trump <span class="hi">break</span>s the <span class="hi">rules</span> at the Iowa <span class="hi">state</span> Fair</li> <li><span class="hi">hillary</span> <span class="hi">clinton</span>, Donald Trump and the <span class="hi">trumpcopter</span> <span class="hi">descend</span> on the Iowa <span class="hi">state</span> Fair</li> <li>Trump <span class="hi">forced</span> to <span class="hi">break</span> from <span class="hi">campaign</span> <span class="hi">trail</span> for jury duty, <span class="hi">skipped</span> five <span class="hi">summonses</span> <span class="hi">since</span> 2006</li> <li>Donald Trump <span class="hi">forced</span> to take <span class="hi">break</span> from <span class="hi">campaign</span> <span class="hi">trail</span> for jury <span class="hi">service</span></li> </ul> <h4>answers - challengers - critics - details - domestic - fellow - foreign - matches - policies</h4><ul><li>Trump <span class="hi">details</span> <span class="hi">domestic</span>, <span class="hi">foreign</span> <span class="hi">policies</span>, <span class="hi">answers</span> <span class="hi">critics</span>, <span class="hi">matches</span> <span class="hi">fellow</span> <span class="hi">challengers</span></li> </ul> <h4>appearance - attack - cover - front - hotel - makes - making - malley - runners - skirt - soapbox - taking - touts - vegas - while</h4><ul><li>Trump <span class="hi">touts</span> <span class="hi">making</span> Time <span class="hi">cover</span> <span class="hi">while</span> <span class="hi">taking</span> heat over <span class="hi">attack</span></li> <li><span class="hi">while</span> in <span class="hi">vegas</span>, O’<span class="hi">malley</span> <span class="hi">makes</span> an <span class="hi">appearance</span> in <span class="hi">front</span> of Trump’s <span class="hi">hotel</span></li> <li><span class="hi">front</span>-<span class="hi">runners</span> <span class="hi">skirt</span> the <span class="hi">soapbox</span></li> </ul> <h4>barbara - cherished - ellen - thanks</h4><ul><li><span class="hi">thanks</span>, Donald, but I don’t want to be ‘<span class="hi">cherished</span>’ | <span class="hi">barbara</span> <span class="hi">ellen</span></li> </ul> <h4>batman</h4><ul><li>Donald Trump to Iowa boy: ‘I am <span class="hi">batman</span>’</li> </ul> <h4>blasts - comments - women</h4><ul><li>DNC <span class="hi">blasts</span> Donald Trump , Jeb Bush for <span class="hi">comments</span> about <span class="hi">women</span></li> </ul> <h4>candidates - dueling - halls</h4><ul><li>GOP <span class="hi">candidates</span> hold <span class="hi">dueling</span> town <span class="hi">halls</span></li> </ul> <h4>chief - tables - tormentor - turned</h4><ul><li><span class="hi">tables</span> <span class="hi">turned</span> on Trump’s <span class="hi">chief</span> <span class="hi">tormentor</span></li> </ul> <h4>columnist - diplomat - introducing</h4><ul><li>Op-Ed <span class="hi">columnist</span>: <span class="hi">introducing</span> Donald Trump, <span class="hi">diplomat</span></li> </ul> <h4>conservative - insists</h4><ul><li>Donald Trump <span class="hi">insists</span> he’s <span class="hi">conservative</span></li> </ul> <h4>crowd - draws - hampshire</h4><ul><li>Donald Trump <span class="hi">draws</span> New <span class="hi">hampshire</span> town hall <span class="hi">crowd</span> wild; jabs Jeb Bush</li> </ul> <h4>field - florida - pennsylvania - second</h4><ul><li>Donald Trump tops GOP <span class="hi">field</span> in <span class="hi">florida</span>, <span class="hi">pennsylvania</span>, <span class="hi">second</span> in Ohio</li> </ul> <h4>legacy - luxury</h4><ul><li>Donald Trump’s <span class="hi">legacy</span> of <span class="hi">luxury</span></li> </ul> <h4>serve</h4><ul><li>Donald Trump will <span class="hi">serve</span> jury duty in NYC next week</li> </ul> <h4>Non-keyword items</h4><ul><li>New York City has no way to fire Donald Trump</li> </ul> </body></html>
  7. is this what you had in mind? $prevkey = ''; foreach ($flavors as $k1 => $arr) { foreach ($arr as $k2 => $v ) { if ($v=='') { if (isset($flavors[$prevkey][$k2])) { $flavors[$k1][$k2] = $flavors[$prevkey][$k2]; } } $prevkey = $k1; } } echo '<pre>',print_r($flavors, true),'</pre>'; gives Array ( [Japanese] => Array ( [hot] => wasabi [salty] => soy sauce ) [Chinese] => Array ( [hot] => wasabi [pepper-salty] => prickly ash ) [indian] => Array ( [hot] => wasabi [pepper-salty] => prickly ash ) [mexican] => Array ( [hot] => soanzo [salty] => soy sauce ) [russian] => Array ( [hot] => soanzo [pepper-salty] => prickly ash ) [ganda] => Array ( [hot] => soanzo [pepper-salty] => prickly ash ) )
  8. A database isn't just an alternative content holder. It also gives you the ability to search and sort.
  9. Which you could also do with a form to update the contents of database records
  10. If you got around to trying it you would find you get a syntax error when using LEFT JOIN without a join condition (ON or USING)
  11. Why are you binding params to a query that has no parameters?
  12. Nothing in that code will do it. Do you have any javascript on the page that might be putting them there?
  13. Here's an example of my method The javascript increments/decrements a counter variable when a checkbox is checked/unchecked and puts the counter value in the corresponding text field. When processing the form we get the ids that were selected from the checkboxes. This gives our IN (x,y,z) for the selection from the table. This won't affect the order of the selection since IN (x,y,z) gives the same results as IN (z,y,x). To get the right order we specify the order in which we want the id field to be selected using ORDER BY FIELD(id, y,x,z). We get the y,x,z by sorting on the $_GET['seq'] values. <?php $mysqli = new mysqli(HOST,USERNAME,PASSWORD,'test'); /** my data ******************************************* CREATE TABLE candidate ( id int not null auto_increment primary key, name varchar(40) ); INSERT INTO candidate (name) VALUES ('Anne Adamson'), ('Ben Brown'), ('Charles Cummins'), ('David Dent'), ('Emma Ellis'), ('Fiona Fleming'), ('George Glover'), ('Henry Horner'), ('Ian Illingworth'), ('Jane Jenkins'); *******************************************************/ // // process the voting form // $results = ''; if (isset($_GET['candidate'])) { $list = join(',', $_GET['candidate']); // selected candidates' ids // find the order they were selected $seqarray=[]; foreach ($_GET['seq'] as $id => $seq) { if ($seq) { $seqarray[$seq] = $id; } } ksort($seqarray); // sort ids into correct sequence $seqlist = join(',', $seqarray); // get the candidates in the required order $sql = "SELECT name FROM candidate WHERE id IN ($list) ORDER BY FIELD(id,$seqlist)"; $results = "You voted for<ol>"; $res = $mysqli->query($sql); while ($row = $res->fetch_row()) { $results .= "<li>$row[0]</li>"; } $results .= "</ol></hr>\n"; } // // create the voting input form // $sql = "SELECT id , name FROM candidate ORDER BY id "; $res = $mysqli->query($sql); $clist = "<table>\n"; while (list($id, $name) = $res->fetch_row()) { $clist .= "<tr> <td>$name</td> <td><input type='checkbox' name='candidate[]' value='$id' class='candidate'> <td><input type='text' name='seq[$id]' id='seq$id' size='2' class='seq' readonly> <tr>\n"; } $clist .= "</table>\n"; ?> <!DOCTYPE html> <html> <head> <title>Voting Form</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type='text/javascript'> var counter = 0; $().ready(function() { $("#btnReset").click(function(){counter=0;}) $(".candidate").click(function() { var id = $(this).val(); if (this.checked) { if (counter < 3) { ++counter; $("#seq"+id).val(counter); } else { this.checked = false; } } else { --counter; $("#seq"+id).val(''); } }) }) </script> </head> <body> <?=$results?> <form> <h3>Select 3 candidates in order of preference</h3> <?=$clist?> <input type='submit' name='btnSubmit' value='Vote'> <input type='reset' name='btnReset' id='btnReset' value='Reset'> </form> </body> </html>
  14. You need to save the changes so you do not reset the input each time foreach($result as $row){ // set replacement to be the string from db $str = file_get_contents("templates/staff.html", true); $replace = $row['content']; $srch = $row['location']; $str = $this->replace($srch, $replace, $str); file_put_contents("templates/staff.html", $str); // ADD }
  15. Most of your problems are to do with "variable scope". Variables used inside functions only exist within that function. so public function Init($n, $db, $g, $nl) { $Name = $n; $Database = $db; $Game = $g; $NoticeLeave = $nl; } needs to be like this to set the class properties public function Init($n, $db, $g, $nl) { $this->Name = $n; $this->Database = $db; $this->Game = $g; $this->NoticeLeave = $nl; } The same goes for your "$struct" array in the "AddDefinition()" function. Also you should avoid globals (which,BTW, should have been global $struct. A better way is for your function to return the instance then add it to the array. Finally, $struct is an array of objects and not an object so you cannot use $struct->name. Use foreach to loop through the array. class GameStruct { public $Name; public $Database; public $Game; public $NoticeLeave; public function Init($n, $db, $g, $nl) { $this->Name = $n; $this->Database = $db; $this->Game = $g; $this->NoticeLeave = $nl; } } function AddDefinition( $name, $database, $game, $notice ) { $instance = new GameStruct; $instance->Init( $name, $database, $game, $notice ); return $instance; } $struct = Array(); $struct[] = AddDefinition( "leavecsgo", "comp_user", "Csgo", "Du har nu lämnat CS:GO-turneringen!" ); $struct[] = AddDefinition( "leavesmite", "comp_user", "Smite", "Du har nu lämnat Smite-turneringen!" ); $struct[] = AddDefinition( "leavefifa", "comp_user", "Fifa", "Du har nu lämnat Fifa-turneringen!" ); $struct[] = AddDefinition( "leavehearthstone", "comp_user", "Hearthstone", "Du har nu lämnat Hearthstone-turneringen!" ); $struct[] = AddDefinition( "leavedota2", "comp_user", "Dota2", "Du har nu lämnat Dota2-turneringen!" ); foreach ($struct as $sobj) { if( !isset( $_POST[ $sobj->Name ] ) ) { $sql = $con->query("DELETE FROM `{$sobj->Database}` WHERE Username='{$Username}' AND Game='{$sobj->Game}'"); $format = 'alert("%s");'; echo '<script >'; echo sprintf( $format, $sobj->NoticeLeave ); echo '</script>'; } }
  16. That is not what the code you posted shows. We cannot help with your code if you post something different from what you are really doing.
  17. That error is a result of your processing of the query (code not shown), not the query itself. WHERE orders.due_date BETWEEN '2014-01-01' AND '2016-08-21' was OK. Do you really have future orders? Or do you want WHERE orders.due_date BETWEEN '2014-01-01' AND CURDATE()
  18. Are you asking how to subtract 1 day from $data_P?
  19. Because there is no record in course table where the course.id matches the user.course for Emma in the user table
  20. you are missing the comma before SUM and you have too many "WHERE"s. PS It is more useful to tell us what you are trying to do instead of what you are not trying to do
  21. yes, but neither will prevent you adding (2,3) and (3,2)
  22. You could set a rule that the lower id is the user and higher id is the friend when adding the record and put a unique constraint on (user_id, friend_id)
  23. A schema like this here http://forums.phpfreaks.com/topic/297801-how-can-i-write-a-query-select-from-table-where-a-pair-of-record-is-not-there/?do=findComment&comment=1518909 would fit that requrement
  24. this line $str = file_get_contents("templates/staff.html", true); needs to be before the loop otherwise you reset the content each time
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.