Jump to content

Data Display Issues


dropfaith

Recommended Posts

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>";

?>

Link to comment
https://forums.phpfreaks.com/topic/182723-data-display-issues/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/182723-data-display-issues/#findComment-964924
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.