473,396 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Static Column amongst Multi-Column Loop

LuiePL
24
I'm looking to update my member list, Since certain states will have more members, I've decided to go with a "single list" approach. I found the following code from this site, which I have modified for my purposes:

[PHP]$columns = 3;

$query = Non Admins;
$result = mysql_query($query);

$num_rows = mysql_num_rows($result);

//we are going to set a new variables called $rows
$rows = ceil($num_rows / $columns);

//to do this display, we will need to run another loop
//this loop will populate an array with all our values
while($row = mysql_fetch_array($result)) {
$data_row = $row['Number'].'-'.$row['FirstName'].' '.$row['LastName'];
$data[] = $data_row;
}

echo "<TABLE BORDER='0'>\n";

echo "<tr>\n<td valign='top' width='25%'>\n";

$querymem = Admins;
$sqlmem = mysql_query($querymem) or die(mysql_error());

while ($rowmem = mysql_fetch_array($sqlmem))
{
$number = $rowmem['Number'];
$fullname = $rowmem['FirstName']." ".$rowmem['LastName'];
echo "<p><b><font color='#FFCC00'><a href='member.php?name=$number'>".strtoupper($numbe r)."</a></font></b><br />".ucwords($fullname)."</p>\n";
}

echo "</td>\n</tr>\n";

//here we changed the condition to $i < $rows
for($i = 0; $i < $rows; $i++) {

echo "<TR>\n";

//here will run another loop for the amount of columns
for($j = 0; $j < $columns; $j++) {
if(isset($data[$i + ($j * $rows)])) {
$member_info = explode("-", $data[$i + ($j * $rows)]);
$number = $member_info[0];
$name = $member_info[1];
echo "<TD valign='top' width='25%'>";
echo "<b><a href='member.php?name=$number'>".strtoupper($numbe r)."</a></b>";
echo "<br />".ucwords($name);
echo "</TD>\n";
}
}
echo "</TR>\n";
}
echo "</TABLE>\n";[/PHP]

You can see the results on my test page. So I'm trying to figure out a way to still have the one column for administrators only, and the regular members to be in the other columns.
Oct 5 '06 #1
1 1827
bevort
53
You could try to put all in one 2D array with 3 colomns per row filling the first colomn with the admins and the 2nd and 3rd witn you members
Then, when creating the HTML, use the array instead of the queries
Oct 5 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: jacob navia | last post by:
As far as I understood the standard, non-automatic variables (static/global data) can't be cached in registers because in a multiprocessing or multi-threading environment, another thread/processor...
3
by: Mauzi | last post by:
hi, this may sound odd and noob like, but what is the 'big' difference between static and non-static funcitons ? is there any performace differnce? what is the best way to use them ? thnx ...
9
by: Seenu | last post by:
Is it safe to create a static function in a multi threaded application ? As an example, I have a function that logs errors ,exceptions and some informational data public static void Log(....) {...
25
by: Sahil Malik [MVP] | last post by:
So here's a rather simple question. Say in an ASP.NET application, I wish to share common constants as static variables in global.asax (I know there's web.config bla bla .. but lets just say I...
6
by: WebMatrix | last post by:
Is there any performance considerations or any other concerns about having a Class with private constructor and all static functions? One particular function in question creates a few new instances...
55
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
3
by: Steve Folly | last post by:
Hi, I had a problem in my code recently which turned out to be the 'the "static initialization order fiasco"' problem (<http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12>) The FAQ...
6
by: Smithers | last post by:
In consideration of a "Utilities" class that contains methods intended to be used amongst multiple projects... Is there any general consensus on whether such a class should be static? I have...
4
by: Dave | last post by:
I have a global.asax file with Application_Start defined and create some static data there and in another module used in the asp.net application and I realize that static data is shared amongst...
4
by: Steffen Bobek | last post by:
Extension methods are made for use with instances. I'd like to "misuse" them as static methods, too. Let me tell you my ambition: I use an extension method to serialize objects somehow like this:...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.