Click here to Skip to main content
15,902,275 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to make a grid whose size is based on user's input and if certain conditions are true then its some of boxes is fill with a colour.This is my code.If i give constant values like this
echo $table_string= Table(4,3); it works fine but if i give it values through user's input like thi
echo $table_string= Table("noOfProcess,3); table doesnt show

XML
<html>

<head>
<title> Sheduling Algorithms </title>
</head>

<body>

<form method = "post" action = ""><br>
Number Of Processess: <input type = "text" name="noOfProcess" /><br>
<input type = "radio" name = "algo" value= "FCFS" /> FCFS <br>
<input type = "radio" name = "algo" value = "SPN" > SPN <br>
<input type = "radio" name = "algo" value = "SRT" /> SRT <br>
<input type = "radio" name = "algo" value = "RRH" /> RRH <br>
<input type= "submit">

</form>

</body>

</html>

<?php

function Table($rows,$columns)
{
     $table_string =
     "<table border='1' >
     <tr>
       <th> Process # </th>
       <th> Arrival Time </th>
       <th> Service Time</th>
     </tr>";
     for($j=0;$j<$columns;$j++)
     {
          $column_string.= "<td> asma </td> ";
     }
     for($i=0;$i<$rows;$i++)
     {
          $table_string.= "<tr>";
          $table_string.= $column_string."</tr>";
     }
     $table_string.="</table>";
     return $table_string;
}
$noOfProcess =  $_POST["noOfProcess"];
$algo =  $_POST["algo"];
echo $table_string= Table("noOfProcess",3);
Posted
Updated 29-Oct-11 4:20am
v2

 
Share this answer
 
Hi Dear,

First try on yourself......


Create your required field with the help of table tag and echo the records from database in respective
<table><tbody><tr><td>?<?php echo "your records here";  ??></td></tr></tbody></table>
tag and and if you want to color records or background the put your condition before echo that records.
 
Share this answer
 
Comments
Sweety Khan 29-Oct-11 10:21am    
i dont want to show data in it. i want to fill some particular boxes or cells with a colour.
arya1685 30-Oct-11 3:55am    
Just put a condition if it's true then echo that cell or box with color background otherwise echo simple cell/box
You might be interested in the HTML5 Canvas[^]

Your boxes/cells might end up looking quite nice :)

Best regards
Espen Harlinn
 
Share this answer
 
There is only one mistake which is in the last line of the code. noOfProcess is a variable and variable should start with $ symbol in php.

Wrong
PHP
echo $table_string= Table("noOfProcess",3);


Corrected
PHP
echo $table_string= Table($noOfProcess,3);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900