RE: [PHP] Query Results Question

2004-08-04 Thread Thijs Lensselink
It should be ` (back-ticks) not single quotes

SELECT `ID`, `Vacancy Role`, `Vacancy Salary`, `Vacancy Location`, `Vacancy Type`
   FROM vacancy_details
   WHERE Publish = 'Yes'

But you don't really need the back-ticks!

Thijs

Ford, Mike [LSS] wrote:
> -Original Message-
> From: Harlequin
> To: [EMAIL PROTECTED]
> Sent: 04/08/04 01:55
> Subject: [PHP] Query Results Question
> 
> I have the following query which should return just two rows:
> 
> SELECT 'ID', 'Vacancy Role', 'Vacancy Salary', 'Vacancy Location',
> 'Vacancy
> Type'
>   FROM vacancy_details
>   WHERE Publish = 'Yes'
> 
> As only two rows have Publish set to "Yes".
> 
> yet even if I execute the query through phpMyAdmin I get two rows with
> field
> headings as field values.
> --
> 
> I may be wrong, as I don't use mySQL, but shouldn't those be
> back-ticks around the column names and not single quotes?  With the
> quotes, you're just asking the database to return the literal text as
> if it were a column value.  Back ticks are used to enclose column
> names that contain non-alphanumeric characters.
> 
> Cheers!
> 
> Mike
> Any suggestions on where I'm going wrong...? I'm pretty sure my query
> syntax
> is accurate as I've used this type of query many times before and have
> even
> checked the syntax by using a query window.
> 
> --
> -
>  Michael Mason
>  Arras People
>  www.arraspeople.co.uk
> -
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Query Results Question

2004-08-04 Thread Ford, Mike [LSS]
-Original Message-
From: Harlequin
To: [EMAIL PROTECTED]
Sent: 04/08/04 01:55
Subject: [PHP] Query Results Question

I have the following query which should return just two rows:

SELECT 'ID', 'Vacancy Role', 'Vacancy Salary', 'Vacancy Location',
'Vacancy
Type'
  FROM vacancy_details
  WHERE Publish = 'Yes'

As only two rows have Publish set to "Yes".

yet even if I execute the query through phpMyAdmin I get two rows with
field
headings as field values.
--

I may be wrong, as I don't use mySQL, but shouldn't those be back-ticks around the 
column names and not single quotes?  With the quotes, you're just asking the database 
to return the literal text as if it were a column value.  Back ticks are used to 
enclose column names that contain non-alphanumeric characters.

Cheers!

Mike
Any suggestions on where I'm going wrong...? I'm pretty sure my query
syntax
is accurate as I've used this type of query many times before and have
even
checked the syntax by using a query window.

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query Results Question - Solved

2004-08-03 Thread Harlequin
I know what's going to happen though Richard. I'll dump it in their site and
it'll look terrible because they don't know how to use CSS effectively. But
hey - that's part of the fun.

Hyperlinks tomorrow though :|

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-
"Richard Bewley" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Looks good :)
>
> -
> Thank you,
> Richard Bewley
> [EMAIL PROTECTED]
>
> Equinox Systems and Development
> Website: http://www.eq-dev.com/
>
> Also, please look at our webhosting services, specializing in business web
> hosting starting from $15 per month!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Query Results Question - Solved

2004-08-03 Thread Richard Bewley
Looks good :)

-
Thank you,
Richard Bewley
[EMAIL PROTECTED]
 
Equinox Systems and Development
Website: http://www.eq-dev.com/ 
 
Also, please look at our webhosting services, specializing in business web
hosting starting from $15 per month!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query Results Question - Solved

2004-08-03 Thread Harlequin
Many thanks Richard.

I have the table presenting neatly now, thanks for all your help with this
one...!

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-
"Richard Bewley" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > I'm only selecting a few fields Richard as I want to try and drop them
> into
> an array and display in a table.
>
> > I know I'm probably going the long way around doing this but I need to
> learn
> from scratch exactly how to do it.
>
> > I appreciate your help and patience very much.
>
> > I've managed to get the query returning some results now. An array. I'm
> going to have to spend a little, well actually quite a bit, of time now
> working out how to present these in a table.
>
> > I assume a for statement will get me pointing in the right direction...?
>
> You are correct that the mysql_fetch_array will return an array which you
> can format into a table.  You can use a while loop if you would like,
which
> is probably the simplest.
>
>  $query = mysql_query("SELECT
> ID,Vacancy_Role,Vacancy_Salary,Vacancy_Location,Vacancy_Type FROM
> vacancy_details WHERE Publish='Yes'");
>
> echo "\n";
> echo "ID:Vacancy Role:Vacancy
> SalaryVacancy LocationVacancy
> Type\n";
>
> while($result = mysql_fetch_array($query)) {
> echo
>
"$result[id]$result[Vacancy_Role]$result[Vacancy_S
>
alary]$result[Vacancy_Location]$result[Vacancy_Type]<
> /tr>\n";
> }
>
> echo "";
> ?>
>
> -
> Thank you,
> Richard Bewley
> [EMAIL PROTECTED]
>
> Equinox Systems and Development
> Website: http://www.eq-dev.com/
>
> Also, please look at our webhosting services, specializing in business web
> hosting starting from $15 per month!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query Results Question

2004-08-03 Thread Harlequin
Curt.

Thanks for the pointer and yes, I should be doing that and overlooked it
this time.

It's working now as I seem to be echoing the second record in the table and
will plug away at getting the table defined.

Thanks for all your help Curt.

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-
"Curt Zirzow" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> * Thus wrote Harlequin:
> > Richard
> >
> > Thanks firstly for your help. I renamed the fields so the spaces are
> > underscores and amended your query but still receive an error:
> >
> > "not a valid MySQL result resource "
> >
> > Still tinkering though...
>
> All this tinkering and database schema's are simply the long way
> around things.  Just use mysql_error() after you query.
>
> mysql_query($sql) or die(mysql_error());
>
> You'll know exactly whats wrong.
>
>
> Curt
> -- 
> First, let me assure you that this is not one of those shady pyramid
schemes
> you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Query Results Question

2004-08-03 Thread Richard Bewley
> I'm only selecting a few fields Richard as I want to try and drop them
into
an array and display in a table.

> I know I'm probably going the long way around doing this but I need to
learn
from scratch exactly how to do it.

> I appreciate your help and patience very much.

> I've managed to get the query returning some results now. An array. I'm
going to have to spend a little, well actually quite a bit, of time now
working out how to present these in a table.

> I assume a for statement will get me pointing in the right direction...?

You are correct that the mysql_fetch_array will return an array which you
can format into a table.  You can use a while loop if you would like, which
is probably the simplest.

\n";
echo "ID:Vacancy Role:Vacancy
SalaryVacancy LocationVacancy
Type\n";

while($result = mysql_fetch_array($query)) {
echo
"$result[id]$result[Vacancy_Role]$result[Vacancy_S
alary]$result[Vacancy_Location]$result[Vacancy_Type]<
/tr>\n";
}

echo "";
?>

-
Thank you,
Richard Bewley
[EMAIL PROTECTED]
 
Equinox Systems and Development
Website: http://www.eq-dev.com/ 
 
Also, please look at our webhosting services, specializing in business web
hosting starting from $15 per month!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query Results Question

2004-08-03 Thread Harlequin
I'm only selecting a few fields Richard as I want to try and drop them into
an array and display in a table.

I know I'm probably going the long way around doing this but I need to learn
from scratch exactly how to do it.

I appreciate your help and patience very much.

I've managed to get the query returning some results now. An array. I'm
going to have to spend a little, well actually quite a bit, of time now
working out how to present these in a table.

I assume a for statement will get me pointing in the right direction...?

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-
"Richard Bewley" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Richard.
>
> > Public. I changed it to "Publish".
>
> > But if I use a query window to interrogate the database I still get just
> two
> rows using the following query with field names not values for the row
cell
> contents:
>
> > SELECT
> 'ID','Vacancy_Role','Vacancy_Salary','Vacancy_Location','Vacancy_Type'
>   FROM vacancy_details WHERE Publish='Yes'
>
> Take out the quotes.  Make your query say:
> SELECT
> ID,Vacancy_Role,Vacancy_Salary,Vacancy_Location,Vacancy_Type FROM
> vacancy_details WHERE Publish='Yes';
>
> Also, if you are selecting every field, then why not do a SELECT *?
>
> -
> Thank you,
> Richard Bewley
> [EMAIL PROTECTED]
>
> Equinox Systems and Development
> Website: http://www.eq-dev.com/
>
> Also, please look at our webhosting services, specializing in business web
> hosting starting from $15 per month!
>
>
>
> -- 
> -
>  Michael Mason
>  Arras People
>  www.arraspeople.co.uk
> -
> "Richard Bewley" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > > Richard
> >
> > > Thanks firstly for your help. I renamed the fields so the spaces are
> > underscores and amended your query but still receive an error:
> >
> > > "not a valid MySQL result resource "
> >
> > > Still tinkering though...
> >
> > Can you paste me
> > a.) Your database structure
> > b.) The exact query you are using
> >
> > Also, you may want to do $query = mysql_query("SELECT * from
> > vacancy_details") or die(mysql_error());
> >
> > I don't care about the first part of that, but try putting in the
> > mysql_error() in the form I used above, and see if it gives you any
other
> > information.
> >
> > -
> > Thank you,
> > Richard Bewley
> > [EMAIL PROTECTED]
> >
> > Equinox Systems and Development
> > Website: http://www.eq-dev.com/
> >
> > Also, please look at our webhosting services, specializing in business
web
> > hosting starting from $15 per month!
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query Results Question

2004-08-03 Thread Curt Zirzow
* Thus wrote Harlequin:
> Richard
> 
> Thanks firstly for your help. I renamed the fields so the spaces are
> underscores and amended your query but still receive an error:
> 
> "not a valid MySQL result resource "
> 
> Still tinkering though...

All this tinkering and database schema's are simply the long way
around things.  Just use mysql_error() after you query.

mysql_query($sql) or die(mysql_error());

You'll know exactly whats wrong.


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Query Results Question

2004-08-03 Thread Richard Bewley
> Richard.

> Public. I changed it to "Publish".

> But if I use a query window to interrogate the database I still get just
two
rows using the following query with field names not values for the row cell
contents:

> SELECT
'ID','Vacancy_Role','Vacancy_Salary','Vacancy_Location','Vacancy_Type'
  FROM vacancy_details WHERE Publish='Yes'

Take out the quotes.  Make your query say:
SELECT
ID,Vacancy_Role,Vacancy_Salary,Vacancy_Location,Vacancy_Type FROM
vacancy_details WHERE Publish='Yes';

Also, if you are selecting every field, then why not do a SELECT *?

-
Thank you,
Richard Bewley
[EMAIL PROTECTED]
 
Equinox Systems and Development
Website: http://www.eq-dev.com/ 
 
Also, please look at our webhosting services, specializing in business web
hosting starting from $15 per month!
 


-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-
"Richard Bewley" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Richard
>
> > Thanks firstly for your help. I renamed the fields so the spaces are
> underscores and amended your query but still receive an error:
>
> > "not a valid MySQL result resource "
>
> > Still tinkering though...
>
> Can you paste me
> a.) Your database structure
> b.) The exact query you are using
>
> Also, you may want to do $query = mysql_query("SELECT * from
> vacancy_details") or die(mysql_error());
>
> I don't care about the first part of that, but try putting in the
> mysql_error() in the form I used above, and see if it gives you any other
> information.
>
> -
> Thank you,
> Richard Bewley
> [EMAIL PROTECTED]
>
> Equinox Systems and Development
> Website: http://www.eq-dev.com/
>
> Also, please look at our webhosting services, specializing in business web
> hosting starting from $15 per month!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query Results Question

2004-08-03 Thread Harlequin
Richard.

Public. I changed it to "Publish".

But if I use a query window to interrogate the database I still get just two
rows using the following query with field names not values for the row cell
contents:

SELECT
'ID','Vacancy_Role','Vacancy_Salary','Vacancy_Location','Vacancy_Type'
  FROM vacancy_details WHERE Publish='Yes'

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-
"Richard Bewley" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Richard
>
> > Thanks firstly for your help. I renamed the fields so the spaces are
> underscores and amended your query but still receive an error:
>
> > "not a valid MySQL result resource "
>
> > Still tinkering though...
>
> Can you paste me
> a.) Your database structure
> b.) The exact query you are using
>
> Also, you may want to do $query = mysql_query("SELECT * from
> vacancy_details") or die(mysql_error());
>
> I don't care about the first part of that, but try putting in the
> mysql_error() in the form I used above, and see if it gives you any other
> information.
>
> -
> Thank you,
> Richard Bewley
> [EMAIL PROTECTED]
>
> Equinox Systems and Development
> Website: http://www.eq-dev.com/
>
> Also, please look at our webhosting services, specializing in business web
> hosting starting from $15 per month!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Query Results Question

2004-08-03 Thread Richard Bewley
> Richard

> Thanks firstly for your help. I renamed the fields so the spaces are
underscores and amended your query but still receive an error:

> "not a valid MySQL result resource "

> Still tinkering though...

Can you paste me 
a.) Your database structure
b.) The exact query you are using

Also, you may want to do $query = mysql_query("SELECT * from
vacancy_details") or die(mysql_error());

I don't care about the first part of that, but try putting in the
mysql_error() in the form I used above, and see if it gives you any other
information.

-
Thank you,
Richard Bewley
[EMAIL PROTECTED]
 
Equinox Systems and Development
Website: http://www.eq-dev.com/ 
 
Also, please look at our webhosting services, specializing in business web
hosting starting from $15 per month!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query Results Question

2004-08-03 Thread Harlequin
Richard

Thanks firstly for your help. I renamed the fields so the spaces are
underscores and amended your query but still receive an error:

"not a valid MySQL result resource "

Still tinkering though...

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-
"Richard Bewley" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> Take the spaces out of your field names, and then use this:
>
>  $query = mysql_query("SELECT
> id,vacancy_role,vacancy_salary,vacancy_location,vacancy_type FROM
> vacancy_details WHERE Public='yes'");
>
> while($result = mysql_fetch_array($query)) {
> echo "$result[id] - $result[vacancy_role]";
> }
> ?>
>
> -
> Thank you,
> Richard Bewley
> [EMAIL PROTECTED]
>
> Equinox Systems and Development
> Website: http://www.eq-dev.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query Results Question

2004-08-03 Thread Curt Zirzow
* Thus wrote Harlequin:
> I have the following query which should return just two rows:
> 
> SELECT 'ID', 'Vacancy Role', 'Vacancy Salary', 'Vacancy Location', 'Vacancy
> Type'
>   FROM vacancy_details
>   WHERE Publish = 'Yes'
> 
> As only two rows have Publish set to "Yes".
> 
> yet even if I execute the query through phpMyAdmin I get two rows with field
> headings as field values.
> 
> Any suggestions on where I'm going wrong...? I'm pretty sure my query syntax
> is accurate as I've used this type of query many times before and have even
> checked the syntax by using a query window.

mysql_error()


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Query Results Question

2004-08-03 Thread Richard Bewley
Hi,

Take the spaces out of your field names, and then use this:



-
Thank you,
Richard Bewley
[EMAIL PROTECTED]
 
Equinox Systems and Development
Website: http://www.eq-dev.com/ 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Query Results Question

2004-08-03 Thread Harlequin
I have the following query which should return just two rows:

SELECT 'ID', 'Vacancy Role', 'Vacancy Salary', 'Vacancy Location', 'Vacancy
Type'
  FROM vacancy_details
  WHERE Publish = 'Yes'

As only two rows have Publish set to "Yes".

yet even if I execute the query through phpMyAdmin I get two rows with field
headings as field values.

Any suggestions on where I'm going wrong...? I'm pretty sure my query syntax
is accurate as I've used this type of query many times before and have even
checked the syntax by using a query window.

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php