Page 1 of 1

How to auto create row using PHP ??

Posted: Fri Sep 07, 2007 4:45 am
by aris1234
Hi All....

please help Me :cry:

my casus laike this:

i have table with 5 colums , after every cell in colum have data i want auto create 5 row with 5 colum too.
but that row auto create if every colum have data.

this code just for looping colums :

Code: Select all

<?php
    																										$columns = 4;
$query = "SELECT * FROM rremarks  WHERE r_name='$rid' ORDER BY r_date ASC";
$result = mysql_query( $query, $conn ) or die('Error, query failed');
for($i=0; $i < $columns; $i++ ) {
	$myrow = mysql_fetch_array($result);
																									        	if($i % $columns == 0){
 		echo "<tr height=\"31\" style='color:black'>\n";
	}																							        	  	if(!empty($myrow)){ ?>

 		<?php 
		     if($myrow['r_date'] <= $today) { 
	                 echo "<td width=\"80\" valign=\"top\" style='border:1px solid silver'>" . 
         		"<div style='padding-top:5px;'><a href=\"#\">$myrow[r_date]</a></div><div style='padding-top:5px;'><a href=\"#\">Report</a></div><div style='padding-top:5px;'><a href=equipmenta.php?rid=$regid>Equipment</a></div><div style='padding-top:5px;'><b>$myrow[r_coach]</b></div>" . 
 		"</td>\n"; 
																									        		}else{
 		echo "<td width=\"80\" valign=\"top\" style='border:1px solid silver'>" . 

 		"<div style='padding-top:5px;'><a href=\"#\">$myrow[r_date]</a></div><divstyle='padding-top:5px;'>Report</div><div style='padding-top:5px;'>Equipment</div><div style='padding-top:5px;'><b>$myrow[r_coach]</b></div>" . 			        		"</td>\n";
	} ?>
	<?php }else{ ?> 
<form name="sche" onsubmit="return validate()" action="prorange.php" method="POST">
																									        			<td width="80" style="border:1px solid silver"> 
 				<input type="hidden" value="<?php echo $regid ?>" name="rn" id="rn">
				<input name="ffr" type="hidden" value="Range" />
				<div><input style="font-size:11px;" name="rd" onfocus="showCalendarControl(this);" type="text"                                     size="8"></div>
                                <div style="padding-top:5px;">	
                                      <select style="font-size:11px;" name="rt" id="rt">
		  				<option value="">time</option>
								<?php foreach($htime as $t): ?>
		  				<option value="<?php echo($t["timer"])?>"><?php echo($t["timer"])?></option>
								<?php endforeach; ?>
         				</select>
				</div>
				<div style="padding-top:5px;">
					<select style="font-size:11px; width:72px;" name="fc" id="fc">
						<option value="">Coach</option>	
							<?php foreach($co as $o): ?>
						<option value="<?php echo($o["cname"])?>"><?php echo($o["cname"])?></option>
								<?php endforeach; ?>
					</select>
				</div>
            <div style="padding-top:5px;"><input style="font-weight:bold; font-family:arial; font-size:11px; color:black;" type="submit" value="save" /></div>
 			</td></form>
																									        		<?php }  ?>
  		<?php 																									        		if(($i % $columns) == ($colum - 1) || ($i + 1) == $columns) {
																									        			echo "</tr>\n";																			        		}   }  ?>
how auto create row?

:oops: :oops:

Posted: Fri Sep 07, 2007 12:18 pm
by feyd
I'm having a tough time trying to understand your problem.

Spelling corrections:
"casus" I have no idea what this is supposed to be.
"laike" like.
"colum" column.

Posted: Fri Sep 07, 2007 4:44 pm
by VladSun
I think "casus" is for "case" (in my country it means "case" in the meaning of "lawsuit"), but I can't understand the problem neither.

Posted: Fri Sep 07, 2007 11:09 pm
by aris1234
i'm very sorry if my engglish languange not good :oops:

im mean like this :

this my table :

colums1 | colums2 | colums3 | colums4 | colums5
data1 data2 data3 data4 data5


if each colums have 5 data then auto create rows
if one or more colums no have data then not auto create rows

please see this :
http://www.conversewithgod.com/golfcour ... php?rid=42

thanks.