Re: [PHP-DB] Paginatating PHP

2006-12-21 Thread chris smith

On 12/21/06, Ondrej Kohout <[EMAIL PROTECTED]> wrote:

It's better to use SQL_CALC_FOUND_ROWS and information function
FOUND_ROWS().


Has nothing to do with the problem.

"its simply showing the else condition which does not have NEXT
or PREVIOUS hyperlinked."

Try "OKi98's" suggestion, it will most likely fix the problem for you.

--
Postgresql & php tutorials
http://www.designmagick.com/

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



RE: [PHP-DB] Login script help

2006-12-21 Thread Miles Thompson


When user has authenticated successfully, start a session with an 
authentication key - almost anything you want.


After that, any page you want to protect you just put one line at the top 
to check for the presence of this value; redirect to login page if it's not 
there.


Regards - Miles


At 11:19 PM 12/21/2006, Haig Dedeyan wrote:


Thanks.

If I do it that way, can't someone get into the index page if they link
directly to it without having to log in?



-Original Message-
From: Bastien Koert [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 21, 2006 7:36 PM
To: Haig Dedeyan; php-db@lists.php.net
Subject: RE: [PHP-DB] Login script help

why not just create a simple single logon page and not include
itthen on
sucessful login, redirect the user to the index page?

bastien


>From: "Haig Dedeyan" <[EMAIL PROTECTED]>
>To: 
>Subject: [PHP-DB] Login script help
>Date: Thu, 21 Dec 2006 16:36:11 -0500
>
>Hi everyone,
>
>My 1st attempt at creating a login script isn't going so good, so
>hopefully someone can help me out.
>
>The login script itself works fine but when I include it into a web
>page, the login.php script shows up but the entire index.html page also
>shows up.
>
>I just want people to log in before they get to index.html.
>
>Index.html starts off with:
>
>session_start();
>include("database.php");
>include("login.php");
>?>
>
>I'm using php5.
>
>Thanks
>
>Haig
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

_
Off to school, going on a trip, or moving? Windows Live (MSN) Messenger
lets
you stay in touch with friends and family wherever you go. Click here to

find out how to sign up!  http://www.telusmobility.com/msnxbox/

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



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.15.26/594 - Release Date: 12/20/2006

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



RE: [PHP-DB] Login script help

2006-12-21 Thread Haig Dedeyan
Thanks.

If I do it that way, can't someone get into the index page if they link
directly to it without having to log in?



-Original Message-
From: Bastien Koert [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 21, 2006 7:36 PM
To: Haig Dedeyan; php-db@lists.php.net
Subject: RE: [PHP-DB] Login script help

why not just create a simple single logon page and not include
itthen on 
sucessful login, redirect the user to the index page?

bastien


>From: "Haig Dedeyan" <[EMAIL PROTECTED]>
>To: 
>Subject: [PHP-DB] Login script help
>Date: Thu, 21 Dec 2006 16:36:11 -0500
>
>Hi everyone,
>
>My 1st attempt at creating a login script isn't going so good, so
>hopefully someone can help me out.
>
>The login script itself works fine but when I include it into a web
>page, the login.php script shows up but the entire index.html page also
>shows up.
>
>I just want people to log in before they get to index.html.
>
>Index.html starts off with:
>
>session_start();
>include("database.php");
>include("login.php");
>?>
>
>I'm using php5.
>
>Thanks
>
>Haig
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

_
Off to school, going on a trip, or moving? Windows Live (MSN) Messenger
lets 
you stay in touch with friends and family wherever you go. Click here to

find out how to sign up!  http://www.telusmobility.com/msnxbox/

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



RE: [PHP-DB] Login script help

2006-12-21 Thread Bastien Koert
why not just create a simple single logon page and not include itthen on 
sucessful login, redirect the user to the index page?


bastien



From: "Haig Dedeyan" <[EMAIL PROTECTED]>
To: 
Subject: [PHP-DB] Login script help
Date: Thu, 21 Dec 2006 16:36:11 -0500

Hi everyone,

My 1st attempt at creating a login script isn't going so good, so
hopefully someone can help me out.

The login script itself works fine but when I include it into a web
page, the login.php script shows up but the entire index.html page also
shows up.

I just want people to log in before they get to index.html.

Index.html starts off with:



I'm using php5.

Thanks

Haig

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



_
Off to school, going on a trip, or moving? Windows Live (MSN) Messenger lets 
you stay in touch with friends and family wherever you go. Click here to 
find out how to sign up!  http://www.telusmobility.com/msnxbox/


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



[PHP-DB] Login script help

2006-12-21 Thread Haig Dedeyan
Hi everyone,

My 1st attempt at creating a login script isn't going so good, so
hopefully someone can help me out.

The login script itself works fine but when I include it into a web
page, the login.php script shows up but the entire index.html page also
shows up.

I just want people to log in before they get to index.html.

Index.html starts off with:



I'm using php5.

Thanks 

Haig

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



Re: [PHP-DB] search result error message

2006-12-21 Thread Niel Archer
Hi,

there's no 'logic' error at all that I can see.  It's more a design
error as it doesn't do the job the way that you describe it at all. 
  What actually happens is that the starting HTML (heading and table
start)  is output before the database is even contacted, so there's no
way for you to take the table back if you don't receive any relevant
hits.

try something more like this:


Your favorites search resultYou are here:  index.htm Home  >
Your favorites

Sub-category search result 



Shop name



$shopname
";
$i++;
}

?> index.htm < Back to search  


} else {

echo "

  The search criteria you entered did not generate any
result,  index.htm please try again .
";

}

You'll probably need to polish this some, because I quickly cut/pasted
it before I go down the pub.

Niel

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



Re: [PHP-DB] search result error message

2006-12-21 Thread tg-php
Sorry, don't have time to test and noodle through why yours may or may not be 
working, but I see some differences in how you're doing it and how we tend to 
do it here.

After doing the connection and database selection, this is how we handle stuff 
(simplified):

$query = "select * from sometable";

$result = mysql_query($query);

$count = mysql_affected_rows();

while ($row = mysql_fetch_assoc($result)) {
  // do some stuff
  $address = $row['address'];  // example of how to get/use data returned
}

Nothing inside the while construct should execute if you get zero results.

You really don't need to use the mysql_affected_rows() either unless you want 
to test for zero results and display an error message, like I believe you 
wanted to do.

-TG

= = = Original message = = =

Hi,

The below mentioned code works fine. Connects to the database, fetches the
result, and displays neatly in a table. If there is no data then it jumps to
the if condition and displays the error message. BUT if the 'if' condition
is running and no data is present the Table headings and the bottm of empty
table is still displayed above the error message. Can you please check and
share with me as in where exactly the logic is wrong.

-- -- Code --- 

Your favorites search resultYou are here:  index.htm Home  >
Your favorites~~

~~~Sub-category search result~~
~
~
Shop name



$shopname
";
$i++;


?> index.htm < Back to search  



  The search criteria you entered did not generate any
result,  index.htm please try again .
~";

?>
~
.
-- 
View this message in context: 
http://www.nabble.com/search-result-error-message-tf2867391.html#a8014018
Sent from the Php - Database mailing list archive at Nabble.com.



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP-DB] search result error message

2006-12-21 Thread Chris Carter

Hi,

The below mentioned code works fine. Connects to the database, fetches the
result, and displays neatly in a table. If there is no data then it jumps to
the if condition and displays the error message. BUT if the 'if' condition
is running and no data is present the Table headings and the bottm of empty
table is still displayed above the error message. Can you please check and
share with me as in where exactly the logic is wrong.

-- -- Code --- 

Your favorites search resultYou are here:  index.htm Home  >
Your favorites

Sub-category search result 



Shop name



$shopname
";
$i++;
}

?> index.htm < Back to search  



  The search criteria you entered did not generate any
result,  index.htm please try again .
";

}?>

.
-- 
View this message in context: 
http://www.nabble.com/search-result-error-message-tf2867391.html#a8014018
Sent from the Php - Database mailing list archive at Nabble.com.

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



Re: [PHP-DB] MSSQL Server

2006-12-21 Thread tg-php
I had some issues a couple years ago connecting to the MS SQL Server where I 
was employed at the time.

I was probably  just doing something wrong, but what I ended up using that 
worked for me was using the ADODB database abstraction layer.  Helped me 
connect to MS SQL , Oracle and some other random data sources I had to from 
time to time.

http://adodb.sourceforge.net/

Sorry I don't have time to look for good examples, but maybe the documentation 
will help out some and get you on the right path.

-TG

= = = Original message = = =

I cannot connect to my MSSQL server.

I use the following connection string:

php:
--
$connection = mssql_connect ('server','user',
'password') or die ('server connection failed');

$database = mssql_select_db ("database_name"
, $connection) or die ('DB selection failed');
?>
--



The MSSQL server is setup to use Windows and Server Authentication. I have a
*local* dummy account setup for testing and when using this account I can
connect with no problems, but when I try and use my domain/network account I
cannot connect at all. (my network account has full access to the server,
database and tables) I can even login to the SQL Management Studio using
Windows Authentication and my network account, but still cannot connect
using PHP.

Any ideas?


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-DB] Order By [blank]

2006-12-21 Thread Kevin Murphy
I haven't tried the union method the query i have is actually  
quite a bit more complicated than just a simple select * from a  
single table, so while it may work, it might take a while to write it  
if I am reading all this right.


But yes, the ifnull() method works just fine. Thanks for your help.

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


On Dec 21, 2006, at 10:12 AM, <[EMAIL PROTECTED]> [EMAIL PROTECTED]> wrote:


You shouldn't have to do that. the IFNULL() handles all that.  If  
the item is null, it returns an emptry string ''.  If it's blank/ 
empty, it returns an empty string. This is just used for the  
comparison = ''.  This determines if it's empty or null and if so,  
returns 'ZZ', if not, it returns the  
unaltered value.  And again, this returned value is only used for  
the sorting.  The values you get from "select *" will be unaltered.


Is this more efficient than doing two SELECTs and a UNION?  I have  
no idea.  But I like to keep things as clean as possible and in my  
reading and experience, letting the server handle an IFNULL()  
function should be quicker than doing four value checks (is null,  
is not null, = '' and != ''), collecting the values of two SELECTS  
then checking to see if it's able to UNION them together.


Also, less code/typing typically means less chance of typos.


BTW: In my example, realistically you could probably shorten the  
morphed value to "ZZ" or "ZZZ" unless you think you'll values in  
your database that will start with "" and get bumped lower on  
the sorting.


-TG

= = = Original message = = =

In case the blank is a null or is really a blank:

select * from blank where tchar_10 is not null and tchar_10 != ''
union all
select * from blank where tchar_10 is null or tchar_10 = ''

- Dave

On 12/21/06, [EMAIL PROTECTED] [EMAIL PROTECTED]>

wrote:


This is a little weird looking, but should do the job.  Remember that
items in your 'order by' can be manipulated conditionally.  In  
this case,
I'm looking for NULL as well as '' (empty) and changing it to  
something that
should come after all your normal alphabetical values, but it  
doesn't change

what appears in your results.  This only affects the sorting:

select * from sometable order by if(ifnull(somecolumn, '') = '',
'', somecolumn)

Hope that helps.

-TG

= = = Original message = = =

I have this column in mysql:

A
F
D
[ empty ]
A
C

If I do an order by on that column, this is what I get:

[ empty ]
A
A
C
D
F

What I would like is this:

A
A
C
D
F
[ empty ]

Is there any way to achieve this in a single MySQL query? Using DESC
in this case doesn't work, because while it puts the empty row in the
last place, it does the rest as well. I could also do 2 queries where
it calls it once in order WHERE  !='', and then do another query to
get the empty ones, but that seems a bit cumbersome.

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326




--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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





[PHP-DB] MSSQL Server

2006-12-21 Thread Dan Shirah

I cannot connect to my MSSQL server.

I use the following connection string:

php:
--
$connection = mssql_connect ('server','user',
'password') or die ('server connection failed');

$database = mssql_select_db ("database_name"
, $connection) or die ('DB selection failed');
?>
--



The MSSQL server is setup to use Windows and Server Authentication. I have a
*local* dummy account setup for testing and when using this account I can
connect with no problems, but when I try and use my domain/network account I
cannot connect at all. (my network account has full access to the server,
database and tables) I can even login to the SQL Management Studio using
Windows Authentication and my network account, but still cannot connect
using PHP.

Any ideas?


Re: [PHP-DB] Order By [blank]

2006-12-21 Thread tg-php
You shouldn't have to do that. the IFNULL() handles all that.  If the item is 
null, it returns an emptry string ''.  If it's blank/empty, it returns an empty 
string. This is just used for the comparison = ''.  This determines if it's 
empty or null and if so, returns 'ZZ', if not, it 
returns the unaltered value.  And again, this returned value is only used for 
the sorting.  The values you get from "select *" will be unaltered.

Is this more efficient than doing two SELECTs and a UNION?  I have no idea.  
But I like to keep things as clean as possible and in my reading and 
experience, letting the server handle an IFNULL() function should be quicker 
than doing four value checks (is null, is not null, = '' and != ''), collecting 
the values of two SELECTS then checking to see if it's able to UNION them 
together.

Also, less code/typing typically means less chance of typos.


BTW: In my example, realistically you could probably shorten the morphed value 
to "ZZ" or "ZZZ" unless you think you'll values in your database that will 
start with "" and get bumped lower on the sorting.

-TG

= = = Original message = = =

In case the blank is a null or is really a blank:

select * from blank where tchar_10 is not null and tchar_10 != ''
union all
select * from blank where tchar_10 is null or tchar_10 = ''

- Dave

On 12/21/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:
>
> This is a little weird looking, but should do the job.  Remember that
> items in your 'order by' can be manipulated conditionally.  In this case,
> I'm looking for NULL as well as '' (empty) and changing it to something that
> should come after all your normal alphabetical values, but it doesn't change
> what appears in your results.  This only affects the sorting:
>
> select * from sometable order by if(ifnull(somecolumn, '') = '',
> '', somecolumn)
>
> Hope that helps.
>
> -TG
>
> = = = Original message = = =
>
> I have this column in mysql:
>
> A
> F
> D
> [ empty ]
> A
> C
>
> If I do an order by on that column, this is what I get:
>
> [ empty ]
> A
> A
> C
> D
> F
>
> What I would like is this:
>
> A
> A
> C
> D
> F
> [ empty ]
>
> Is there any way to achieve this in a single MySQL query? Using DESC
> in this case doesn't work, because while it puts the empty row in the
> last place, it does the rest as well. I could also do 2 queries where
> it calls it once in order WHERE  !='', and then do another query to
> get the empty ones, but that seems a bit cumbersome.
>
> --
> Kevin Murphy
> Webmaster: Information and Marketing Services
> Western Nevada Community College
> www.wncc.edu
> 775-445-3326
>
>
>
>
> --
> Kevin Murphy
> Webmaster: Information and Marketing Services
> Western Nevada Community College
> www.wncc.edu
> 775-445-3326


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-DB] Order By [blank]

2006-12-21 Thread David Mitchell

In case the blank is a null or is really a blank:

select * from blank where tchar_10 is not null and tchar_10 != ''
union all
select * from blank where tchar_10 is null or tchar_10 = ''

- Dave

On 12/21/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:


This is a little weird looking, but should do the job.  Remember that
items in your 'order by' can be manipulated conditionally.  In this case,
I'm looking for NULL as well as '' (empty) and changing it to something that
should come after all your normal alphabetical values, but it doesn't change
what appears in your results.  This only affects the sorting:

select * from sometable order by if(ifnull(somecolumn, '') = '',
'', somecolumn)

Hope that helps.

-TG

= = = Original message = = =

I have this column in mysql:

A
F
D
[ empty ]
A
C

If I do an order by on that column, this is what I get:

[ empty ]
A
A
C
D
F

What I would like is this:

A
A
C
D
F
[ empty ]

Is there any way to achieve this in a single MySQL query? Using DESC
in this case doesn't work, because while it puts the empty row in the
last place, it does the rest as well. I could also do 2 queries where
it calls it once in order WHERE  !='', and then do another query to
get the empty ones, but that seems a bit cumbersome.

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326




--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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




Re: [PHP-DB] Order By [blank]

2006-12-21 Thread tg-php
This is a little weird looking, but should do the job.  Remember that items in 
your 'order by' can be manipulated conditionally.  In this case, I'm looking 
for NULL as well as '' (empty) and changing it to something that should come 
after all your normal alphabetical values, but it doesn't change what appears 
in your results.  This only affects the sorting:

select * from sometable order by if(ifnull(somecolumn, '') = '', 
'', somecolumn)

Hope that helps.

-TG

= = = Original message = = =

I have this column in mysql:

A
F
D
[ empty ]
A
C

If I do an order by on that column, this is what I get:

[ empty ]
A
A
C
D
F

What I would like is this:

A
A
C
D
F
[ empty ]

Is there any way to achieve this in a single MySQL query? Using DESC  
in this case doesn't work, because while it puts the empty row in the  
last place, it does the rest as well. I could also do 2 queries where  
it calls it once in order WHERE  !='', and then do another query to  
get the empty ones, but that seems a bit cumbersome.

-- 
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326




-- 
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-DB] Order By [blank]

2006-12-21 Thread tg-php
This is a little weird looking, but should do the job.  Remember that items in 
your 'order by' can be manipulated conditionally.  In this case, I'm looking 
for NULL as well as '' (empty) and changing it to something that should come 
after all your normal alphabetical values, but it doesn't change what appears 
in your results.  This only affects the sorting:

select * from sometable order by if(ifnull(somecolumn, '') = '', 
'', somecolumn)

Hope that helps.

-TG

= = = Original message = = =

I have this column in mysql:

A
F
D
[ empty ]
A
C

If I do an order by on that column, this is what I get:

[ empty ]
A
A
C
D
F

What I would like is this:

A
A
C
D
F
[ empty ]

Is there any way to achieve this in a single MySQL query? Using DESC  
in this case doesn't work, because while it puts the empty row in the  
last place, it does the rest as well. I could also do 2 queries where  
it calls it once in order WHERE  !='', and then do another query to  
get the empty ones, but that seems a bit cumbersome.

-- 
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326




-- 
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-DB] Order By [blank]

2006-12-21 Thread David Mitchell

What about a union?  Does mySql 4.0.x support it?

select * from blank where tchar_10 != ''
union all
select * from blank where tchar_10 = ''


- Dave



On 12/21/06, Naintara <[EMAIL PROTECTED]> wrote:


Depending on your MySQL version you could use a subquery by combining the
two queries you mentioned, for a fairly straight-forward query.

http://dev.mysql.com/tech-resources/articles/4.1/subqueries.html
http://mysqld.active-venture.com/Subqueries.html

You could read about optimizing subqueries for optimum queries.

-Original Message-
From: Kevin Murphy [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 21, 2006 10:49 PM
To: php-db@lists.php.net
Subject: [PHP-DB] Order By [blank]

I have this column in mysql:

A
F
D
[ empty ]
A
C

If I do an order by on that column, this is what I get:

[ empty ]
A
A
C
D
F

What I would like is this:

A
A
C
D
F
[ empty ]

Is there any way to achieve this in a single MySQL query? Using DESC in
this
case doesn't work, because while it puts the empty row in the last place,
it
does the rest as well. I could also do 2 queries where it calls it once in
order WHERE  !='', and then do another query to get the empty ones, but
that
seems a bit cumbersome.

--
Kevin Murphy
Webmaster: Information and Marketing Services Western Nevada Community
College www.wncc.edu
775-445-3326




--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326

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




Re: [PHP-DB] Order By [blank]

2006-12-21 Thread Kevin Murphy
Unfortunately, I'm on 4.0.x so sub-queries are out. And yeah, I  
should get my host to upgrade but we both work for the government  
so that isn't happening. ;-)


Any other thoughts.

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


On Dec 21, 2006, at 9:30 AM, Naintara wrote:

Depending on your MySQL version you could use a subquery by  
combining the

two queries you mentioned, for a fairly straight-forward query.

http://dev.mysql.com/tech-resources/articles/4.1/subqueries.html
http://mysqld.active-venture.com/Subqueries.html

You could read about optimizing subqueries for optimum queries.

-Original Message-
From: Kevin Murphy [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 21, 2006 10:49 PM
To: php-db@lists.php.net
Subject: [PHP-DB] Order By [blank]

I have this column in mysql:

A
F
D
[ empty ]
A
C

If I do an order by on that column, this is what I get:

[ empty ]
A
A
C
D
F

What I would like is this:

A
A
C
D
F
[ empty ]

Is there any way to achieve this in a single MySQL query? Using  
DESC in this
case doesn't work, because while it puts the empty row in the last  
place, it
does the rest as well. I could also do 2 queries where it calls it  
once in
order WHERE  !='', and then do another query to get the empty ones,  
but that

seems a bit cumbersome.

--
Kevin Murphy
Webmaster: Information and Marketing Services Western Nevada Community
College www.wncc.edu
775-445-3326




--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326

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





RE: [PHP-DB] Order By [blank]

2006-12-21 Thread Naintara
Depending on your MySQL version you could use a subquery by combining the
two queries you mentioned, for a fairly straight-forward query.

http://dev.mysql.com/tech-resources/articles/4.1/subqueries.html
http://mysqld.active-venture.com/Subqueries.html

You could read about optimizing subqueries for optimum queries.

-Original Message-
From: Kevin Murphy [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 21, 2006 10:49 PM
To: php-db@lists.php.net
Subject: [PHP-DB] Order By [blank]

I have this column in mysql:

A
F
D
[ empty ]
A
C

If I do an order by on that column, this is what I get:

[ empty ]
A
A
C
D
F

What I would like is this:

A
A
C
D
F
[ empty ]

Is there any way to achieve this in a single MySQL query? Using DESC in this
case doesn't work, because while it puts the empty row in the last place, it
does the rest as well. I could also do 2 queries where it calls it once in
order WHERE  !='', and then do another query to get the empty ones, but that
seems a bit cumbersome.

--
Kevin Murphy
Webmaster: Information and Marketing Services Western Nevada Community
College www.wncc.edu
775-445-3326




-- 
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326

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



[PHP-DB] Order By [blank]

2006-12-21 Thread Kevin Murphy

I have this column in mysql:

A
F
D
[ empty ]
A
C

If I do an order by on that column, this is what I get:

[ empty ]
A
A
C
D
F

What I would like is this:

A
A
C
D
F
[ empty ]

Is there any way to achieve this in a single MySQL query? Using DESC  
in this case doesn't work, because while it puts the empty row in the  
last place, it does the rest as well. I could also do 2 queries where  
it calls it once in order WHERE  !='', and then do another query to  
get the empty ones, but that seems a bit cumbersome.


--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326




--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326




Re: [PHP-DB] Paginatating PHP

2006-12-21 Thread Ondrej Kohout
It's better to use SQL_CALC_FOUND_ROWS and information function 
FOUND_ROWS().


For more information see 
http://dev.mysql.com/doc/refman/4.1/en/information-functions.html


Find: FOUND_ROWS()

Iky


OKi98 wrote:


Chris Carter wrote:
>There is enough data to display this result and to paginate but its 
simply showing the

>else condition which does not have NEXT or PREVIOUS hyperlinked.
>...
>$query_count = "SELECT count(*) FROM students";
>$result_count = mysql_query($query_count);
>$totalrows = mysql_num_rows($result_count);
well, the result is always 1 (even if no students are present), you 
need to use some mysql_fetch_* function to get the count of students

ie.
$tmp=mysql_fetch_row($result_count);
$totalrows=$tmp[0];


OKi98



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



Re: [PHP-DB] Paginatating PHP

2006-12-21 Thread OKi98

Chris Carter wrote:
>There is enough data to display this result and to paginate but its 
simply showing the

>else condition which does not have NEXT or PREVIOUS hyperlinked.
>...
>$query_count = "SELECT count(*) FROM students";
>$result_count = mysql_query($query_count);
>$totalrows = mysql_num_rows($result_count);
well, the result is always 1 (even if no students are present), you need 
to use some mysql_fetch_* function to get the count of students

ie.
$tmp=mysql_fetch_row($result_count);
$totalrows=$tmp[0];


OKi98

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