Solved

Code help. Gives balnk page.

Posted on 2008-10-06
11
149 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now