Jump to content

[SOLVED] A little help with some code please...


cowboysdude

Recommended Posts

This is what I have... but I also have a problem.  When there is no file it is still a clickable link... I do not want that.  I just want it to be empty with no clickable areas... currently if you click on it, it will tell you that NO SUCH file exists... lol  I knew that ... how do I make it so nothing happens if there is no file..

 

<?php
$filename= array($fileone,$filetwo,$filethree,$filefour,$filefive,$filesix,$fileseven,$fileeight);
$title= array($name1,$name2,$name3,$name4,$name5,$name6,$name7,$name8);
$time= array($time1,$time2,$time3,$time4,$time5,$time6,$time7,$time8); 
$path = $params->get('path');

foreach($filename as $key=>$filename){
     if($filename != $filename){
       echo " "; 
    }else{
        echo "<a href='$path/$filename'> $title[$key]
	<br /> $time[$key]";

    }
}
?>

 

Somebody gave me this suggestion..

use;

 

if(!empty($filename){

}

 

BUT I have tried to replace this line with the above

 

if($filename != $filename){
       echo " "; 
    }

 

But I get a parsing error..

 

Suggestions?

 

Thanks in advance! 

Link to comment
Share on other sites

foreach($filename as $key=>$filename){

    if($filename != $filename){

 

You're defining the variable $filename twice.

 

Well ok... lol being very green at this I'm not sure I'm reading it like this:

foreach FILE print the title plus time, if the file does not equal the file then do something.

 

I may be wrong and why I can't figure this out..WHEW... this learning stuff ...

 

The first line defines the file plus the title and time so it will show up in html... is that wrong?

 

Thank you

 

Link to comment
Share on other sites

What's wrong though is that you're looping through the array $filename and defining the values to $filename.  You don't see the problem?  After the first iteration, $filename will no longer be your array; it will be the first name from the $filename array.

Link to comment
Share on other sites

Somebody gave me this suggestion..

use;

 

if(!empty($filename){

}

 

BUT I have tried to replace this line with the above

 

if($filename != $filename){
       echo " "; 
    }

 

But I get a parsing error.. 

 

Missing a parentheses...

 

if(!empty($filename)){

}

 

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.