Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Code help. Gives balnk page.

Posted on 2008-10-06
11
Medium Priority
?
164 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…

704 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