Solved

Code help. Gives balnk page.

Posted on 2008-10-06
11
146 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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 Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 look for a specific file type in a local or remote server directory using PHP.

758 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

17 Experts available now in Live!

Get 1:1 Help Now