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!
what i want is the table and usernames to be display in any kind
of rows and colums i specify
*/
// here i'm looking for the user id and name
$users=mysql_query("SELECT ID,username FROM users");
while($user=mysql_fetch_array($users)){
// the variables
$id=$user['ID'];
$username=$user['username'];
$rows=9;//i want this number to control the number of rows in the table
$col=4;// i want this to be the number of coloums on my table
//i want to be able to custumize how many rows and colum i can put in a table
//this is the kind of loop i want
for($r=1;$r <=$rows; $r++){//loop for the ros
echo "<tr>";
for($c=1;$c <=$col; $c++){// and looping for the colums with the username inside the<td>
echo "<td>$username</td><td></td>";
}
echo "</tr>";
}
}
/*so if i run the script like i want it would display something like
+----+--------+
| ID |username| <--- any number of rows i want
+---+---------+
^ ^ and number of cells"colums" i want
*/
Can you explain the formatted output you want a little better? You want 9 rows with 4 columns each to print for each record returned from the database call? May I ask why? (may determine a better method for doing so)
bdlang wrote:Can you explain the formatted output you want a little better? You want 9 rows with 4 columns each to print for each record returned from the database call? May I ask why? (may determine a better method for doing so)
now i just want to be able to tell my table how many rows and colums it should have..
you know like when people are doing galleries.. that they difine how many rows and colums they want.. some thing like that.. i want to difine how many rows and colums my table show have..
i know how to do thi but i want to do it with variables.. now when i do that.. the tabl show the same variable or reapeat it all of then..
this is what i was looking for with this i can control my table by just changing the num or the % number.. my problem still that i can't work a query into it.. becuase the <td> sends the same name over and over..