Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Reply
Old 10-16-2009, 09:55 AM   #1 (permalink)
 
Newb Techie

Join Date: Oct 2009

Posts: 1

ste2me is on a distinguished road

Default nooobie needs help

I have been working on a website using PHP and MySQL and although I have knowledge in both these fields, my knowledge is quite limited and I have come across a problem I need help with.
I am creating a videos page and I would like the videos to be displayed (using PHP) in a format similar to what is found here:


hiphopdx.com/index/videos?nav

I would like the videos to display the date headline (the date being when the videos were posted) then the thumbnails of the videos to be displayed in 4 columns. I already have the videos page set up with the pagination, mysql connection and video details. I am currently displaying the videos in a single column as I dont know how to display PHP results in multiple columns.

So basically I am looking for the videos page to display the results like this (example):

Thursday, August 27, 2009
Video 1 | Video 2 | Video 3 | Video 4
Video 5 | Video 6 | Video 7 | Video 8

many thanks
ste2me is offline   Reply With Quote
Old 10-16-2009, 10:32 AM   #2 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default Re: nooobie needs help

i would create an html table to produce the requested output.

PHP Tables (table, tables) - PHP Classes

create a table with 4 columns and necessary amount of rows.
office politics is offline   Reply With Quote
Old 11-11-2009, 04:43 AM   #3 (permalink)
 
Newb Techie

Join Date: Nov 2009

Posts: 1

nathan_s is on a distinguished road

Default Re: nooobie needs help

An hml table is the way to go, if you don't want to use any additional classes you can always echo the code for the table to be created, however the source code would be really messy
nathan_s is offline   Reply With Quote
Old 11-13-2009, 04:52 PM   #4 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,683

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: nooobie needs help

Quote:
Originally Posted by office politics View Post
i would create an html table to produce the requested output.

PHP Tables (table, tables) - PHP Classes

create a table with 4 columns and necessary amount of rows.
That's just unnecessary. You don't need a whole class to do this, it's quite simple actually.

Code:
<?php

$sql = mysql_query ("SELECT * FROM videos");

$cols = 4; // set number of columns
$i = 0;    // counter

echo '<table border="0" cellspacing="1" cellpadding="3">';

while ($row = mysql_fetch_array ($sql)) {
	// start new row
	if ($i % $cols == 0) {
		echo '<tr>';
	}

	// run through the columns
	echo '<td>'.$row['video_name'].'</td>';
	
	// we have reached the end of the specified number of columns, so close it
	if ($i % $cols == $cols) {
		echo '</tr>';
	}

	$i++;
}

// in case there are not the exact amount of columns as we specified, add some blank ones to clean up
if ($i % $cols != 0) {
	while ($i++ % $cols != 0) {
		echo '<td>&nbsp;</td>';
	}
	echo '</tr>';
}

?>

__________________

Need website help? PM me!

Last edited by CrazeD; 11-14-2009 at 09:13 AM.
CrazeD is offline   Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On