Jump to content

H3 wont echo out


dropfaith

Recommended Posts

i got this all working but the headings arent echoing to the browserupon checking source for the page

<h3></h3> are echoed out  but the data is not any ideas why?

 

<?php
include("admin/db_connect.inc.php");
$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);
$sortedlist = array();
while ($list = mysql_fetch_assoc($result))
{
$sortedlist[$list['Type']][] = $list;
}
foreach($sortedlist as $list)
{
//echo "<pre>"; print_r($list); echo "</pre>";
echo "<h3>{$list['Type']}</h3>\n";
echo "<ul>\n";
foreach($list as $entry)
{
//echo "<pre>"; print_r($entry); echo "</pre>";
echo "<li>";
if(empty($entry['Link']))
echo $entry['Name'];
else
echo "<a href=\"{$entry['Link']}\">{$entry['Name']}</a>";
echo "{$entry['Venue']} {$entry['Year']}";
echo "</li>\n";
}
echo "</ul>\n";
}

?>

Link to comment
Share on other sites

I'm not sure, but it looks like $sortedlist is a two-dimensional array. And you're just echoing the array in the Type-dimension. It looks like you have to do:

echo "<h3>{$list['Type'][0]}</h3>\n"; (or whatever array-key you're trying to echo)

 

instead of:

echo "<h3>{$list['Type']}</h3>\n";

Link to comment
Share on other sites

nope still the same thing i had  with that. it need to echo the type thru a loop  like say theres 20 results in 5 groups

 

H3 group 1

somecrapi

more

 

H3 group 2

so on and so forth

 

http://dropfaith.freei.me/liveperformance.php is a test site for now  if you look its grouping them correctly but the headers wont echo out  which confuses me

Link to comment
Share on other sites

somewhere in this chunk of code its messed up and wont echo the text of the h3 everything else works fine

{$list['Type'][0]} is rhe olny thing not being echoed

wonders

$sortedlist = array();
while ($list = mysql_fetch_assoc($result))
{
$sortedlist[$list['Type']][] = $list;
}
foreach($sortedlist as $list)
{

//echo "<pre>"; print_r($list); echo "</pre>";
echo "<h3>{$list['Type'][0]}</h3>\n";
echo "<ul>\n";

Link to comment
Share on other sites

is the full code

<?php
error_reporting(E_ALL);

include("admin/db_connect.inc.php");
$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);
$sortedlist = array();
while ($list = mysql_fetch_assoc($result))
{
$sortedlist[$list['Type']][] = $list;
}
foreach($sortedlist as $list)
{

//echo "<pre>"; print_r($list); echo "</pre>";
echo "<h3>{$list['Type'][0]}</h3>\n";
echo "<ul>\n";



foreach($list as $entry)
{
//echo "<pre>"; print_r($entry); echo "</pre>";
echo "<li>";
if(empty($entry['Link']))
echo $entry['Name'];
else
echo "<a href=\"{$entry['Link']}\">{$entry['Name']}</a>";
echo "{$entry['Venue']} {$entry['Year']}";
echo "</li>\n";
}
echo "</ul>\n";
}

?>

Link to comment
Share on other sites

http://dropfaith.freei.me/liveperformance.php

wtf  so  im playing with this some more and tryed

<?php $sortedlist = array();
while ($list = mysql_fetch_assoc($result))
{
$sortedlist[$list['Type']][] = $list;
}
foreach($sortedlist as $list)
{

//echo "<pre>"; print_r($list); echo "</pre>";
echo "<h3>{$entry['Type']}</h3>\n";
echo "<ul>\n";



foreach($list as $entry)
{
//echo "<pre>"; print_r($entry); echo "</pre>";
echo "<li>";
if(empty($entry['Link']))
echo $entry['Name'];
else
echo "<a href=\"{$entry['Link']}\">{$entry['Name']}</a>";
echo "{$entry['Venue']} {$entry['Year']}{$entry['Type']}";
echo "</li>\n";
}
echo "</ul>\n";
}?>

 

which  almost worked  but its one off like one down

the top list has no type and then they start with the top ones type over the second list set this is pissing me off its the only thing left on this site and  i cant fiqure it out

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.