Solved

Code help. Gives balnk page.

Posted on 2008-10-06
11
151 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
  • 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
Industry Leaders: 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 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

735 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