OK, I've been at this for hours now and can't get it to do what I what. It may not even be the right function to do this with. I have a search on a site that searches the db for files and displays a link to the files returned. If a document is in pdf I want it to display a pdf icon and if in word to display a word icon. Here is where I'm at, can anyone help me? $name2 = $row['name']; if (strlen(strstr($name2, '.pdf'))>0) { $icon = "<img src='pdf_icon.png' width='25px' height='30px' border='0' />"; } elseif (strlen(strstr($name2,'.doc'))>0) { $icon - "<img src='ms-word-icon.png' width='25px' height='30px' border='0' />"; } else { $icon = ""; } print "<td width='20px'> <a href='msds/" . $name2 . "' target='_blank'>" . $icon . "</a></td> <td>" . $name2."</td> <td>" . $row['number']."</td> <td>" . $row['manufacture']."</td>"; print "</tr>\n"; Code (markup):
Looks like the problem is at line 5: $icon - "<img src='ms-word-icon.png' width='25px' height='30px' border='0' />"; PHP: the '-' should be a '=' also you don't need to do the strlen check strstr will return false if it is not found.
Can't believe I missed that, guess I needed another set of eyes to look. I figured I messed up the if statements, never done anything with that function before. Thanks