D
D
dsjohn2021-05-10 22:43:19
PHP
dsjohn, 2021-05-10 22:43:19

How to compare and output variables in psql?

there is a php script that displays a certain word, tried to compare by assigning additional variables, nothing helped. If the value is true, you need to display another column with this id, but did not even display the column itself

if($_POST['country']){
  $result = $pdo->pg_query("SELECT `name_doc` FROM `test_table` WHERE `number` = ".$_POST['name']."");
  while ($row = $result->fetch_row()) {
        printf ("%s (%s)\n", $row[0], $row[1]);
    }
}
$pdo->close();
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dsjohn, 2021-05-11
@dsjohn

Long story short, I solved this problem myself.

$query = 'SELECT name FROM database';
$result = pg_query($query);
$myrow = pg_fetch_assoc($result, [$myVar = array()] );
$value = $myrow[name];
//echo "$value";
//echo "$word";
if ($value == "$word") {
    $query2 = 'SELECT path FROM documents';
    $result2 = pg_query($query2);
    $myrow2 = pg_fetch_assoc($result2, [$myVar = array()]);
    $value2 = $myrow2[path];
    echo "$value2";
} elseif ($value <> $word) {
    echo "pozshral";
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question