Hi friends …
I write above code to display top 5 rows from the database but it not works properly. It displays first row 5 times which is undesireable.
Anyone plz help???
Thx in advance…
But Now if I update a new row in database. It not update on output.
I mean to say as admin update this table, these updation must be shown to user…
Help plz…
Sir,
First I want to tell you that above code leaves top row and starts from the second row. Ex.–It should print 1,2,3,4 but it prints 2,3,4.
Second problem is when admin update a new row it becomes bottom row in phpMyadmin. So, this updated row never displays.
mysql_fetch_array() by default returns both an indexed and associative array.
you are using an index $i in your for loop declaration but then referring to the row elements with associative keys. The 2 need to be consistent with each other.
imho the easiest option is to use mysql_fetch_assoc() and then refer to $row using associative and not indexed keys.
I don’t have an issue if you disagree with my opnion
unless this is an attempt on your part to hijack this thread we can just agree to disagree or if you need to discuss further, start a new thread on the topic
Bottom changes along with the context, depending on whether it is the context of a numerically ordered list, or a table with new entries being added to it.
Perhaps the two of you were meaning different types of bottom?
order based on auto_incrementing values is no different than order based on any other column
the rows are inserted wherever there is space, and you will see them “in order” only if you use an ORDER BY clause in the SELECT
i ~think~ i know where this idea of “bottom” comes from – if you’re using some front-end like phpmyadmin to browse your table data, then the rows usually appear with the smaller auto_increment numbers at the top of the listing and larger numbers at the bottom
however, given my example with salary, there is a more prevalent interpretation for top and bottom, isn’t there
if you were to list out salaries in ascending sequence, like this –
2
4
5
7
8
9
11
23
37
then, yes, the larger numbers are at the “bottom” of the list
however, if you were to ask someone which are the top 5 salaries, what do you get?
i think it is important to make this clarification, because “top” and “bottom” when used in the context of ORDER BY (rather than listings) are very common concepts in the database world, and we shouldn’t be introducing confusion based on some other idea