Display 5 recent items from database - php/mysql -


I am trying to display the top 5 latest things in the database. I'm showing it on my items. Php is on page, but I want to do 5 on dashboard.php page

I am just learning php / mysql and only about 4 days and I think that I am learning very fast, but I can not find it while searching.

Here is my code to get the full list of items.

  & lt ;? Php $ SQL_GetProducts = "SELECT * FROM` new_equip` command` ID` by DESC; "; $ R_GetProducts = mysql_query ($ SQL_GetProducts, $ link); While ($ row = mysql_fetch_assoc ($ R_GetProducts)) {$ eid = $ line ['id']; $ Name = $ line ['name']; $ Model = $ line ['model']; $ Desc = $ row ['desc']; $ Visual = $ line ['image']; $ Date = $ line ['date']; If (! File_exists ("../ UIMages /" $ imagename) || strlen ($ imagename) & lt; 5) {$ imagename = "NoImage.jpg"; }? & Gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Div class = "thumbnail" & gt; & Lt; Div class = "thumbnail-view" & gt; & Lt; A href = "../iimages/" & lt; php echo $ imagename ;? & gt; " Class = "thumbnail-view-hover ui-lightbox" & gt; & Lt; / A & gt; & Lt; Img src = "../iimages/"> php echo $ $ $ imagename ;? gt; " Width = "125" alt = "gallery image" /> & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - /.thumbnail - & gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? php echo $ name; ? & Gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; P & gt; & Lt ;? Php echo word vap ($ desc, 90, "
& Lt ;? php echo $ date; ? & Gt; & Lt; / TD & gt; & Lt; Td class = "text-center" & gt; & Lt; Button class = "BTN BTN-Xs BTN-Primary" & gt; & Lt; I class = "fa-pencil" & gt; & Lt; / I & gt; & Lt; / Button & gt; & Amp; Nbsp; & Lt; Button class = "btn btn-xs btn-secondary" & gt; & Lt; I class = "fa-fa-times" & gt; & Lt; / I & gt; & Lt; / Button & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php}? & Gt; & Lt; / Tbody & gt;

From what I have read and seen, I should have something like this

  $ SQL_GetProducts = "SELECT * FROM 'new_equip' 'ID` DESC by ORDER LIMIT 0, 5 ";   

Then I returned a $ query-> Read something about bringing;

Any help would be greatly appreciated.

Welcome - I recommend you to $ query- & gt; Fetch (); Do not use
, your code is correct, but the second is to write:

  SELECT * FROM `new_equip` order ID 5 from the limit of DESC   

And do not forget: You should delete "" after DESC here:

  SELECT * from 'new_equip` order `ID` by DESC;    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -