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: -
<?php
-
-
include 'admin/config.php';
-
include 'admin/opendb.php';
-
-
$query = "SELECT druid FROM oth_recruitment";
-
$result = mysql_query($query);
-
-
if ($result == 'Open')
-
{
-
echo "<font color=\"#00FF00\">Open</font>";
-
} else
-
{
-
echo "<font color=\"#FF0000\">Closed</font>";
-
}
-
?>
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".
3 8294
$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
thanks, I had to change $query to $result - but other than that, it works perfectly.
Glad it does. See ya.
Ronald
Sign in to post your reply or Sign up for a free account.
Similar topics |
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");
|
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";
|
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...
|
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";
|
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...
| |
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...
|
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...
|
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;
|
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...
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |