Hello
i have some php code where i echo out somethings from a database into a table.
What i need is some php code to show something else than what i am getting from the database.
Here is an example:
I echo out a field like this:
[PHP]<?php
$sql = "SELECT * FROM QHEADER WHERE [QuoteID] = '" . $QuoteToFind . "'" ;
$qheader = ads_exec($conn,$sql);
while (ads_fetch_row($qheader))
{
$RJustQuoteToFind = ads_result($qheader,"Quote Nbr");
echo "<td bgcolor='#EFEFEF' align='left' valign='top' class='boldtext' style='border-style: none; padding-top: 3px;'>" . ads_result($qheader,"VGrove") . "</td>";
}
?> [/PHP]
Now this field shows up in the table as: "Y"
What i need it to show is: "Yes"
Is it possible to do something like:
if FieldTocheck = 'Y' then FieldToPrint = "Yes"
Any input is welcome.............?????
10 2196
Hello
i have some php code where i echo out somethings from a database into a table.
What i need is some php code to show something else than what i am getting from the database.
Here is an example:
I echo out a field like this:
[PHP]<?php
$sql = "SELECT * FROM QHEADER WHERE [QuoteID] = '" . $QuoteToFind . "'" ;
$qheader = ads_exec($conn,$sql);
while (ads_fetch_row($qheader))
{
$RJustQuoteToFind = ads_result($qheader,"Quote Nbr");
echo "<td bgcolor='#EFEFEF' align='left' valign='top' class='boldtext' style='border-style: none; padding-top: 3px;'>" . ads_result($qheader,"VGrove") . "</td>";
}
?> [/PHP]
Now this field shows up in the table as: "Y"
What i need it to show is: "Yes"
Is it possible to do something like:
if FieldTocheck = 'Y' then FieldToPrint = "Yes"
Any input is welcome.............?????
Hi there,
I'm assuming that this portion:
[PHP]ads_result($qheader,"VGrove") [/PHP]
is what is echoing "Y". If this is the case, you could alter your code as such:
[PHP]$varEcho=(ads_result($qheader,"VGrove") =="Y")?"Yes":"No";[/PHP]
The above code creates a variable based on the ads_result() function. If that function call results in a "Y", the $varEcho is set to "Yes", else sets it to "No". It's called a ternary. You could then echo out $varEcho instead of the ads_result()
Hope that helps.
Greg
Great! Just what i needed. It works perfect.
Tanks a lot..... ;o)
Could you perhaps help me something else also..............?
I have another field i'm getting from a database i wont to change into something else. It is date/time field.
Ex:
[PHP]<?php
$sql = "SELECT * FROM QHEADER WHERE [QuoteID] = '" . $QuoteToFind . "'" ;
$qheader = ads_exec($conn,$sql);
while (ads_fetch_row($qheader))
{
$RJustQuoteToFind = ads_result($qheader,"Quote Nbr");
echo ads_result($qheader,"LastQuoteDateTime");
}
?>[/PHP]
it comes in a predefined date/format, and I want to change this, but how......????
Could you perhaps help me something else also..............?
I have another field i'm getting from a database i wont to change into something else. It is date/time field.
Ex:
[PHP]<?php
$sql = "SELECT * FROM QHEADER WHERE [QuoteID] = '" . $QuoteToFind . "'" ;
$qheader = ads_exec($conn,$sql);
while (ads_fetch_row($qheader))
{
$RJustQuoteToFind = ads_result($qheader,"Quote Nbr");
echo ads_result($qheader,"LastQuoteDateTime");
}
?>[/PHP]
it comes in a predefined date/format, and I want to change this, but how......????
Hi,
I think you can do that with the php date() function.
Cheers
nathj
Tried it, but now i get both the current date and time + the predefined date and time format from the database:
[PHP]<?php
$sql = "SELECT * FROM QHEADER WHERE [QuoteID] = '" . $QuoteToFind . "'" ;
$qheader = ads_exec($conn,$sql);
while (ads_fetch_row($qheader))
{
$RJustQuoteToFind = ads_result($qheader,"Quote Nbr");
//$NewLastQuoteDateTime = ads_result($qheader,"LastQuoteDateTime");
echo (date("d m Y G:i" . ads_result($qheader,"LastQuoteDateTime")));
}
?>[/PHP]
???????????
Hi,
[PHP]echo (date("d m Y G:i" . ads_result($qheader,"LastQuoteDateTime")));[/PHP]
should be
[PHP]echo (date("d m Y G:i", ads_result($qheader,"LastQuoteDateTime")));[/PHP]
note the comma rather than the period - the period is concatenating the input into the function rather than allowing the date to be formatted to be passed as a second parameter.
Hope that helps..
Regards Purple
If put in a comma instead i get this error message:
A non well formed numeric value encountered in C:\Inetpub\wwwroot\quotetest.php on line 739
1970 01 01 1:33
it should be like this
echo (date("d m Y G:i", strtotime(ads_result($qheader,"LastQuoteDateTime") )));
use timestamp insted of date
That helped.
Thanks a lot ;o)
it should be like this
echo (date("d m Y G:i", strtotime(ads_result($qheader,"LastQuoteDateTime") )));
use timestamp insted of date
Hi,
sdhariwal's suggestion is one approach, may I suggest a better one may be to store the LastQuoteDateTime on the database as a datetime field and then you will not need the strtotime converstion.
Regards Purple
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Michael Flanagan |
last post by:
Of course "echo" is working, but I've got a case where php doesn't
seem to be sending out the result of an "echo." I'm probably doing
something wrong, but I can't see it.
I've got the following...
|
by: Neil |
last post by:
Hello,
I do hope some kind soul can help me with what I thought was not going
to be difficult, but for this newbie it's a bit harder than I thought.
Here's what I'm trying to do.....
I can...
|
by: windandwaves |
last post by:
Hi Folk
My question is:
echo all the time vs echo at the end - what is faster
Let me explain
I used to write pages like this:
echo "<head> ";
|
by: Swann |
last post by:
Hello,
I have a form linked to a table with a button that deletes the
currently selected record with a VBA sub. When I perform the delete
query, the data in the fields are replaced with #DELETE,...
|
by: weirdstuff |
last post by:
Hi. I have this simple code:
===========================================
->Database query here
(.. some code)
$row=mysql_fetch_array($res);
(...)
|
by: Jon Slaughter |
last post by:
I have some code that loads up some php/html files and does a few things to
them and ultimately returns an html file with some php code in it. I then
pass that file onto the user by using echo. Of...
|
by: L. Berger |
last post by:
Hi,
I am working on an HTML template which has a lot of html tags, with
PHP data shown in the middle of these tags -- you know, the usual.
Currently, I have HTML as is, and many many "echo...
|
by: Twayne |
last post by:
Hi,
Irrelevant question time, probably:
Is there any advantage/reason to use one format over the other for the
following two types of echo statements?
1. echo "error is " . $error;
2. ...
|
by: Request-1 |
last post by:
hi folks,
html coder here, new and terrified * of php!!
aaaaaa!
i'm trying to bury a JS script to rotate a photo, in a page i converted from
html to php.
the conversion went well, it was to...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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: 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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |