PDA

View Full Version : View Category by description in database


Potter_gold
04-24-2007, 08:16 PM
Hi

I am struglling with a my first bit of mySql, that i am attempting to do on my own. I usually get some help from the web team at work.

Objective - I am trying to build pages on specific genre "example is Bart Simpson - http://www.freepspwallpapers.co.uk/the_simpsons/bart_simpson.php

What i want to do is only show my Bart Simpson Wallpapers on this page. I have started some of my coding, but wondered if you can help?

Peter

<?php
// Connect to the database.
require('dbconnect.php');

// Select what we want.
$sql = 'SELECT * TABLE 'wallpapers' WHERE `description` = 'wallpapername';

// Use the paged results class to easily create paged results.
$results_per_page = 12;
$pages = new MySQLPagedResultSet($sql, $results_per_page, $database_connection);

$content = $pages->getPageNav("cid=".$_GET['cid']).'<div style="clear: both;">&nbsp;</div>';
// Show the matching images.

$i = '1';
while ($row = $pages->fetchArray()) {

$content .= '<div style="float: left; padding: 0.2em; text-align: center;">'.$row['wallpapername'].'<br/><a href="javascript:popUp(\'/popup.php?imgid='.$row[wallpaperid].'\');"><img src="'.$row['wallpaperimagesmall'].'" alt="Free '.$row['wallpapername'].' PSP Wallpapers" title="Free '.$row['wallpapername'].' PSP Wallpapers" border="0"></a></div>';

if ($i == '4' || $i == '8' || $i == '12') {
$content .= '<div style="clear: both;">&nbsp;</div>';
}

$i++;
}

$content .= '<div style="clear: both;">'.$pages->getPageNav("cid=".$_GET['cid']).'</div>';
$template = str_replace('{CONTENT}',$content,$template);
echo $template;
?>

Potter_gold
04-25-2007, 08:30 PM
Hi

I think i have nearly sorted this but need help on one last little thing.

$sql = "SELECT * FROM wallpapers where wallpapername = 'Bart Simpson' and wallpaperimagesmall like '%small%' order by wallpaperid desc";

On this query i can make the bart simpson images appear, but need it only to show the small ones. The small ones appear in my database under the field "wallpaperimagessmall"

Can you fnish me off?

Peter

guelphdad
04-26-2007, 05:56 PM
Don't use SELECT * use


SELECT
name,
thefields,
you,
actually,
need
FROM
yourtablename


SELECT * is a bad habit to get into.