-
Posts
24,565 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
problem with searching case sensitive database entries
Barand replied to izzy's topic in PHP Coding Help
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 | +--------+--------+--------+ -
Well done, guys. Thank you for your efforts.
-
That code looks terribly repetitive. What is in the $cole array?
-
// 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
-
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
-
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 | +----+------------+
-
how i can checking the duplicate links with php and mysql ?
Barand replied to mikhak's topic in PHP Coding Help
"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' -
"=" is the assignment operator. "==" is the equality operator
-
Alternative to using a where clause in a left join nested subquery
Barand replied to idkwhy's topic in MySQL Help
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 -
Inserting date & time from two fields into one column
Barand replied to adrianle's topic in PHP Coding Help
if the fields are in correct formats (yyyy-mm-dd and hh:ii:ss) then UPDATE mytable SET datetime = CONCAT(date, ' ', time) -
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.
-
Use double quotes instead of single quotes for the attribute value value="<?php echo $job_title ?>"
-
You need to provide names for the form <selects> eg <select id="selectCountry" name="selectCountry" class="form-control" multiple>
-
$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;
-
See what the error message is with echo $db->error;
-
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 }
-
Having trouble grouping a PHP list in dropdown menu
Barand replied to vbcoach's topic in PHP Coding Help
And without a day number in your data the sort order will be Fri, Mon, Sat, Sun, Thu, Tue, Wed -
pass variable to mysql statement in foreach loop
Barand replied to phillyrob0817's topic in MySQL Help
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 -
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;
-
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?
-
see http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/
- 1 reply
-
- 1
-
a logic issue in creating multiple graphs using phpgraphlib
Barand replied to ajoo's topic in PHP Coding Help
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 -
http://lmgtfy.com/?q=news+ticker+for+website