I am new to mysql and would like to know if this is possible:

I want to for example:

Track how many columns within my table have been created
& Track the last one created

For like to embed in a page in order to view it daily (updates automatically of course).

any idea??

Hi there,

Just to confirm, do you definitely mean columns? Or do you mean each entry in a database table i.e. a row (columns = vertical, rows = horizontal).

each entry in a database table

I don’t know how you’re connecting to your mysql database, but ive included the basics as if you had the defaults from installing XAMPP.

$db = mysql_connect("localhost","root");
$entries = array();
$sql = "SELECT
			`id` DESC
		LIMIT 10";
$query = mysql_query($sql);
while(($row = mysql_fetch_assoc($query)) !== false)
	$entries[] = $row['field'];
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
			Last 10 entries (most recent at the top):
		foreach($entries as $entry)
			echo "<li>".$entry."</li>";

Of course you will need to modify this depending on what limit you want (if any), your database connection, table name, field name etc but let me know if this helps you at all.

yes !! thnx!

I used include “connection.php”; to connect … its easier

No problem - glad to have helped. Happy coding and a prosperous new year :smiley:

what if I only want to show 1 instead of 10?

Where it says “LIMIT 10” at the end of the query, simply change the 10 to a 1.

yes ty I found out right away… thnx for everything and happy new year

Sponsor our Newsletter | Privacy Policy | Terms of Service