09-20-2007, 04:28 AM
It's possible to show only category in my news?, how?. For example, I would like to show one category (for example car) in my page car.php, category trucks in my page trucks.php, etc. Thank you.
Brian Wrote:This is possible. You would need to make copies of news.php, and call them news-cars.php, news-trucks.php, etc, and simply modify the queries. If you want me to be more specific, tell me what categories you have and what the category ID of each one is.In my news I have many categories. ¿It's possible to add any code in my news.php (for example, news.php?car, news.php?truck) to show that category that I want?. Thank you.
To tell what the ID for a category is, hover over the links next to it in the categories page and note the number at the end of the URL.
isset($_GET['action']) ? $action = $_GET['action'] : $action = '';
if (!isset($urlGetCat))
{
isset($_GET['category']) ? $urlGetCat = $_GET['category'] : $urlGetCat = '';
}
$getnews = $DB->query("SELECT * FROM `unp_news` ORDER BY `date` DESC LIMIT $newslimit");
$getnews = $DB->query("SELECT * FROM `unp_news` WHERE `catid`='$urlGetCat' ORDER BY `date` DESC LIMIT $newslimit");
Brian Wrote:It is possible, though the way page-including in general works, it will only be effective with PHP includes or iframes.
Anyway, in news.php, you could find:
And add below it:PHP Code:
isset($_GET['action']) ? $action = $_GET['action'] : $action = '';
PHP Code:
if (!isset($urlGetCat))
{
isset($_GET['category']) ? $urlGetCat = $_GET['category'] : $urlGetCat = '';
}
And then in news.php
Find:
PHP Code:
$getnews = $DB->query("SELECT * FROM `unp_news` ORDER BY `date` DESC LIMIT $newslimit");
Replace with:
PHP Code:
$getnews = $DB->query("SELECT * FROM `unp_news` WHERE `catid`='$urlGetCat'[/B] ORDER BY `date` DESC LIMIT $newslimit");
Now, if you are using frames, just include news.php?category=categorynumber, replacing categorynumber for each instance. If you are using PHP includes, link to your page as normal and add ?category=categorynumber to the link.
Let me know if anything is unclear.
Database error in Utopia News Pro:
Invalid SQL Query: SELECT * FROM `unp_news` WHERE `catid`=''[/B] ORDER BY `date` DESC LIMIT 10
MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[/B] ORDER BY `date` DESC LIMIT 10' at line 1
MySQL Error Number: 1064
Date: September 27, 2007 12:27 PM
Script: /