G
G
gloribus2016-11-02 00:23:07
PHP
gloribus, 2016-11-02 00:23:07

How to compare data array and sql array from database?

A selection is taken from the database and there is an array of data of the form:

Array
(
    [id] => 112
    [value] => 5412
)
Array
(
    [id] => 1451
    [value] => 3134
)

From the database, too, the selection goes id and value
. You need to find the same id and compare value

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-11-02
@slo_nik

Goodnight.
How did you try to solve this problem? Show code.

G
gloribus, 2016-11-02
@gloribus

$cnt = count($answers);
$c = 0;	
while ($c < $cnt) {
 $id = $answers[$c]["name"];
 $value = $answers[$c]["value"];
while($tasks_row = $tasks->fetch_assoc()){
echo $tasks_row['id'];
echo "\r\n";	 
if($tasks_row['id'] == $task_id){
  if($value == $tasks_row['value'])echo "nice";
}	 
 }
 $c++;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question