Add defult number of rows?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Add defult number of rows?

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Add defult number of rows?

Post by requinix »

If you outputted X rows and X<19 then output 19-X more empty rows. Really basic stuff, this.
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: Add defult number of rows?

Post by jayson.ph »

can i have your little code? to have additional idea.
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: Add defult number of rows?

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Add defult number of rows?

Post by requinix »

What's the rest of your code?
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: Add defult number of rows?

Post 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>'; 
   
	}
	}
	?>

User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Add defult number of rows?

Post 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.
Post Reply