Jump to content

Problematic if statement


Schlo_50

Recommended Posts

Hi there,

 

I have a list of manufacturer names in the format: ID|NAME|CAT_ID

 

I have a script which displays the list in a table and now I want it to be a bit more clever in that when you are viewing a category on my site all related manufacturers show up. I thought a simple if statement would suffice (if ($_GET['cid'] == $manid) { //run code here } but it's not producing the desired effects. $_GET['cid'] is definately picking up the correct id too. At the moment if I go to a page with a matching category nothing displays at all.

 

$Lines = file("admin/data/manufacturers.DAT");

if(count($Lines) < 1){
print "<br><p align=\"center\">There are no items in this category</p>";
}

print "<table align=\"center\" cellspacing=\"0\" width=\"100%\">";
print "<tr height=\"30\">";

foreach($Lines as $Key => $Val){
$Data[$Key] = explode("|", $Val);
}

for ($i = 0; $i < count($Lines); $i++) {

$cnt++;
$mid = trim($Data[$i][0]);
$name = trim($Data[$i][1]);
$manid = $Data[$i][2];

if ($_GET['cid'] == $manid){

if (($i % 2) === 0 && $i > 0) {
print "</tr><tr height=\"30\">\n";
}
print "<td width=\"50%\"><p><img src=\"images/arrow.gif\" border=\"0\">  <a href=\"?id=manufacturer_view&cid=$mid\"><b>$name</b></a></p></td>\n$manid - ".$_GET['cid']."";

}
}
print "</tr>";
print "</table>";

 

Could someone please take a look and possible revise the troubling area?

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/108005-problematic-if-statement/
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.