dropfaith Posted November 24, 2009 Share Posted November 24, 2009 i have two sections of code that both work great but when combined fail horribly the issue is in this section here if ($list['Type'] != $previousType) { echo "</ul><h3>". $list['Type'] . "<ul>"; $previousType = $list['Type']; } echo "<li>"; if(empty($list['Link'])){ echo "". $list['Name'] . ""; } else { echo "<a href=\"". $list['Link'] . "\">". $list['Name'] . "</a>"; } Full code below what im trying to get done is list a bunch of rsults based on the Type first section of code above does that fine' the second secton just makes sure empty cells are not displayed ( as the some are inks some are not. that works too but when combined like the full code below it does the second have but will display all the types above each post instead of grouping them up and ideas? <?php include("admin/db_connect.inc.php"); // open database connection $connection = mysql_connect(HOST, DBUSER, PASS) or die('Could not connect !<br />Please contact the site\'s administrator.'); $db = mysql_select_db(DB) or die('Could not connect to database !<br />Please contact the site\'s administrator.'); // get the info from the db $sql = "SELECT * FROM live"; $result = mysql_query($sql, $connection) or trigger_error("SQL", E_USER_ERROR); // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) { // echo data $previousType = ''; if ($list['Type'] != $previousType) { echo "</ul><h3>". $list['Type'] . "<ul>"; $previousType = $list['Type']; } echo "<li>"; if(empty($list['Link'])){ echo "". $list['Name'] . ""; } else { echo "<a href=\"". $list['Link'] . "\">". $list['Name'] . "</a>"; } if(empty($list['Venue'])){ echo ""; } else { echo "(". $list['Venue'] . ") "; } if(empty($list['Year'])){ echo ""; } else { echo "Year:". $list['Year'] . " "; } echo "</li> "; } // end while echo "</ul>"; ?> Quote Link to comment Share on other sites More sharing options...
dropfaith Posted November 24, 2009 Author Share Posted November 24, 2009 bump and a bit of clarification im trying to get it to display like http://dropfaith.freei.me/links.php but i need the code to filter out certain stuff like links if there isnt one so the page doesnt end up self linking from all the random posts. <h3> <ul> some lis </ul> repeat blah <li><a href=""></li> <li> and so forth not all will have links So i need it filtered which i can do i just cant get it to display under the h :-\adings if i filter it for some reason Quote Link to comment 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.