473,698 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql query changing font color

2 New Member
I have a table called oth_recruitment

In the table are 10 fields. Each field will have only 1 entry: Open or Closed.

On my website, I have the following code:

Expand|Select|Wrap|Line Numbers
  1.        <?php
  2.  
  3.     include 'admin/config.php';
  4.     include 'admin/opendb.php';
  5.  
  6.     $query  = "SELECT druid FROM oth_recruitment";
  7.     $result = mysql_query($query);
  8.  
  9.         if ($result == 'Open')
  10.         {
  11.             echo "<font color=\"#00FF00\">Open</font>";
  12.         } else
  13.         {
  14.             echo "<font color=\"#FF0000\">Closed</font>";
  15.         }
  16.     ?> 
When the query runs, and it finds "Open" in the field druid, I want word "Open" to show on the webpage, and I want it to be green. When the word "Closed" is found, I want the word "Closed" to show in red. I'm doing something wrong here, obviously, because no matter what I change the value to in the table, it always displays "Closed".
Feb 10 '08 #1
3 8294
ronverdonk
4,258 Recognized Expert Specialist
$query only contains the handle to your result set. You have to read or browse through the result set. Since you have 1 column result only you could use mysql_result, but I will show how to read an entire row and how to address the individual columns via an associated (row) array, e.g.
[php]
while ($row = mysql_fetch_ass oc($query)) {
if ($row['druid'] == 'Open')
echo "<font color=\"#00FF00 \">Open</font>";
else
echo "<font color=\"#FF0000 \">Closed</font>";
//
// process other columns in the row
//
}
[/php]

Ronald
Feb 10 '08 #2
petrakid
2 New Member
thanks, I had to change $query to $result - but other than that, it works perfectly.
Feb 11 '08 #3
ronverdonk
4,258 Recognized Expert Specialist
Glad it does. See ya.

Ronald
Feb 11 '08 #4

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

Similar topics

6
1037
by: phpguy | last post by:
Hi people im making an online booking system as a final year project in my university i get this error which i cannot seem to fix ! Here is my code: PART 1 ********************************************************* #connect to sql $connect=@mysql_connect("localhost","root","") or die("Err:Conn");
1
1917
by: no-email | last post by:
Hi, Below is a bunch of programs to demo the basic sql commands. Suggestions on possible improvements will be appreciated. <?php // mysql-demo.php include ("connectdb.php"); $setSQL="SET FOREIGN_KEY_CHECKS=0"; $dropSQL="DROP TABLE IF EXISTS temp";
1
3211
by: automation | last post by:
There is a truncation error of my Web Application using PHP 5.04, MySQL 5.022, and HTML(IE 6.0) whereby the MySQL Result Set is being truncated on the HTML page, even though the CSS Div Page Height is set to 'auto' which is supposed to grow the HTML page height to the size necessary to display the contents within the page. The query count is correct, but the MySQL Result Set is being truncated on the html page. This happens for MySQL Results on...
3
3107
by: Auddog | last post by:
I have the following query that works in mysql: select id, order_no, price, count(item_no), sum(price) from production WHERE item_no = '27714' group by item_no; When I setup my query in php, I use: $query2 = "SELECT id, order_no, price, count(item_no) as count from production where item_no = '27714";
7
2502
by: dongletran06 | last post by:
Hi, Please help me find out what wrong with my codes in inputting from my form to mysql database using drop down menu. Below is the codes I used. Only the drop down is not working but the "input text" are successfully adding data to mysql. I just try first using the month as drop down. The month data type I used in mysql database is varchar. Im new in PHP please help me. Thanks <?php /* Created on: 10/12/2006 */ ?> <html> <body> <?php...
3
1284
by: alisonjane | last post by:
Hi, First, I apologize, but I am a biologist not a programmer! Second, I made a web-based scheduling system in mysql. It works great but I need to generate a report by specifying a range of dates on another webpage. I made the query to give me the columns I want, but I don't know how to create the front-end page on which I would like select the range of dates to show me. Here is the query that returns ALL records: <? // script to...
11
4278
by: stantron | last post by:
Setup: I only have one database with one table in it. The first page has a form that adds a record (w/ 6 fields in it) to the mySQL database's lone table via PHP. This works fine. I also have a PHP table that displays all records in my database on this same page. This too works fine. I have my table set up so that there is a 7th field, called "rid" to act as a "record id" or unique identifying field. This is primary and auto-incremented. There...
39
5856
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f ISO-8859-1 -t UTF-8 mydb.sql mydb_utf8.sql mysqlCREATE DATABASE mydb_utf8 CHARACTER SET utf8 COLLATE utf8_general_ci;
70
5382
mideastgirl
by: mideastgirl | last post by:
I have recently been working on a website for an honors association, and have a lot of difficulty but have found help from those on this site. I would like to see if I can get some more help on a different issue than what I was initially having. I am working on storing data collected from a form on my website. I would like the information to be stored into MySQL once entered by users. I have googled this question and have tried multiple...
0
8604
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
9028
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
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
7728
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4369
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
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
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.