Sounds about right... you can also do something like this (syntax should be
right):
SELECT MIN(id) as minid, MAX(id) as maxid FROM mytable
$array['minid'] and $array['maxid']
Basically it's going to be whatever the heading of that column is. Using "as"
gives it an alias for less ugly headin
SELECT MIN(id), MAX(id) FROM mytable
:)
Hope that helps!
-TG
= = = Original message = = =
I have a table where I need to figure out the very first ID and the
very last ID, so here is what I wrote:
$first_query = "SELECT id FROM mytable ORDER BY id LIMIT 1";
$first_result = mysql_query($firs
Yeah, that's a bit of an important piece of information. Some tricks do work
across versions of SQL, but not always.
Something else you can try is creating an artificial column to sort by. Excuse
the code, it's been ages since I've worked with MS SQL so syntax is probably
off, but just to dem
Try this:
SELECT * FROM productgroup WHERE groupid = $productid
ORDER BY label = 'Cats' DESC, title
The test SQL I did to make sure I understood it was this (against our Users
table):
select * from users order by first = 'Bob' DESC, first, last
It put all the "Bob"s first, sorting them by firs
I suck at regex, but looks like 3.23 may actually support it. And most regex
implementations have a word boundary code for doing exactly what you're talking
about.
Referring to this page: http://dev.mysql.com/doc/refman/4.1/en/regexp.html
I found this example.. hopefully it'll help you (and wo
Assuming you're using MySQL, try MONTH(). As in:
SELECT MONTH(SomeDateField) FROM SomeTable
http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html
If this isn't a database question, but a general PHP question, try this:
// For numeric month without leading zero, use "n"
echo dat
Try this as your SQL. It should give you all the results, then you can use PHP
to sort it all out.
SELECT * FROM egw_cal WHERE cal_category='501' and cal_id in (SELECT cal_id
FROM egw_cal_dates where cal_start > $tstamp)
-TG
= = = Original message = = =
Hello Everyone
Got a simple / st
Ok, in your original message you said something about using the name as
dominant key (or whatever you want to call it). All the SQL does is gather all
the data together in an associated fashion. You can use the array you build to
organize the data. I'm still not 100% sure what you're doing,
Not sure if this is exactly what you're looking for, Matt, but I think it is.
If that's not right, please re-describe the problem and let's see what we can
figure out.
If you have questions about what/how/why/etc... feel free to ask.
-TG
= = = Original message = = =
Hello,
I need to que
If all you want is a unique list of "adr_one_region" codes, then use the
DISTINCT keyword in your SQL:
SELECT DISTINCT adr_one_region FROM egw_addressbook WHERE cat_id='8' ORDER BY
adr_one_region
-TG
= = = Original message = = =
Hello everyone
I'm back working on the website again... I'
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
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 ra
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',
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 chang
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 chang
You may get duplicate messages sometimes when someone responds directly to you
as well as copying the message to the main mailing list. Like in this ccase,
my To: field is the PHP DB list, and my CC: field is your personal email
address.
If that's not the issue, then try what Dave suggested an
cron or Windows Task Manager would work if you want to check the status of the
data periodically, but I believe you can also use Access to hit a web address
(it doesn't have to display anything) so you could, at time of insert, have
Access activate a PHP script on your web server that does the d
Here are some thoughts on the couple of methods shown:
1.
SELECT count(*) as MyCount FROM aTable # Fast query done on server size
SELECT * FROM aTable LIMIT 5 # Fast limited data return query done server side
2.
SELECT * FROM aTable # Potentially slow query, lots of data stored in PHP
mysql_n
Yeah I did.. just didn't have time when I posted that message. I was
mis-remembering what cross-tab queries did. They're not really what the
original poster was looking for.
For anyone interested in crosstab queries (aka "pivot" queries or tables or
reports), here's an example of how to do it
Correct me if I'm wrong, but it sounds like you have something like this:
123 Joe
124 Joe
125 Sue
126 John
127 Joe
128 Frank
129 Sue
And you want to output something like:
Joe 123, 124, 127
Sue 125, 129
John 126
Frank 128
But what you're getting is:
Joe 123
Joe 124
..etc
You have two
An alternative to cron jobs or scheduled tasks (if they're not an option) is to
have a marker somewhere (probably in your database) that records a timestamp
for the last 'gold' update then when someone does get around to accessing the
database through normal operations, have it figure out how ma
One thing I've done in situations like this is just load your returned DB data
into an array. Something like this would do:
$dvdarr[$result['call_number']]['Title'] = $result['title'];
$dvdarr[$result['call_number']]['Publisher'] = $result['publisher'];
$dvdarr[$result['call_number']]['Comments
Don't have time to totally disect it, but you might change the "if($num_rows)"
to "if($num_rows > 0)" just to make sure.
Also, try echoing out your SQL statement to check and make sure things like
$table got a real value or other silly things.
Lastly, I usually use single quotes for SQL stateme
Sounds like you're asking how to programmatically add your web site to Google's
search. I didn't dig very deep, but it doesn't look like Googles API provides
for the ability to submit (only search) and by Google's "addurl" page
(http://www.google.com/addurl/?continue=/addurl) it appears that th
The other response is half correct.. I havn't seen anything to read data from
Excel with PHP (although it's technically possible, just kind of complicated)
so the easiest solution is to use Excel and just have it load the file and save
it in CSV format.
The part that's not entirely correct is
I remember the quick install/test I did using PEAR and I kind of had a similar
experience, but I figured out what the issue was for me.
PEAR installed perfectly but doing the pear install thing where it pulls the
package down and puts it where it needs to put it, I was doing what you were
doing
Haha.. oh yeah.. DISTINCT works too.. in this case you'd get a list of all
totally 100% unique records.
If you had an auto_increment column though, you'd want to exclude it from the
list.
-TG
= = = Original message = = =
SELECT DISTINCT * FROM `tablename`
On Wednesday 01 March 2006 7:24 am
Depends on how you determine if something's a duplicate or not. For example,
if it's just one column that can be used, you can do something like this:
select ItemName, count(ItemName) from ItemListTable group by ItemName
having count(ItemName) > 1
That'll show you if "ItemName" is repeated.
Thanks Balazs and David.. I think that's exactly what I was looking for. I
searched for hours (and I consider myself a fairly decent researcher) and was
just getting frustrated..hah.. I think my problem was I was searching for
"money" and "float problems" and such and not "monetary". I think
Again.. your forgiveness. This is a MySQL question. If the MySQL mailing lists
would include a [MySQL Help] tag in their subject lines, I'd use them. What I
receive from them is difficult to distinguish from spam half the time so I gave
up.
We had a problem a few months ago and now I can't fin
Bastien's example is probably the quickest and easiest. I just wanted to point
out that you can use math within the mktime() function as well in case the
relative date/time you need isn't "right now".
$month = 1;
$day = 19;
$year = 2006;
$hour = 17;
$minute = 08;
$second = 05;
echo date("Y-m-d
Ooops... here's the real link:
http://rajshekhar.net/blog/archives/85-Rasmus-30-second-AJAX-Tutorial.html
= = = Original message = = =
Two ways I can think of to update part of a page without doing a full refresh:
1. Use an IFRAME so you're technically updating a page, but it's the page
with
Two ways I can think of to update part of a page without doing a full refresh:
1. Use an IFRAME so you're technically updating a page, but it's the page
within the frame (not my favorite but works ok)
2. Or you can use asynchronous javascript (AJAX) to update just that one
section of the page w
Ahh! Thank you Philip! That's what I was looking for! I see what I did wrong
now.
I was using the date format strings wrong. I was using it like I'd use it for
DATE_FORMAT() instead of as an input filter.
This is what I was trying to do:
select STR_TO_DATE('2003-11-05 06:00 PM', '%Y-%m-%d %H
Unfortunately, no. The dates and times are stored as text. So here's what I
get:
2006-01-10 07:00 PM
2006-01-10 08:00 PM
2006-01-10 09:00 AM
2006-01-10 09:00 PM
(notice the "AM" out of order)
For anyone interested, here's the big ugly version.. if anyone knows of a
function that I can use i
Forgive me that this isn't really PHP related, but solely MySQL.. but the MySQL
mailing lists drive me nuts and figured someone here would have a quick answer.
I'm trying to sort by a date and time field(s) (two separate fields). It's a
dumb system but until we do the next revision, it's going
What? Nobody said "This has nothing to do with PHP and databases?" Sheesh...
someone must be sleeping. :) Ok, so it sorta does relate..
But yeah... no2br() will do it for you. Textarea input types DO send a newline
and/or carriage return (didn't test and might be system specific), so if you
You got the right idea, but you're making it more complicated than it needs to
be.
your $sDate after using explode() is going to contain an array. strtotime
doesn't take an array, it takes a string.
$monthName = date("F", strtotime($row_events['Sdate']));
$monthNumber = date("m", strtotime($r
Couple of things you can do:
1. Drop the song ID and only get the artist information "SELECT
distinct(Artist) from songtable". It doesn't look like your SELECT statement
needs a song, but you include the song ID as $id anyway. Any reason for that or
can you drop it so you only get artist?
2.
This isn't really a MySQL error (sorta), it's a PHP error. You probably forgot
to update a variable name when you updated everything else.
Here's an example sequence for querying using PHP/MySQL:
$TestQY = "SELECT * from SomeTable";
$TestRS = mysql_query($TestQY) or die("Error executing query")
Ahh..thanks Jordan.. sorry I missed that one and thanks for the info. I
assumed serialize was just magic and worked properly. hah. Now I know.
I always thought it was sloppy to use anyway, but in a pinch, it's nice to know
there's an option like that. Imploding does sound better though.
-T
Sorry, didn't catch this thread from the beginning, but did anyone recommend
trying the serialize() and unserialize() commands? They'll convert the array
to a block of text that can be stored, retrieved and unserialized.
My gut instinct is that if you're trying to store any array in a database,
Haha.. what the hell? Ok, I know this is an older copy of the script I wrote
because I know I took out the "All this does is escape the data" comment and I
KNOW I saw the thing about mysql_escape_string() being deprecated... don't
know why it's still in there. Hah
Thanks for pointing that out
I'm pretty amateur at this too, but have done a little reading on the subject.
Here's some nuggets to ponder while the real experts write their responses: :)
1. Magic quotes + mysql_escape_string = double escaped stuff. I think the
general opinion is the magic quotes is evil, but I'm sure some
One trick is to force the case in your comparison:
$ucstringinput = strtoupper($stringinput);
$qry = "select * from sometable where upper(address) like '%$ucstringinput%'"
Didn't think LIKE was case sensitive, but regardless... forcing upper or
lowercase in your comparison doesn't affect output
If I remember right, PHP's built-in database functions don't allow for a
DSNLess connection. Meaning you have to set up an ODBC source on the machine
PHP is running on (or do a remote ODBC connection) and connect to a DSN (a
named datasource manually set up). BUT.. if you know the address of t
Ok, I'm at a point where I'm just going to throw this out there and see if
anyone has any good solutions because I'm just not seeing one. Of course
there's always a better solution, but I'm too brain dead right now to see it.
So any input would be appreciated.
Also..forgive me if this is more
Ahh.. ok.. I was mostly doing DSNless connections.
You might want to look into the setup for your ODBC source called "Datasource"
in your example below. That might be what's actually passing the
authentication, not PHP itself. PHP makes a call to the local ODBC source
which in turn actually
Maybe I'm not understanding the situation properly, because I can't see why you
would have had it working under IIS5 if your configuration is how I think it is.
Integrated authentication basically allows a workstation that's logged into a
domain to automatically pass it's credentials from the wo
Well, first of all.. your subject line mentions GROUP BY which is a database
function for telling the query what to use when performing aggregate functions
like sum, count, average, etc type functions.
That's really not what you're looking at doing here it sounds like. Sounds
like you just wa
Sounds like pre-loading the addresses into javascript or something is also
going to be just as cumbersome and that's the only other method I can think of
to have the addresses auto-complete realtime. Yahoo has a little helper app
that works with Yahoo mail to auto-complete names from your emai
To be honest, I havn't had much use for it myself but I've done a lot of 'hack'
projects that didn't need to be this specific. But as I understand, you might
want to use the triple-equal sign to determine if they're exactly the same.
Are you comparing...
2
with...
"0002"
(integer versus a s
Interesting use of split().. don't think I've ever used that function but looks
like it'll do just as well and also allow multiple dividers. Thanks for
pointing that out.
As for this:
$mysqldate = $y.'-'.$m.'-'.$d;
The only problem I foresee is what happens when you have single digit days an
Yeah, this is my problem with relyinig on strtotime(). If you don't give it a
format that it knows, it's going to give you random results (well, not random,
but "undesireable"). Seems like more of a crutch that leaves too much chance
of error for my taste. I prefer to be a little more explici
54 matches
Mail list logo