473,387 Members | 1,495 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,387 software developers and data experts.

Layout of mySQL quary (again!)

Hi there,

I have the following code:

$side1 = '#EFEFEF';
$side2 = '#DDDDDD';
$sideoffset = 0;

echo "<table>";
$column = 0;
while ($myrow = mysql_fetch_array($result2)) {
$TDcolor = ($sideoffset++ % 2) ? $side1 : $side2;
if (!$column) echo "<tr >";
echo "<td bgcolor=\"$TDcolor\">",$myrow["last"],"</td>";
if ($column) echo "</tr>";
$column = !$column;
}
if ($column) echo "<td></td></tr>";
echo "</table>";
This really works great, but my next problem is that collumns on
the left side, need another <td>$var</td> on their left, and
the ones on the right need it on the right, so the output would
look like:

_ _____ _____ _
|_|__x__|__x__|_|
|_|__x__|__x__|_|
|_|__x__|__x__|_|

I hope this is clear enough, and that anyone can help me...

Greetings knoakske
Jul 17 '05 #1
1 1706
knoak wrote:
Hi there,

I have the following code:

$side1 = '#EFEFEF';
$side2 = '#DDDDDD';
$sideoffset = 0;

echo "<table>";
$column = 0;
while ($myrow = mysql_fetch_array($result2)) {
$TDcolor = ($sideoffset++ % 2) ? $side1 : $side2;
if (!$column) echo "<tr >";
echo "<td bgcolor=\"$TDcolor\">",$myrow["last"],"</td>";
if ($column) echo "</tr>";
$column = !$column;
}
if ($column) echo "<td></td></tr>";
echo "</table>";
This really works great, but my next problem is that collumns on
the left side, need another <td>$var</td> on their left, and
the ones on the right need it on the right, so the output would
look like:

_ _____ _____ _
|_|__x__|__x__|_|
|_|__x__|__x__|_|
|_|__x__|__x__|_|

I hope this is clear enough, and that anyone can help me...


Change:
echo "<td bgcolor=\"$TDcolor\">",$myrow["last"],"</td>";

To:
echo "<td></td><td>$var</td><td>",$myrow["last"],"</td><td></td>";

and change:
echo "<table>";

To:
echo "<table bgcolor=\"$TDcolor\">
and of course you will have to move the statement where you
define $TDcolor.

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: knoak | last post by:
hi there, A few days ago i posted a question how i could divide a query's result over 2 collumns. I got the following code thanks to Pedro: > echo '<table class="search_result"...
1
by: knoak | last post by:
And again Pedro saves the day! Thanks a lot man i got it to work. And also thanks a lot for your explanation, but i guess my newbie-level is to high to get it yet. Anyway thanks a load!!!! ...
0
by: Oliver Etzel - GoodnGo.COM | last post by:
Hello all, after Installing mysql I started the mysql daemon.. Then I tried to log in to my mysql database and got the message could not find mysql.sock in /tmp. In the mysql-configuration...
0
by: Stefan Hinz | last post by:
Degan, jumping in to try and solve some problems that look pretty obvious to me ... > #options for default service (mysqld2) > (mysqld2) It should be , not (mysqld2).
0
by: Dyego Souza do Carmo | last post by:
Hi, I would like to know if you could fix the bug I reported to you some days ago. The error is: "ERROR 1030: Got error 139 from table handler" after running an update command using several...
0
by: Kurt Tragant | last post by:
Hi List, wouldn't it be possible to do a fast backup of the MySQL data in this way: 1.) rsync the MySQL data (with running mysqld) 2.) Stop mysqld 3.) rsync the MySQL data again Please...
5
by: phillip.s.powell | last post by:
$sql = "SELECT IF((SHOW TABLES LIKE '$subselectTableName'), count(*), NULL) AS numRows FROM $subselectTableName"; I am trying to write a SQL statement that will tell me if a table exists or not,...
1
by: shan_rish | last post by:
Hi Group, I am new to MySql. I installed Solaris 10 on a Pentium machine. Then i came to know that MySql comes bundled with Solaris 10. So i installed MySql which came with the Solaris 10. Then i...
1
by: Dano | last post by:
OK, I'm officially frustrated. I had MySQL 4.0.18 running as a service on my WinXP laptop, along with MySQLAdministrator, and a new tool, DB Designer. Everything was working fine, and I was able...
1
by: bcochofel | last post by:
Hi, I'm using Perl CGI and HTML::Template to generate the following XML: ---------------------------------------------------------------------- <?xml version="1.0" encoding="iso-8859-1"?>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.