Closed Thread Icon

Topic awaiting preservation: can't display all SQL entries (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=13036" title="Pages that link to Topic awaiting preservation: can&amp;#039;t display all SQL entries (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: can&#039;t display all SQL entries <span class="small">(Page 1 of 1)</span>\

 
~Sir_KiTree~
Bipolar (III) Inmate

From: PA
Insane since: Jul 2001

posted posted 01-15-2004 23:38

ok here's my problem: my code is not retrieving the first entry in every new category. see where it says

code:
if ($counter != 3){
echo "<td align='left' width=76> <IMG SRC='images/thumbs/".strtolower($ID). "_thumb.jpg'></td><TD align='left'>". $label."<br>".$type."</TD>";


well that is where it is supposed to display the particular cells but it seems that everytime it goes to a new $category (which is the echo above it) it doesn't display the first entry in the database at the start of the new category.


here's my code:

code:
$link = mysql_connect($page_mysqlserver, $page_mysqluser, $page_mysqlpass);
mysql_select_db($page_mysqldb);


$sql = "SELECT `clicks` , `category` , `label` , `type` , `description` , `ID` , `section1` , `section2` FROM `Sheet1` WHERE 1 AND `section2` = 'Health' ORDER BY `category` ASC ";
$result = mysql_query($sql);
$counter = 0;
echo "<TABLE class='text' width='100%' border='0'><TR>";
while ($row = mysql_fetch_array($result)) {

$clicks = $row[clicks];
$category = $row[category];
$label = $row[label];
$type = $row[type];
$descr = $row[description];
$ID = $row[ID];
$section1 = $row[section1];
$section2 = $row[section2];
$counter++;

if ($oldcategory != $category){
echo "<tr><td class='header' colspan='2'><hr><a name=\"".$category."\"></a>".$category."</td><td class='header' align='right' colspan='2'><hr><a href='#top'>^ TOP</a></td></tr><tr>";
}
if ($counter != 3){
echo "<td align='left' width=76> <IMG SRC='images/thumbs/".strtolower($ID). "_thumb.jpg'></td><TD align='left'>". $label."<br>".$type."</TD>";
}else{
$counter = 0;
echo "</tr><tr>";
}
$oldcategory = $category;
}

echo "</tr>";
echo "</table>";

?>



Thanks in advance for any ideas.

~Sir_KiTree~Scan~
..::ill communications network::..

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 01-16-2004 01:15

Try this SQL instead:

"SELECT `clicks` , `category` , `label` , `type` , `description` , `ID` , `section1` , `section2` FROM `Sheet1` WHERE `section2` = 'Health' ORDER BY `category` ASC ";

~Sir_KiTree~
Bipolar (III) Inmate

From: PA
Insane since: Jul 2001

posted posted 01-16-2004 01:55

still happening. funny thing is it seems to be excluding every 4th entry now that i look at it closer. must have something to do with the ($counter != 3). if i change it to ($counter != 3 &#0124; &#0124; $counter == 3) i get all entries, but it doesn't create a new row which was the point in the first place... hrmm...

~Sir_KiTree~Scan~
..::ill communications network::..

~Sir_KiTree~
Bipolar (III) Inmate

From: PA
Insane since: Jul 2001

posted posted 01-16-2004 01:57

nevermind. i fixed it... added the same line

code:
echo "<td align='left' width=76> <IMG SRC='images/thumbs/".strtolower($ID). "_thumb.jpg'></td><TD align='left'>". $label."<br>".$type."</TD>";

into the else statement and that solved the problem. guess i just needed to know someone cared! ha! thanks.

~Sir_KiTree~Scan~
..::ill communications network::..

« BackwardsOnwards »

Show Forum Drop Down Menu