Solved

Code help. Gives balnk page.

Posted on 2008-10-06
11
157 Views
Last Modified: 2013-12-13
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
Comment
Question by:syedasimmeesaq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 13

Expert Comment

by:compfixer101
ID: 22652234
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
 
LVL 82

Expert Comment

by:hielo
ID: 22652256
change $all:
function Input($nama,$com, $id, $all)

 to $alldata:
function Input($nama,$com, $id, $alldata)
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 22652346
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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 82

Expert Comment

by:hielo
ID: 22652384
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
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 22652421
tried that..still no luck
0
 
LVL 82

Expert Comment

by:hielo
ID: 22652474
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
 
LVL 82

Expert Comment

by:hielo
ID: 22652499
>>$j = 0;
while($j < $alldata)

are you passing a numeric value for $alldata?
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 22652537
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
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 22652773
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
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 22653146
ok it was my fault..not sending the parameters right. You were right on heilo. Thanks
0
 
LVL 82

Expert Comment

by:hielo
ID: 22653373
you are welcome
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question