954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Quick database question

Hi, im currently building a photography portfolio website for ym dissertation and i have a quick question.

The site has several categories of photos, would it be easier storing all in photos in one table and adding a album and field or storing each separate category,of photos, into its own table? I have a script which gets the photos from the database which is below, if its easier storing all the photos in one table how would i go about modifying this script to select the photos with a specific category. I hope that makes sense. thanks

<?php

require "common.php";

$q = "SELECT id, title, source FROM sports";

$result = $mysqli->query($q) or die(mysql_error($mysqli));  
   
 if ($result) {  

      
while ($row = $result->fetch_object()) {  
		
		$title = $row->title;
		$source = $row->source;
		$id = $row->id;
		
		echo "<a class='gallery' rel='usa' id='$id' alt='$title' href='img/sports/$source'>  <img src='img/sports_tn/$source'  />   </a> \n";
		}		
}
?>
1baxter1
Newbie Poster
8 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

In my opinion, as long as you don't have more than 500,000 photos to list, you should be able to store them all in the one table without the slightest cpu problem providing the script is written correctly. But if you plan to have more than five hundred thousand (500,000) photos then you will probably want seperate tables for each category to save cpu.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You