Page 1 of 1

Add defult number of rows?

Posted: Thu Aug 16, 2012 11:06 pm
by jayson.ph
Hi all,

For now i have this below
Image
and it not good looking for a user or else for us and to show up the record i use while/fetch_array: and any idea if how to insert a defult number of rows in a table. like image below
Image

Re: Add defult number of rows?

Posted: Thu Aug 16, 2012 11:43 pm
by requinix
If you outputted X rows and X<19 then output 19-X more empty rows. Really basic stuff, this.

Re: Add defult number of rows?

Posted: Fri Aug 17, 2012 12:04 am
by jayson.ph
can i have your little code? to have additional idea.

Re: Add defult number of rows?

Posted: Sun Aug 19, 2012 3:46 am
by jayson.ph
hi trying your answer but i don't thinks so if it is correct what you mean: i trying this

Code: Select all

for($i=20; $i<20; $i++)
the output will generate x20 in every id. instead i have only 5 records it will make 100. ==

What i mean is i need to set an empty rows in my page that correspond or equal into my table limit 20. because even if no record found the table is still there even if it is empty. like in image example above. and i hope there is someone could help. thanks

Re: Add defult number of rows?

Posted: Sun Aug 19, 2012 3:44 pm
by requinix
What's the rest of your code?

Re: Add defult number of rows?

Posted: Mon Aug 20, 2012 12:29 am
by jayson.ph
i off in office but i have something i have like this: my job was work fine. my problem is to set ready made table rows.

Code: Select all


   	$query= "SELECT * FROM list ORDER BY id LIMIT 0,20" ;
   	$result= mysql_query($query);

  	 while($row = mysql_fetch_array($result) ){
	
	fo($i=0;$i<19;$i++)
	{
   
	echo '<tr>';
	
  	 echo '<td><input type=\"hidden\" name=\"id\" value=" . $row['id'] . " />'.$i.'</td>';
 	 echo '<td><input type=\"text\" name=\"fname\" value=" . $row['fname'] . " />'.$i.'</td>';
 	 echo '<td><input type=\"text\" name=\"lname\" value=" . $row['lname'] . " />'.$i.'</td>';
  	 echo '<td><input type="submit" value="Save Changes" />''</td>';
	echo '</tr>'; 
   
	}
	}
	?>


Re: Add defult number of rows?

Posted: Mon Aug 20, 2012 2:47 am
by requinix
Well, with that code you're displaying each row 19 times...

Keep just the while loop. Use mysql_num_rows to figure out how many you printed (or keep a running counter) and print however many more rows as filler until you reach 20 rows.