-2

I am trying to insert a row into a database. I have inserted a few rows into a table. When I open the database on phpmyadmin it seems that all the rows were inserted. However when i then later try to retrieve a column from the table it only says that there is one row (the first inserted row). but it doesn't retrieve the other rows. Any help would be appreciated. below is the relevant code

$result = mysqli_query($cxn, 'select AssetId FROM About');
$rows = mysqli_fetch_array($result, MYSQLI_NUM);
$len = count($rows);
print_r($rows);
$curAsId = $rows[$len - 1];

This is the output of print_r

Array ( [0] => 1 )

when it should display many more rows

1
  • Hint: mysqli_fetch_array() only returns one row. Try echo $result->num_rows for an actual count Commented Aug 4, 2016 at 1:08

1 Answer 1

-1

Try this:

$result = mysqli_query($cxn, 'select AssetId FROM About');
while ($rows = mysqli_fetch_array($result, MYSQLI_NUM)) {
$len = count($rows);
print_r($rows);
echo $curAsId = $rows[$len - 1];
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.