Jump to content

Barand

Moderators
  • Posts

    24,565
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Did you try the correct syntax that QuickOldCar suggested? SELECT * FROM sample; +-----------+--------+--------+--------+ | sample_id | cola | colb | colc | +-----------+--------+--------+--------+ | 1 | aabbcc | ddeeff | gghhii | <- match | 2 | ppqqrr | BBccdd | xxyyzz | <- | 3 | abcabc | defdef | hijhij | | 4 | zzzyyy | kkklll | ccaabB | <- | 5 | aaaaaa | cccccc | xxxxxx | +-----------+--------+--------+--------+ SELECT cola, colb, colc FROM sample WHERE (cola LIKE '%bb%') OR (colb LIKE '%bb%') OR (colc LIKE '%bb%'); +--------+--------+--------+ | cola | colb | colc | +--------+--------+--------+ | aabbcc | ddeeff | gghhii | | ppqqrr | BBccdd | xxyyzz | | zzzyyy | kkklll | ccaabB | +--------+--------+--------+
  2. Well done, guys. Thank you for your efforts.
  3. That code looks terribly repetitive. What is in the $cole array?
  4. // CREATE ARRAY WHOSE KEYS ARE THE DATES IN THE REQUIRED RANGE $dt1 = new DateTime('2015-03-30'); $dt2 = new DateTime('2015-04-05'); $dt2->modify('+1 day'); $dp = new DatePeriod($dt1, new DateInterval('P1D'), $dt2); foreach ($dp as $d) { $data[$d->format('Y-m-d')] = ''; } this gives $data = Array ( [2015-03-30] => [2015-03-31] => [2015-04-01] => [2015-04-02] => [2015-04-03] => [2015-04-04] => [2015-04-05] => ) When you process your query results drop the data into the array for the dates you have. You can loop through the array to get your final output with all dates
  5. He has used the proper array notation. Outside quoted strings he uses $_POST['title']. Inside quoted strings the index quotes are unnecessary as it cannot be taken for a defined constant as this example shows error_reporting(-1); define('index', 42); $data = array( 'index' => 123, 42 => 'constant used' ); echo "$data[index]"; // --> 123 echo $data['index']; // --> 123 echo $data[index]; // --> constant used [EDIT] Beaten at the post
  6. That date value as it is will insert into a DATE type field; CREATE TABLE `test_date` ( `id` int(11) NOT NULL AUTO_INCREMENT, `date` date DEFAULT NULL, PRIMARY KEY (`id`) ); INSERT INTO test_date (date) VALUES (20150315); SELECT * FROM test_date; +----+------------+ | id | date | +----+------------+ | 1 | 2015-03-15 | +----+------------+
  7. "a" and "google.com" in the query need to be inside single quotes SELECT COUNT(linkurl) FROM `link` where `username` = 'a' AND `linkurl` = 'google.com'
  8. "=" is the assignment operator. "==" is the equality operator
  9. No, you really don't want to do that. It just helps hackers by telling them which bit they got correct.
  10. You don't say what you want to achieve but I suspect your problem may be similar to this one http://forums.phpfreaks.com/topic/295214-joining-two-tables-and-returning-fields-from-maxid-row/?do=findComment&comment=1508035
  11. if the fields are in correct formats (yyyy-mm-dd and hh:ii:ss) then UPDATE mytable SET datetime = CONCAT(date, ' ', time)
  12. You should never put data provided by users (ie $_POST, $_GET) directly into a query, it leaves you wide open to SQL injection attacks. You should use mysql_real_escape_string() on the data first. This will also cure your problems with apostrophes in the data. Better still, stop using the deprecated mysql_ functions and use mysqli or PDO instead with prepared queries.
  13. Use double quotes instead of single quotes for the attribute value value="<?php echo $job_title ?>"
  14. You need to provide names for the form <selects> eg <select id="selectCountry" name="selectCountry" class="form-control" multiple>
  15. $getquery will either be a mysqli result or, if the query failed, it will be "false". As you get a message saying it is not a result then the query failed and there should be an error message $get = "SELECT * FROM `users`"; $getquery = mysqli_query($db,$get); if (!$getquery) echo $db->error;
  16. See what the error message is with echo $db->error;
  17. Pretty much the same way. An array of counts. $counts=array('pos' => 0, 'neu' => 0, 'neg' => 0); foreach ($strings as $string){ $scores = $sentiment->score($string); $class = $sentiment->categorise($string); $counts[$class]++; // increment count for the class }
  18. And without a day number in your data the sort order will be Fri, Mon, Sat, Sun, Thu, Tue, Wed
  19. You shouldn't have columns ball1, ball2, ... ballN. You should normalize the data correctly so each ball has its own row - then you have a single column to search. See this thread http://forums.phpfreaks.com/topic/295145-cannot-get-these-variables-to-add-up/?do=findComment&comment=1507842
  20. Before you can get the number of rows you need the results After the execute() either $res = $smt->get_result(); echo $res->num_rows; or $smt->store_result(); echo $smt->num_rows;
  21. Needs a rewrite of the pseudocode in that case skip = 0 loop call get_contact_list() using skip skip += 25 if no contacts returned exit loop end if process contacts end loop Is that better?
  22. pseudocode start = 0 loop call get_contact_list() using start start += 25 if no contacts returned exit loop end if process contacts end loop
  23. see http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/
  24. If the only thing that changes in each of the 10 graphs is the data then use the same "graph.php" but pass the different data (and maybe a caption) each time. Use something like this $data_1 = array(1,2,3); $data_2 = array(5,6,7); $g1_data = json_encode($data_1); // convert to a string $g2_data = json_encode($data_2); // convert to a string echo "<img src='graph.php?caption=chart_1&data=$g1_data' />"; echo "<img src='graph.php?caption=chart_2&data=$g2_data' />"; In graph.php the data will be in $_GET['data'] $data_array = json_decode($_GET['data'], 1); // reconstruct data array // create graph
  25. http://lmgtfy.com/?q=news+ticker+for+website
×
×
  • 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.