Forum Moderators: coopster
Seem to have got myself knotted here and I know this should be easy.
While rehacking a piece of code - the purpose of which is to put some data into a cell in a calendar - I have this. This is the original piece of code and it seems to work:
echo "\n<td align=center valign=top>".$holidayfont ;
showhols($weekhols,"cal_pophols.php?id=",true);
echo $closefont."</td>\n" ;
and am trying to convert it to the following:
$text .= "<td style='text-align: center; vertical-align: top'>";
$text .= showhols($weekhols,"evm_pophols.php?id=",true);
$text .="</td>" ;
which doesn't work. The data "floats" to the top of page.
The issue seems to be with the showhols function. Don't seem to have it nested properly.
Sort of lost sight of where I'm going here. Any suggestions would be appreciated?
showhols function? echoing data? For example:
function showhols($weekhols,$php_script_name,$true_or_false) {
echo 'some data';
}
true since the function completes normally and that will be concatenated to the $text variable. You may need to go about things this way:
function showhols($weekhols,$php_script_name,$true_or_false) {
global $test;
$text .= 'some data';
return $text;
}
showhols function is doing...
function showhols($hols,$hyperlink,$pop){$cnt = 0 ;
while ($row = mysql_fetch_object($hols)){
if ($cnt>0) echo "<br>" ;
if ($hyperlink=="")
echo "<u>" ;
else if ($pop)
echo "<a href='#' onclick=\"Javascript:window.open('".$hyperlink.$row->id."','popholswin','toolbar=no,location=no,status=no,
menubar=no,scrollbars=yes,resizable=no,width=300,height=300');\">" ;//all on one line
else
echo "<a href='".$hyperlink.$row->id."'>" ;
echo stripslashes($row->title) ;
if ($hyperlink!="")
echo "</a>";
else
echo "</u>";
$cnt++ ;
}
}
as mentioned, I'm hacking my way through someone else's code - learning as I go. I'd been inclined to just do a loop to collect and drop in the data. However, this function would serve the purpose of dropping in this data at other points in the app.
I'll work through your suggestion and see how we go.
Your function is writing out html and not appending it to your variable in your mainline loop. See what I mean? Change your echo's to
[b]$text .=[/b] and return the $text variable at the end of your function...