hi all
i want to know is there any code which will print a data into the bottom of a exist table?
let say now i have a table like below

NAME TIME BID
alan 9.40am RM100

after i execute the code....the new table will add the new thing at the bottom.
NAME TIME BID
alan 9.40am RM100
justin 10.00am RM110

without overwrite all the old data...
thanks for any info and help

Recommended Answers

All 9 Replies

to do this you need something like date and time or Auto increment field.. by using them you can create query to get data in descending order with limit 0,1

you mean i create a field in database also??then i called it out in my html?
do you have any link of tutorial for it??

create one column id set it as "Auto Increament" in database
so when new entry add to database id automatically incremented
id NAME TIME BID
001 alan 9.40am RM100
002 alan 9.50am RM200
003 alan 10.20am RM400
004 alan 11.40am RM100

then use query
SELECT * FROM TABLENAME ORDER BY id DESC, LIMIT 0,1
Your query result largest id which is last entry of database

004 alan 11.40am RM100

it is basic trick..

Kokfui,

The question appears to be about an HTML table but the answer is about a database table - very different animals.

Which is it?

Airshow

actually i want to create a fix html table where data can be insert into that table without erase the old data...mean it will insert the data i entered to bottom of the exist table...if can, i want the php code can generate a html table into my directory...not generate a database table...im not really know how to explain..but i think i get other way to solve it already..thx anw

Kokfui,

Here's a demo, with hard-coded data for the new row.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Airshow :: Untitled</title>

<script>
function addTablaRow(name, time, bid) {
	var tbody, tr, td;
	tbody = document.getElementById('myTableBody');
	tr = document.createElement('tr'); tbody.appendChild(tr);
	td = document.createElement('td'); tr.appendChild(td); td.innerHTML = name;
	td = document.createElement('td'); tr.appendChild(td); td.innerHTML = time;
	td = document.createElement('td'); tr.appendChild(td); td.innerHTML = bid;
}
</script>
</head>

<body>

<table border>
<thead><th>NAME</th><th>TIME</th><th>BID</th></thead>
<tbody id="myTableBody">
<tr><td>alan</td><td>9.40am</td><td>RM100</td></tr>
</tbody>
</table>

<div style="margin-top:10px;">
<button onclick="addTablaRow('justin','10.00am','RM110')">Add Row (hard-coded)</button>
</div>

</body>
</html>

You will need to get your data from somewhere, rather than it being hard-coded but the principle is the same.

Airshow

Airshow

Kokfui not mention in his first post with which kind of table he was working .

so keep your language clean .. :P

No critisism Sanket_s. I felt the need to clarify before the topic developed any further.

Airshow

thank you all for helps...trying with airshow guide...thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.