D
D
dsjohn2021-05-12 09:19:25
PHP
dsjohn, 2021-05-12 09:19:25

How to match by Id in psql?

there is a query to the database and output, but for some reason it does not work by id search only by 1 and not by all, I tried to change id to i or [i] also changed to pg_fetch_assoc and pg_fetch_array but nothing helps

$query = 'SELECT name FROM database';
$result = pg_query($query);
$myrow = pg_fetch_assoc($result);
$value = $myrow[name];
if ($value == "$word") {
    $query2 = 'SELECT path FROM documents';
    $result2 = pg_query($query2);
    $myrow2 = pg_fetch_assoc($result2);
    $value2 = $myrow2[path];
    echo "$value2";
} elseif ($value <> $word) {
    echo "нераспознало или нету в базе данных";
}

Answer the question

In order to leave comments, you need to log in

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

Comparison

$str = pg_escape_string($ip);
$result2 = pg_query($dbconn, "SELECT * FROM table WHERE name = '{$str}'");
really terrible community

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question