MrsWeirdey MrsWeirdey - 3 months ago 9
MySQL Question

Can I select values from one column in an php-array?

I need only the values of one column in an array. Without php I would use "SELECT valueX FROM tableY".
This does not work with php. I only get one result.
This is what I have:

$salty = "SELECT salt FROM login";
$salts = mysqli_query($connection, $salty);
$validsalts = mysqli_fetch_array($salts);

Answer

You have to make a loop iteration for fetching the all value.

for example.

$salty = "SELECT salt FROM login";
$salts = mysqli_query($connection, $salty);
while($validsalts = mysqli_fetch_array($salts))
{
    echo $validsalts['salt'];
}