Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-10-2007, 10:05 AM
Vizionz Vizionz is offline
 
Join Date: Jul 2003
Location: Chicago
Posts: 524
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default really need some help

i been trying to learn to code and took on a project but nevermind all that i am stumped so i will show you the code. i need to be able to grab song listings from a database table and show them in a neat table.

if i go here info.php?artist=Artistname
with the below code it will show all the albums in the database and info to go with it but what ever i have tried i cant get it to show a table with all the songs in the database to go with the album...
Code:
<?
connectdbase();

$artist=str_replace("|","&",$artist);
$artist=str_replace("***","\'",$artist);
$sql="SELECT ID,title,artist,albumyear,genre,album, picture from songlist WHERE artist='$artist' GROUP BY album ORDER BY album";
$result=mysql_query($sql);
while($data=mysql_fetch_object($result))
		
if($data->album!=''){
echo "<table class=alt2 border=0 width=100%><tr><td>";
echo "<table border=0 width=100% height=96><tr><td class=thead height=21><p align=left><font color=#c0c0c0>".$data->album." | Fan Rating: 9.4  | Rate this album</font></a></p></td></tr>";				
echo "<tr><td><table border=0 width=100%><tr><td><center><img src=pictures/".$data->picture."' border='1'width='130'height='130'></center></td><td width=30%><b>Artist</b>: ".$data->artist."</a><br><b>Album</b>: ".$data->album."<br><b>Release Date</b>: ".$data->albumyear."<br><b>Genre</b>: ".$data->genre."</td>";
echo "<td width=50%><p align=left>";
 <------ right here i want to display table---->
with the song listings for this current album
echo "</td>";
echo "</tr>";
echo "</td></tr></table>";											
echo "</td></tr></table>";
$artist=mysql_escape_string($data->artist);
$album=mysql_escape_string($data->album);

$sql2="SELECT title from songlist WHERE artist='$artist' AND album='$album'";
$result2=mysql_query($sql2);
$tracks=0;
while($data2=mysql_fetch_object($result2))
	{
	$tracks++;
	}

	if($tracks>0){
		echo "$tracks</td></tr>";
		} else {
		echo "none";
	}
echo "</td></tr>";
$count++;
}
?>

in the above code is what i have so far. and you can see a arrow and where i would like to throw in a table that grabs the songs for the album associated..
if i type ".$data->title." it will show the first track but no others. thats where i get stuck

the code below is standalone which will grab the songs for that artists if i call the page

info.php?artist=Artistname&album=albumname


Code:
<table>
		<tr align=center bgcolor="<? echo $tbl_hdr; ?>">
		<td>
		<font size=1 color="<? echo $text; ?>" face=tahoma>
		Num
		</td>
		<td>
		<font face=tahoma size=1 color="<? echo $text; ?>">
		TRACK NAME
		</td>

		<tr>
		<td>
		<font face=tahoma size=1 color="<? echo $highlight; ?>">
			<?
			$count=0;
			$artist=$data->artist;
			connectdbase();
			$query2 = "select ID,title,trackno from songlist WHERE album='$album' and artist='$artist' ORDER BY trackno";
			$result2 = mysql_query($query2);
			while($data2=mysql_fetch_object($result2))
			{
			$count++;
			if(($count % 2)==0){
				$bgcolor=$dark;
			} else {
				$bgcolor=$light;
			}
			echo "<tr bgcolor=$bgcolor><td><font size=2 face=tahoma color='$highlight'>";
			if($data2->trackno!='0'){
			echo $data2->trackno;
			} else {
			echo $count;
			}
			echo "</td/><td><font face=tahoma size=2 color='$text'>";
			echo $data2->title;
			echo "</td></tr>";
			}
			?>
		</td>
		</tr>
	</table>
by itself and it will show the songs in a nice little table. but figure one allows me to grab all the artists albums in one spot. and now i just need to throw the songs for the albums in there.
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 11:23 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05635 seconds
  • Memory Usage 2,206KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete