Z
Z
ZaurK2014-11-01 22:47:48
Programming
ZaurK, 2014-11-01 22:47:48

How to fix some news in the top in mySql when selecting news from the database?

Hello! Is it possible to fix certain news in the top with one query when selecting news from the mySql database so that it is always at the top? How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
neolink, 2014-11-01
@neolink

for example, if it should be an entry with id = 3:

SELECT * FROM news ORDER BY IF(id = 3, 1, 0) DESC, id DESC

G
Gevoskiy, 2017-01-04
@redd_i

Via CSS:
Add to image width:500px
The browser will choose a proportional height.
Through PHP:

$size=GetImageSize("photo.jpg");
$src=ImageCreateFromJPEG("photo.jpg");
$iw=$size[0];
$ih=$size[1];
$koe=$iw/150; //150 - ширина.
$new_h=ceil($ih/$koe);
$dst=ImageCreateTrueColor(150, $new_h);
ImageCopyResampled($dst, $src, 0, 0, 0, 0, 150, $new_h, $iw, $ih);
ImageJPEG($dst, "small_photo.jpg", 100);
imagedestroy($src);

Source.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question