473,543 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_arr ay($result2)) {
$TDcolor = ($sideoffset++ % 2) ? $side1 : $side2;
if (!$column) echo "<tr >";
echo "<td bgcolor=\"$TDco lor\">",$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 1721
knoak wrote:
Hi there,

I have the following code:

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

echo "<table>";
$column = 0;
while ($myrow = mysql_fetch_arr ay($result2)) {
$TDcolor = ($sideoffset++ % 2) ? $side1 : $side2;
if (!$column) echo "<tr >";
echo "<td bgcolor=\"$TDco lor\">",$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=\"$TDco lor\">",$myrow["last"],"</td>";

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

and change:
echo "<table>";

To:
echo "<table bgcolor=\"$TDco lor\">
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
1655
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" summary="search result">'; > $column = 0; > while ($row = mysql_fetch_array($result)) {
1
615
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!!!! (Fixed a minor mistake as wel, if ($column) echo "<td></td></tr>"; echo "</table>";
0
1435
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 file /etc/my.cnf (in my redhat system 8.0) I changed the place for the socket file from "socket=/var/lib/mysql/mysql.sock" to...
0
2878
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
1207
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 blobs. Now I am using mySql 4.0.15 and Linux. If you try to do the same with mySql 4.0.14, the record that is updated is simple deleted.
0
2184
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 answer. I have found a similiar post in the year 2001, but no
5
3930
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, this is because PHP will throw Fatal Errors and halt all programming if the table does not exist that I attempt to query. How do you write an...
1
1418
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 checked the version of the MySql i installed using mysqlcheck -V and the version shown was 4.0.24. I wanted the latest version of MySql (5.0) to be...
1
6602
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 to do a good test. Then I wanted to upgrade to MySQL 5.0. I completely uninstalled everything with the "Add/Remove Programs" utility in the...
1
3328
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"?> <?xml-stylesheet type="text/xml" href="RR.xsl"?> <!-- $Id: template.xml,v 1.5 2006/12/11 11:13:30 bcochofel Exp $ --> <RR...
0
7412
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7355
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7594
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7697
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5889
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4899
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3394
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1830
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.