Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

Code help. Gives balnk page.

What is wrong with this code. Can anyone point out. Thanks
function Input($nama,$com, $id, $all)
{
if($nama == 0){
$com = "<font color=\"red\"> </font>";
 
}
 
$HTML =  
"
<HTML>
	<BODY>
	
	 
		<table width='90%' border='2'> ";
$j = 0;
while($j < $alldata)
{
		
		
$HTML .=  "
  
  
  <tr>
    <td>$id</td>
    <td>$com</td>
  </tr>";
 $j++ 
}  
$HTML .= "</table>
		
	</BODY>
</HTML>";
return $HTML;
}

Open in new window

0
syedasimmeesaq
Asked:
syedasimmeesaq
  • 6
  • 4
1 Solution
 
compfixer101Commented:
try this

also what is $j++ for?
<?php
function Input($nama,$com, $id, $all)
{
if($nama == 0){
$com = "<font color=\"red\"> </font>";
 }
 $HTML = "
<HTML>
	<BODY>
		<table width='90%' border='2'> ";
$j = 0;
while($j < $alldata)
{
$HTML .=  "<tr>
    <td>$id</td>
    <td>$com</td>
  </tr>";
 $j++ 
}  
$HTML .= "</table>
	</BODY>
</HTML>";
return $HTML;
}
?>

Open in new window

0
 
hieloCommented:
change $all:
function Input($nama,$com, $id, $all)

 to $alldata:
function Input($nama,$com, $id, $alldata)
0
 
syedasimmeesaqAuthor Commented:
I tried that but the above suggestions didn't work. Still giving me a blank page. I think it is because I am breaking $HTML variable wrong. Any idea ?
Thanks
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
hieloCommented:
you are missing a semicolon after $j++. copy and paste this:
<?php
function Input($nama,$com, $id, $alldata)
{
	if($nama == 0){
		$com = "<font color=\"red\"> </font>";
	}
 
	$HTML ="
<HTML>
        <BODY>
        
         
                <table width='90%' border='2'> ";
$j = 0;
while($j < $alldata)
{
	$HTML .=  "
  <tr>
    <td>{$id}</td>
    <td>{$com}</td>
  </tr>";
 $j++;
}  
$HTML .= "</table>
                
        </BODY>
</HTML>";
return $HTML;
}

Open in new window

0
 
syedasimmeesaqAuthor Commented:
tried that..still no luck
0
 
hieloCommented:
Did you notice the braces around the variables:
>>   <td>{$id}</td>
>>    <td>{$com}</td>

there's nothing else wrong with that function. Most likely you are not passing the parameters correctly.
0
 
hieloCommented:
>>$j = 0;
while($j < $alldata)

are you passing a numeric value for $alldata?
0
 
syedasimmeesaqAuthor Commented:
yes. What I am trying to do is make the rows of the data from the table. $alldata is 7 cause there are 7 records. the code below works but gives me only 1 record and I want to generate the rows for as many records are there. But when I slice the code below to incoporate WHILE statement, it fails. It doesn't let me break the variable.
Thanks
<?php
function Input($nama,$com, $id, $alldata)
{
	if($nama == 0){
		$com = "<font color=\"red\"> </font>";
	}
 
	$HTML ="
<HTML>
        <BODY>
        
         
                <table width='90%' border='2'> 
	
  <tr>
    <td>{$id}</td>
    <td>{$com}</td>
  </tr>
</table>
                
        </BODY>
</HTML>";
return $HTML;
}

Open in new window

0
 
hieloCommented:
you probably need $com in between the font tags. The attached code worked for me:
function Input($nama,$com, $id, $alldata)
{
	if($nama == 0){
		$com = "<font color=\"red\">$com</font>";
	}
 
	$HTML ="
<HTML>
        <BODY>
        
         
                <table width='90%' border='2'> ";
$j = 0;
while($j < $alldata)
{
	$HTML .=  "
  <tr>
    <td>{$id}</td>
    <td>{$com}</td>
  </tr>";
 $j++;
}  
$HTML .= "</table>
                
        </BODY>
</HTML>";
return $HTML;
}
 
echo Input(0,"y",3,4);

Open in new window

0
 
syedasimmeesaqAuthor Commented:
ok it was my fault..not sending the parameters right. You were right on heilo. Thanks
0
 
hieloCommented:
you are welcome
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now