Imam tablicu u bazi:
Code:
CREATE TABLE IF NOT EXISTS `themes` (
`id_theme` int(10) unsigned NOT NULL AUTO_INCREMENT,
`nametheme` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`theme` text COLLATE utf8_unicode_ci NOT NULL,
`sticky` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id_theme`)
)
CREATE TABLE IF NOT EXISTS `themes` (
`id_theme` int(10) unsigned NOT NULL AUTO_INCREMENT,
`nametheme` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`theme` text COLLATE utf8_unicode_ci NOT NULL,
`sticky` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id_theme`)
)
sad kad vadim podatke iz baze radim ovkao:
Code:
$query = mysqli_query($con_base, "SELECT id_theme, nametheme, sticky FROM themes ORDER BY id_theme DESC") or die('Error');
if (mysqli_num_rows($query) > 0) {
while ($row = mysqli_fetch_array($query)) {
$result_list[] = $row;
}
}
// Ispisujem
if (isset($result_list)) {
foreach ($result_list as $row) {
?>
<div><?php echo $row['nametheme']; ?></div>
<?php
}
}
$query = mysqli_query($con_base, "SELECT id_theme, nametheme, sticky FROM themes ORDER BY id_theme DESC") or die('Error');
if (mysqli_num_rows($query) > 0) {
while ($row = mysqli_fetch_array($query)) {
$result_list[] = $row;
}
}
// Ispisujem
if (isset($result_list)) {
foreach ($result_list as $row) {
?>
<div><?php echo $row['nametheme']; ?></div>
<?php
}
}
mene zanima kako mogu da izvadim iz baze i izlistam prvo redke koji imaju sticky=1 pa onda da one koji imaju sticky=0
dali se to moze uradit u sql?
hvala