473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

echo out something else than what is in the database

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.............?????
Sep 6 '07 #1
10 2196
gregerly
192 Expert 100+
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
Sep 6 '07 #2
Great! Just what i needed. It works perfect.

Tanks a lot..... ;o)
Sep 6 '07 #3
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......????
Sep 6 '07 #4
nathj
938 Expert 512MB
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
Sep 6 '07 #5
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]

???????????
Sep 7 '07 #6
Purple
404 Expert 256MB
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
Sep 7 '07 #7
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
Sep 7 '07 #8
it should be like this

echo (date("d m Y G:i", strtotime(ads_result($qheader,"LastQuoteDateTime") )));

use timestamp insted of date
Sep 7 '07 #9
That helped.

Thanks a lot ;o)
Sep 7 '07 #10
Purple
404 Expert 256MB
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
Sep 7 '07 #11

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

Similar topics

3
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...
7
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...
9
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> ";
2
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,...
4
by: weirdstuff | last post by:
Hi. I have this simple code: =========================================== ->Database query here (.. some code) $row=mysql_fetch_array($res); (...)
25
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...
2
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...
11
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. ...
32
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
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...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
isladogs
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...

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.