Select Previous and Next Entry based on ID in MySQL

Here is an easy way to select the previous and next entry based on a given ID in MySQL, good for paginations in PHP.

To get the previous entry, query is “SELECT * FROM table_name WHERE id $current_id ORDER BY id ASC LIMIT 1”

You might think it’s easier to use (id – 1) or (id + 1) but it might return errors when id’s are deleted and the count is broken.


Opening Jetdirect port in Linux

Here’s a way to open the jetdirect port on linux, by adding a service wrapper under /etc/xinetd.d/ folder with the name jetdirect. Here is the content:

service jetdirect
socket_type = stream
protocol = tcp
wait = no
user = lp
server = /usr/bin/lp
server_args = -d printer1 -o raw
groups = yes
disable = no

Restart the xinetd service and run nmap to see if port 9100 has been opened.