Hi all, I have a doubt on how retrieve data form MySQL database in Last-in-First Out manner. I mean to say Recent entry should be on top of the page. waiting for reply................. Thank you in advance
It is giving this warning "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in" This is my code $query = "SELECT * FROM datatable ORDER BY Sl.no DESC"; Sl.no is autoincremented for every entry.
My table has a fields Sl.no, subject, title, url, email, date, text $query = "SELECT * FROM datatable ORDER BY 'Sl.no' DESC "; $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { if($row != NULL) { echo "<b>The subject is" .$row[1]. "</b><br>"; } echo "<div class='class2'>"; echo "<a href='$row[3]' target='_blank'>$row[2]</a></div>"; echo "<h3>$row[4]$row[5] submitted on $row[6]</h3>"; echo "<p>$row[7]</p>"; Is there any thing wrong?? Either i use DESC or ASC i am getting the same results .
Try this: SELECT * FROM datatable ORDER BY no DESC Is SI referring to a different table? If so, you need to do a join.
It is giving this warning "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in" Sl.no is a field in my table.
mysql_query($query); Code (markup): returns not valid mysql resource, but FALSE. Catch the error and throw error msg! Like: if (!$result) die (mysql_error());
One solution could be donot use '.' in sl.no Other can be change the field name for testing to SRNO other can be take another field instead of sl.no and check if it works like change it to subject Regards Alex
It is returning valid resource. ASC or DESC nothing is working. Just returns Hower the data is entered into data base.
Replace: $query = "SELECT * FROM datatable ORDER BY 'Sl.no' DESC "; with: $query = "SELECT * FROM datatable ORDER BY `Sl.no` DESC";
it gives "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in" I got to fix this immediately, please help me.
Okay, so i want to do this exact same thing, but i only want to show the last three or so entries into the table, not all of them, any way i can do this? Thanks for your help in advance