View Full Version : Help With Code
Well the code is below:
<?
include "config.php";
$d = mysql_query("SELECT * FROM `users` ORDER BY `level` ASC");
while ($staff = mysql_fetch_array($d)) {
IF ($staff[level] == 2) {
echo (" <p><strong></strong></p> ");
echo ("
<p><a href=\"members.php?view=Profile&user=$staff[username]\"><b>$staff[habboname]</b></a> - DJ $staff[username]");
}
}
?>
But it adds users in rows like
Link
Link
Link
Does any one know how to make them in collums (of 3)?
Like
Link Link Link
+ Rep For Helping :D
J1MI (Forum Moderator) - Thread moved from Website designing, hopefully you'll get more reply's here
Heinous
28-11-2006, 08:56 PM
Each loop have a value increment ($i++) and use
if ($i == 3 | $i == 6 | $i == 9) {}
etc etc.
Obviously if it returns true, <br /> or new table row, whatever method you're using.
Each loop have a value increment ($i++) and use
if ($i == 3 | $i == 6 | $i == 9) {} etc etc.
Obviously if it returns true, <br /> or new table row, whatever method you're using.
Can u edit the code above please :p
Im not very good when people say use this, I then end up staring at screen like, erm, hum, where I put it lol
Luckyrare
28-11-2006, 09:12 PM
Its much easier to do it this way...
<?
include "config.php";
$d = mysql_query("SELECT * FROM `users` ORDER BY `level` ASC");
while ($staff = mysql_fetch_array($d)) {
IF ($staff[level] == 2) {
echo (" <p><strong></strong></p> ");
echo ("
<div style=\"width: 33%;\"><a href=\"members.php?view=Profile&user=$staff[username]\"><b>$staff[habboname]</b></a> - DJ $staff[username]</div>");
}
}
?>
Make each div 33%
Heinous
28-11-2006, 09:17 PM
Its much easier to do it this way...
<?
include "config.php";
$d = mysql_query("SELECT * FROM `users` ORDER BY `level` ASC");
while ($staff = mysql_fetch_array($d)) {
IF ($staff[level] == 2) {
echo (" <p><strong></strong></p> ");
echo ("
<div style=\"width: 33%;\"><a href=\"members.php?view=Profile&user=$staff[username]\"><b>$staff[habboname]</b></a> - DJ $staff[username]</div>");
}
}
?> Make each div 33%
But darling, div's stack by default. :) And if he used float, then that would stuff up as it would be floating. :)
And no, you asked for help, I told you how. If you don't work out how to implement it yourself, you'll never learn.
Heinous
28-11-2006, 09:47 PM
put $i = 0; before the while statement. :p
edit;
and $i = $i++ in the while statement.
Im Officaly Confused Now :S
<table border="1">
<?php
require('config.php');
$SQL = mysql_query("SELECT * FROM `users` ORDER BY `level` ASC");
while($row = mysql_fetch_array($SQL))
{
if(!$n) print '<tr>';
$n++;
print <<<HTML
<td> <a href='members.php?view=Profile&user={$row['username']}'>{$row['habboname']}</a> - {$row['username']} </td>
HTML;
if($n!=3) continue;
print '</tr>';
unset($n);
}
?>
</table>
Mentor
29-11-2006, 11:52 PM
put $i = 0; before the while statement. :p
edit;
and $i = $i++ in the while statement.
Im to lazy to follow whats going on here but, you dont actualy need the $i = part. The code $i++ on its own is all you need to incriment the value of $i by one
with the code, its not realy a auto staff list, with the old 1, it put level 1 as management etc.....
So it only lists management, not All staff :S
Can any one make this, If user level = 1, only show them users?
<table border="0">
<?php
require('config.php');
$SQL = mysql_query("SELECT * FROM `users` ORDER BY `level` ASC");
while($row = mysql_fetch_array($SQL))
{IF ($staff[level] == 1)
if(!$n) print '<tr>';
$n++;
print <<<HTML
<td><table id="table1" style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="42" width="129" border="1">
<tr>
<font face="Verdana" color="#000000" size="1">
<td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; FONT-WEIGHT: normal; FONT-SIZE: 10pt; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; FONT-STYLE: normal; FONT-FAMILY: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; FONT-VARIANT: normal" align="middle" width="123" bgColor="#cce6ff" height="20">
<b> <a href='members.php?view=Profile&user={$row['username']}'>
<font size="1" face="Verdana">{$row['habboname']}</font></a></b></td>
</font>
</tr>
<tr>
<font face="Verdana" color="#000000" size="1">
<td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; FONT-WEIGHT: normal; FONT-SIZE: 10pt; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; FONT-STYLE: normal; FONT-FAMILY: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; FONT-VARIANT: normal" align="middle" width="123" bgColor="#cce6ff" height="20">
<i><font size="1" face="Verdana">DJ {$row['username']} </td></font></i></td>
</font>
</tr>
</table></td>
HTML;
if($n!=3) continue;
print '</tr>';
unset($n);
}
?>
</table>
<table border="0">
<?php
require('config.php');
$SQL = mysql_query("SELECT * FROM `users` ORDER BY `level` ASC");
while($row = mysql_fetch_array($SQL))
if ($staff[level] == 1) {
if(!$n) print '<tr>';
$n++;
print <<<HTML
<td><table id="table1" style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="42" width="129" border="1">
<tr>
<font face="Verdana" color="#000000" size="1">
<td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; FONT-WEIGHT: normal; FONT-SIZE: 10pt; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; FONT-STYLE: normal; FONT-FAMILY: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; FONT-VARIANT: normal" align="middle" width="123" bgColor="#cce6ff" height="20">
<b> <a href='members.php?view=Profile&user={$row['username']}'>
<font size="1" face="Verdana">{$row['habboname']}</font></a></b></td>
</font>
</tr>
<tr>
<font face="Verdana" color="#000000" size="1">
<td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; FONT-WEIGHT: normal; FONT-SIZE: 10pt; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; FONT-STYLE: normal; FONT-FAMILY: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; FONT-VARIANT: normal" align="middle" width="123" bgColor="#cce6ff" height="20">
<i><font size="1" face="Verdana">DJ {$row['username']} </td></font></i></td>
</font>
</tr>
</table></td>
HTML;
if($n!=3) continue;
print '</tr>';
unset($n);
}
?>
</table>
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.