Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Latest Addons
AD Gallery 46
SyntaxHighlighte... 48
Newsletters v4.03 107
Facebook Like Box 123
Newsletters v4.02 56
Metro 158
Facebook Connect 166
Shoutbox Panel 125
Redactor for PHP... 104
MI Floating Side... 107
Facebook Login/R... 151
Avatar Studio v2.03 177
Relationship Sta... 96
Sexual Orientati... 113
Fisherman 142
Popular Addons
iTheme2 5797
Arise 5785
User Control v1.23 4617
Event Calendar 4046
Photowidget panel 3884
Radio-Theme red2... 3351
Highslide Gallery 3311
CSS/JavaScript D... 3223
Facebook Connect... 2980
Dynamic Menu 2889
Slideshow Lightb... 2719
L-AMANT 2657
Enigma 2630
2Dark 2603
Black 2572
View Thread
Official Home of PHP-Fusion » General Addon and Modification Support » Ideas for Modifications and Requests
Who is here? 1 guest(s)
 Print Thread
SQL QUERY HELP
Kevin Maschke
Hi, I would like to know if it is possible to make an SQL QUERY so that the result is displayed in 2 columns and separated alphabetically...

Something like this:

http://es.wikiped...ADa:Anexos

But for a side panel, with just 2 columns...

Would it be possible?
<3 PHP-Fusion
 
http://www.km.hostei.com/php-fusion/
Ankur
Please explain it a more that which kind of structure you want...!

For Example, this is an Example code which you can Test by running in a Panel or Custom Page to see... : ( This will show 20 User Names and their ID's in Two columns arranged in Ascending order by their Name )

<?php

$result = dbquery("SELECT user_name, user_id FROM ".DB_USERS." ORDER BY user_name ASC LIMIT 20");

echo "<table cellpadding='0' cellspacing='0' width='100%' border='1'>\n<tr>";
echo "<td><b>User Name</b></td>\n";
echo "<td><b>User ID</b></td>\n</tr>\n";

while ($data = dbarray($result))
{
echo "<tr>\n";
echo "<td>".$data['user_name']."</td>\n";
echo "<td>".$data['user_id']."</td>\n";
echo "</tr>";
}

echo "</table>";

?>

ankurthakur.co.cc/images/freelancer.png
 
http://ankurthakur.in/
Kevin Maschke
Hm... I was thinking about something like my attached image, but in just 2 columns... I mean list of all articles in "article_cat" 1, ordered this way...

Merged on Jun 10 2011 at 09:03:25:
And also... Is it possible to make a custom page with a list of all articles in a article category, order them by name and add an "alphabet" to let users/viewers sort by letter?

Example:
http://www.vkmang...dia/review

something like this, but without visits.
Kevin Maschke attached the following image:
anime.png

Edited by Kevin Maschke on 10-06-2011 09:03
<3 PHP-Fusion
 
http://www.km.hostei.com/php-fusion/
Ankur
Ok ! Testing over ! The Panel is ready ! :)

openside("Articles Menu");

// Uncomment the 1st Query and Comment the 2nd Query to show all articles(not from particular category)
//$result = dbquery("SELECT article_id, article_subject FROM ".DB_ARTICLES." ORDER BY article_subject ASC LIMIT 25");

$result = dbquery("SELECT article_id, article_subject FROM ".DB_ARTICLES." where article_cat=3 ORDER BY article_subject ASC LIMIT 25");
// Remember the Limit is set to 25. You can Increase it.

echo "<table cellpadding='0' cellspacing='0' width='100%' border='0'>\n<tr>\n";

// Must start with 3, Cannot start with 0 because at 1 it will give 0.5 which is 0
$i=3;

while ($data = dbarray($result))
{
echo "<td>» <a href='".BASEDIR."articles.php?article_id=".$data['article_id']."'>".$data['article_subject']."</a></td>\n";

if ($i % 2 == 0)
{
echo "</tr>\n<tr>\n";
}
$i++;

}

echo "</tr>\n</table>";

closeside();

ankurthakur.co.cc/images/freelancer.png
 
http://ankurthakur.in/
Kevin Maschke
GREAT! WORKS PERFECTLY! Grin Thanks a lot!!!


And about the other thing... Is it possible to make a custom page with a list of all articles of an article category, order them by name and add an "alphabet" to let users/viewers sort by letter?

As here:
VKMANGA REVIEWS
something like this, but without the visits column...

EDITED: URL WAS WRONG
<3 PHP-Fusion
 
http://www.km.hostei.com/php-fusion/
Ankur
Kevin Maschke wrote:

GREAT! WORKS PERFECTLY! :D Thanks a lot!!!


And about the other thing... Is it possible to make a custom page with a list of all articles of an article category, order them by name and add an "alphabet" to let users/viewers sort by letter?

As here:
VKMANGA REVIEWS
something like this, but without the visits column...

EDITED: URL WAS WRONG


Here is the Code ! ;-)

Remember:- For use in Custom Page only


<?php

$sortby = ($_GET['sortby'] == "" ? "" : "WHERE article_subject LIKE '".stripinput($_GET['sortby'])."%'");

$result = dbquery("SELECT article_id, article_subject FROM ".DB_ARTICLES." ".$sortby." ORDER BY article_subject ASC LIMIT 25");

while ($data = dbarray($result))
{
echo "» <a href='".BASEDIR."articles.php?article_id=".$data['article_id']."'>".$data['article_subject']."</a><br />\n";
}

$search = array(
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R",
"S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"
);

echo "<div class='pagenav' align='center'>";
for ($i = 0; $i < 36 != ""; $i++) {

echo "<a href='".FUSION_SELF."?page_id=".stripinput($_GET['page_id'])."&amp;sortby=".$search[$i]."'>".$search[$i]."</a>";
}
echo "</div>";
echo "<a href='".FUSION_SELF."?page_id=".stripinput($_GET['page_id'])."'>Show All</a>";

?>

ankurthakur.co.cc/images/freelancer.png
 
http://ankurthakur.in/
Kevin Maschke
Hm... The code works, but the result isn't displayed correctly

See it here http://www.km.hos...?page_id=4

The links are all one after the other one...
<3 PHP-Fusion
 
http://www.km.hostei.com/php-fusion/
Ankur
Kevin Maschke wrote:

Hm... The code works, but the result isn't displayed correctly

See it here http://www.km.hos...?page_id=4

The links are all one after the other one...


Can you see this line in Code :
echo "» <a href='".BASEDIR."articles.php?article_id=".$data['article_id']."'>".$data['article_subject']."</a><br />\n";

The <br /> is added so that it comes after new line and in your website source code, its not showing the <br /> code...

So I think that you have missed that ! Because it worked nicely for me in simple Gillete theme !
ankurthakur.co.cc/images/freelancer.png
 
http://ankurthakur.in/
Kevin Maschke
Oh! I've corrected that in my custom page. The problem was that I copy&pasted your code from your previous post, where the <br /> is not specified Pfft

And just a quick question... Would it also be possible to give the query result a similar design to the one used on the page (VKMANGA) I've shown before?
<3 PHP-Fusion
 
http://www.km.hostei.com/php-fusion/
Ankur
Updated : (everything is simple HTML ! Try editing yourself ;) )
<?php

$sortby = ($_GET['sortby'] == "" ? "" : "WHERE article_subject LIKE '".stripinput($_GET['sortby'])."%'");

$result = dbquery("SELECT article_id, article_subject FROM ".DB_ARTICLES." ".$sortby." ORDER BY article_subject ASC LIMIT 25");

$count = 1;

while ($data = dbarray($result))
{
echo $count.". <a href='".BASEDIR."articles.php?article_id=".$data['article_id']."'>".$data['article_subject']."</a><br />\n";
$count++;
}

$search = array(
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R",
"S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"
);

$br = 0;

echo "<div class='pagenav' align='center'>";
for ($i = 0; $i < 36 != ""; $i++) {
echo "<a href='".FUSION_SELF."?page_id=".stripinput($_GET['page_id'])."&amp;sortby=".$search[$i]."'>".$search[$i]."</a>";
if ($br == 17) { echo "<br /><br />"; }
$br++;
}
echo "</div>";
echo "<a href='".FUSION_SELF."?page_id=".stripinput($_GET['page_id'])."'>Show All</a>";

?>

ankurthakur.co.cc/images/freelancer.png
 
http://ankurthakur.in/
Kevin Maschke
But with design I meant the "table" design, with the hover effect...

I must be CSS, they use UL I think...
<3 PHP-Fusion
 
http://www.km.hostei.com/php-fusion/
Jump to Forum:
Similar Threads
Thread Forum Replies Last Post
shoutbox query problem System Administration 7 14-04-2012 06:36
Usernames query User Administration 8 13-12-2011 17:10
(request/query) RSS to NEWS Ideas for Modifications and Requests 2 04-07-2011 12:51
Keddy's Sub Forums 7.01.04 Update Query? Ideas for Modifications and Requests 1 19-02-2011 12:33
help / query General Discussion 1 21-01-2011 08:28
Official Home of PHP-Fusion uses cookies. Some may already have been set. Read more about our Cookies here.
Please click the button I Consent Cookies to hide this bar and accept our cookies. If you continue to use the site with no action taken, we'll assume that you consent our cookies anyway.
Cookiebar Panel byVenue