wrathican Posted September 9, 2007 Share Posted September 9, 2007 hey im trying to show a list of projects that are stored in my db but it doesn't seem to be working, i know i have more than one but it only shows the one... :S heres the code: (the 'views' is the section that isnt working) here it is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/portfolio.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Ashley Broadley :: Online Portfolio</title> <!-- InstanceEndEditable --> <link rel="stylesheet" type="text/css" href="portfolio.css" /> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> </head> <body> <table width="600" border="0" cellpadding="0" cellspacing="0" class="body"> <!--DWLayoutTable--> <tr> <td width="600" height="101" valign="top"><img src="images/header.gif" width="600" height="120" /></td> </tr> <tr> <td height="13" valign="top" class="head"><span class="navi"><a href="index.php">Home</a> | <a href="contact.php">Contact</a> | <a href="portfolio.php">Portfolio </a>| <a href="about.php">About Me</a></span></td> </tr> <tr> <td height="20" valign="top"><img src="images/box_01.gif" width="600" height="20" /></td> </tr> <tr> <td height="13" valign="top"><!-- InstanceBeginEditable name="EditRegion1" --> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="cont"> <!--DWLayoutTable--> <tr> <td width="600" height="15" valign="top" class="cont"><?php include './include/misc.inc'; include './include/opendb.inc'; switch($_GET['func']) { case "views": $cat = $_GET['cat']; $query = "SELECT * FROM port_project WHERE proj_sect_id='" . $cat . "'"; //echo $query; $result = mysql_query($query); while ($row = mysql_fetch_array($result,MYSQL_NUM)) { //collect variables from DB $id = $row[0]; $title = $row[2]; $client = $row[3]; $body = $row[4]; $date = $row[5]; //trim the string $max_length = 200; $body = substr($body, 0, $max_length-3).'...'; //change the date format $newdate = date('l, jS F Y', strtotime($date)); //gets the thumnail from the db $query = "SELECT img_thumb, img_alt FROM port_image WHERE img_proj_id='" . $id . "' AND img_title='Y'"; $result = mysql_query($query); $pic = mysql_fetch_array($result,MYSQL_NUM); //echo the output $querycat = "select sect_title from port_section where sect_id='" . $cat . "'"; $resultcat = mysql_query($querycat); $cattitle = mysql_fetch_array($resultcat,MYSQL_NUM); $catt = $cattitle[0]; ?><span class="title"><?php echo $catt; ?></span><br /><br /> <a href="?func=viewp&proj=<?php echo $id; ?>"><img src="<?php echo $pic[0]; ?>" border="0" align="left" alt="<?php echo $pic[1]; ?>"/></a><br /><a href="?func=viewp&proj=<?php echo $id; ?>"><span class="newst"><?php echo $title; ?></span></a><br /><br /> <span class="break">Client: <?php echo $client; ?></span> <br /><br /> <?php echo $body; ?> <br /> <br /> <span class="break">Added on <?php echo $newdate . "</span>"; } break; case "viewp": $id = $_GET['proj']; $query = "SELECT * FROM port_project WHERE proj_id='" . $id . "'"; $result = mysql_query($query); while ($row = mysql_fetch_array($result,MYSQL_NUM)) { //collect variables from DB $title = $row[2]; $client = $row[3]; $body = $row[4]; $date = $row[5]; $url = $row[6]; $newdate = date('l, jS F Y', strtotime($date)); } ?><br /> <span class="newst"><?php echo $title; ?></span><br /><br /> <span class="break">Client: <?php echo $client; ?><br /> <a href="<?php echo $url; ?>" target="_blank">Link</a><br /></span> <br /> <?php //get images $query = "SELECT * FROM port_image WHERE img_proj_id='" . $id . "'" ; $result = mysql_query($query); while($pic = mysql_fetch_array($result,MYSQL_NUM)) { $thumb = $pic[2]; $fullpic = $pic[3]; $alt = $pic[4]; ?> <a href="<?php echo $fullpic; ?>" target="_blank"><img src="<?php echo $thumb; ?>" border="0" alt="<?php echo $alt; ?>"/></a><img src="images/imgspacer.gif" /> <?php } ?> <br /> <?php echo $body; ?> <br /> <span class="break">Added on <?php echo $newdate . "</span>"; break; default: ?><span class="title">Portfolio</span><br />Here is a list of links to each section of my portfolio: <ul> <?php $query = "SELECT * FROM port_section"; $result = mysql_query($query); while($row = mysql_fetch_array($result,MYSQL_NUM)) { $sectid = $row[0]; $title = $row[2]; ?> <li><a href="?func=views&cat=<?php echo $sectid; ?>"><?php echo $title; ?></a></li> <?php } } ?> </ul> <?php //here will be the latest 2 projects ?></td> </tr> </table> <!-- InstanceEndEditable --></td> </tr> <tr> <td height="20" valign="top"><img src="images/box_04.gif" width="600" height="20" /></td> </tr> <tr> <td height="13" valign="top" class="foot">Copyright 2007 © Ashley Brodley </td> </tr> </table> </body> <!-- InstanceEnd --></html> Quote Link to comment https://forums.phpfreaks.com/topic/68625-showing-things-from-db/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.