473,603 Members | 2,652 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 1726
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
1659
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
1439
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 "socket=/tmp/mysql.sock". That doesn´t work.
0
2883
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
1210
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
2188
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
3933
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 elegant MySQL 4.1+ statement to detect if a table exists or not?
1
1422
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 installed in the Pentium machine. So i downloaded the mysql-max-5.0.21-solaris10-i386.pkg.gz and...
1
6606
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 Control Panel. I re-installed MySQL 5.0. I started it as a service, and I was able to
1
3331
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 xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://cochofel.sytes.net ~bcochofel/iweb/files/RR.xsd">
0
7997
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7929
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8419
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8065
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8274
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5441
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3906
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3954
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.