Jump to content

Getting results in array


mostafatalebi

Recommended Posts

Uhm. You are "hostile" to using the functionality designed to make life easier on you because....?

 

Are you saying you want all the results in an array, and then access the array key? Or you want to give a function the ID and get that row?

Link to comment
Share on other sites

With Hostile I mean the id column of sql table do not update accordingly. OK if the id is the only solution I employ it.

My table has many many rows, and I need only the last six rows. I want to get all the rows and then by using array keys fetch them: $result[$size-1]; $result[$size-2] and ...;

 

If I could store only last six rows directly from the SQL statement, then life would be much easier.

Link to comment
Share on other sites

Sorry I again encountered a problem

 

The below part of script doesn't work with "prepare", while it easily runs with "query";

DEFINE("SELECT", "SELECT english, persian FROM ");

$statement = SELECT . $table . " ORDER BY id DESC LIMIT 6";

if($data = $database->query($statement))

{

$b = $data->fetch_array(MYSQLI_NUM);

echo $b[0] . " " . $b[1];

$data->close();

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.