This one isnt working!

function insertpath($num){
echo "          <td colspan=\"3\" align=\"left\"> <br>\n";
echo "              <b>Date Published</b>:",$Date_Added[$num] ,"<br>\n";
echo "              <b>Sample</b>:",$Sample_Views[$num],"</td>\n";
}
insertpath(0);

But this one Works

echo "          <td colspan=\"3\" align=\"left\"> <br>\n";
echo "              <b>Date Published</b>:",$Date_Added[$num] ,"<br>\n";
echo "              <b>Sample</b>:",$Sample_Views[$num],"</td>\n";

Well not woking in the sense the values of variables ($Date_Added[$num],$Sample_Views[$num]) not coming in the first. Whil in second its working!


Help me :(

Recommended Answers

All 2 Replies

There are two things you need to do to troubleshoot this problem. INSIDE your function, at the very top, do this:

First, echo out one of the arrays like this:

echo "<pre>";
print_r($Date_Added);
echo "</pre>";

Then echo out the value of $num:

echo "<hr />".$num;

You should see that $num = 0, but that your array does not even exist. You forgot one important line at the top of your function:

global $Date_Added, $Sample_Views;

Maybe concat syntax error :o

THIS....
echo "<b>Sample</b>:",$Sample_Views[$num],"</td>\n";

SHOULD BE THIS....
echo "<b>Sample</b>:".$Sample_Views[$num]."</td>\n";

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.