How can I make an entry always up MYSQL PHP

1

I come to ask for your help, I am programming a forum in php and mysql without a framework, and I need to put in the list of entries the rules of the forum so that it remains fixed (ALWAYS UP) and so when users fence entering new entries appear below, as in wordpress, I hope you make me understand. I can not imagine how to do it, I ask for your guidance. Thank you all

(THE RED LINE IS ONLY TO POINT OUT THE ROW THAT I WANT TO BE ABOVE)

    
asked by Arellano Cornejo Daniel 21.01.2018 в 03:04
source

1 answer

1
  

I need to put the rules of the forum in the list of entries   that is fixed (ALWAYS UP)

You could have a field in the table where you handle the records associated with those categories. Let's call this field "priority" . To be able to perform the ORDER BY of MySql and when you bring the results I put you first the record associated with "Welcome ::: Forum Rules!" (will have priority with value "1" acting as if it were a kind of status while everything else will have value "0")

  

and so when users fence entering new entries appear   below

I imagine you have a field of "date" that registers the moment the user created the entry, otherwise it would be good to have it because it is the one that we will use so that once fixed "Welcome ::: Forum Rules!" the other entries are listed according to this field from to the most recent (again we use ORDER BY but based on the "date" field)

Here is the sample query you should use to achieve your goal:

$consulta= "SELECT * FROM foro ORDER BY prioridad, fecha DESC"; 
    
answered by 21.01.2018 / 14:54
source