Forum Moderators: coopster
I need to know how to go about getting certain data (namely the first 3 entries) from a mysql database, and putting it into an array, to then echo around various parts of the page.
I found a few things on mysql_fetch_array and the like but cant seem to get them to work fully.
The current script (which i dont have access to here at home) is setup to fetch the latest mysql entry and echo it using variables, setup into an array itself, from the various columns in that database table row. Does that make sense?
So, What i need to do is get the first 3 entries seperate, into an array, so i can then control where they appear on the page.
Any help would be appreciated
:)
Its pulling the first entries out of the database and not the most recent. Although with this i added ORDER BY to the sql query to solve that problem.
Also, noticed its not pulling in the correct data. I change the number in the echo statement, and the stuff it displays either stays the same, or nothing at all, despite the stuff in the database been different.
This might be due to the way the backend backend framework is setup...will have another go with a basic page and database to see if it works...
The error is You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table'
But i cant see any problems with it. Ive checked several times against php.net's mysql functions and that but i cant spot anything. Using the above code, this is what i have been using -
$qry = mysql_query('SELECT * FROM table')
or die ("select died: " . mysql_error());
for($i = 0; $i < 3; $i++)
$answer[$i] = mysql_fetch_array($qry);
These are the versions that i have -
Apache Version 2.2.8
PHP Version 5.2.6
MySQL Version 5.0.51b