How fetch specified column by rows number in PHP

Home / Uncategorized / How fetch specified column by rows number in PHP

Question:
I have a table with 5 column and a lot of rows. i want to fetch column number 3 for each rows that i select from my DB and store them in variables for compare together.

for example my data:row 1 | column 1 column 2 column 3

row 2 | column 1 column 2 column 3

then i want to store column 3 for each rows and store them in variables and then compare the variables :variable 1 (row 1 , column 3) >= or =< variable 2 (row 2 , column 3)


Answer:
$query = "SELECT * FROM table";
$results = mysqli_query($con, $query);

$var = [];

while ($row = mysqli_fetch_array($results)) {
$var[] = $row[‘column3’];
}

Then you can do anything with your variables array.
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *