Small PHP/SQL problem
Posted: 2012-11-22 04:44pm
I have a bit of a problem with my wife's website. About two years ago it was coded based on wordpress by a webdeveloper. Right now, Im picking up the admin's mantle, retro-ing the code and trying to figure it out myself so I can do all the necessary modifications. I've ran into a bit of a problem which is way beyond my expertise (html and css coding is mostly my thing, only started learning php).
Here is the problem.
The website in question is http://www.olakalinowska.pl and it is built on wordpress, with the postloop and branding modified to produce the current result. There is a script on the main page which takes all the galleries from a specified album ID and produces a collapsible menu - if you hover on one of the title bars, it will produce a sub-menu with links to specific galleries.
The thing is, the ordering of the galleries seems random. At first I thought it goes by gallery ID, but it does not, if you look at it. I don't think it utilizes any sort of array result ordering.
What I would like it to do is to follow the ordering on the wordpress ngg gallery in the CMS. Any help would be greatly appreciated.
Here is the problem.
The website in question is http://www.olakalinowska.pl and it is built on wordpress, with the postloop and branding modified to produce the current result. There is a script on the main page which takes all the galleries from a specified album ID and produces a collapsible menu - if you hover on one of the title bars, it will produce a sub-menu with links to specific galleries.
The thing is, the ordering of the galleries seems random. At first I thought it goes by gallery ID, but it does not, if you look at it. I don't think it utilizes any sort of array result ordering.
What I would like it to do is to follow the ordering on the wordpress ngg gallery in the CMS. Any help would be greatly appreciated.
This was suggested to me on a php forums, unfortunately it does not work.<div class="float-me">
<!-- start slub -->
<div id="main-page-slub">
<a class="div-href" href="/slub/">śluby i chrzty</a>
<div class="menu">
<ul>
<li>
<a href="/slub/">śluby i chrzty</a>
<ul id="album-list-slub">
<?php
$aid = 4;
$query = 'SELECT * FROM wp_ngg_album WHERE id = '.$aid.' LIMIT 1'; //album ludzie
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$sort = $row['sortorder'];
}
$gals_ids = implode(',', (unserialize($sort)));
$query = 'SELECT * FROM wp_ngg_gallery WHERE gid IN ('.$gals_ids.')'; //wszystkie galerie z albumu ludzie
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo ('<li><a href="/slub/?album='.$aid.'&gallery='.$row['gid'].'">'.$row['title'].'</a></li>');
}
?>
</ul>
</li>
</ul>
</div>
</div>
<!-- stop slub -->
<div class="shadow-right"></div>
<div style="clear: both;"></div>
<div class="shadow-bottom"></div>
<div style="clear: both;"></div>
</div>
I've been able to go as far as below, but it only sorts ascending by gallery id and I would have to rework all the gallery id's in the database (I actually lost a record today trying to do this)$query = 'SELECT * FROM wp_ngg_gallery WHERE gid IN ('.$gals_ids.') ORDER BY '.$sort.'';
Hmm, help?$query = 'SELECT * FROM wp_ngg_gallery WHERE gid IN ('.$gals_ids.') ORDER BY gid';