[PHP-DB] figuring out number of months between two dates
I have a table that contains a list of dates. For instance: 2001-08-23 2001-08-27 2001-09-04 (and running through) 2002-06-03 I want to calculate how many months between 2001-08-23 and CURRENT_DATE (which for discussion purposes we'll put at 2002-04-01) and how many months between the first week and the last. I can count the weeks and divide by 4.333 to approximate months, but I was wondering if there was a way to use a PHP function or MySQL's MONTH() to do the job. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Pop up are you sure...
Addressed to: "Dave Carrera" <[EMAIL PROTECTED]> [EMAIL PROTECTED] ** Reply to note from "Dave Carrera" <[EMAIL PROTECTED]> Tue, 2 Apr 2002 07:23:43 +0100 > But wouldn't it be nice to have a class or function we could all use > built in to php that would let us do this. > > > > C,C++,Delphi and JS allow you to do this. > Over the web? The limitation is in HTML not PHP. > > I have come across various probs with JS on client systems so I shy away > from it. > Good move! Rick Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Pop up are you sure...
Hi all, Thank you all for you advice. I am aware of the two ways of achieving the required result ie: JS and extra button built into my script. But wouldn't it be nice to have a class or function we could all use built in to php that would let us do this. C,C++,Delphi and JS allow you to do this. I have come across various probs with JS on client systems so I shy away from it. Again thank you all for your advice. Dave Carrera Php Developer http://davecarrera.freelancers.net http://www.davecarrera.com
[PHP-DB] Re: Pop up are you sure...
Dave, Javascript is client side. PHP is server side. Obviously the limitations imposed by each of the languages is evident. PHP can't do anything once the output is sent to the browser. JavaScript can't do anything before it gets sent to the browser. But, each is important as the other. Learn to use both (its not that hard) and it will make life a lot easier (and more interesting). Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: autoincrement
What's the error? Do you already have an auto-inc field? Have you tried it with another interface? Ie: directly in the MySQL command line util. Glenn Notes from MySQL.com: There can be only one AUTO_INCREMENT column per table, and it must be indexed. When you add an AUTO_INCREMENT column, column values are filled in with sequence numbers for you automatically. You can set the first sequence number by executing SET INSERT_ID=# before ALTER TABLE or using the AUTO_INCREMENT = # table option. See section 5.5.6 SET Syntax. With MyISAM tables, if you don't change the AUTO_INCREMENT column, the sequence number will not be affected. If you drop an AUTO_INCREMENT column and then add another AUTO_INCREMENT column, the numbers will start from 1 again. "Daniel Broome" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I am trying to add auto increment to a table I have already created in > phpMyAdmin but I keeps coming up with an error. > what can I do to fix this? > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] autoincrement
I am trying to add auto increment to a table I have already created in phpMyAdmin but I keeps coming up with an error. what can I do to fix this? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Grouping menu items
Hello All Forget my previous post - I will simply run an update on the table to alter all the various News variations back to 'News' cheers kim -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Grouping menu items
Hello All, I have a MySql database which has a 'sections' column which includes values such as Real Estate, Sport, Letters etc. The 'News' section is divided into 4 parts to indicate a priority for any given story; News, News2, News3 and News4. We are using: $getlist1 = mysql_query("SELECT distinct Section FROM stories"); to populate a popup menu which returns each of the 'News', News2, News3 and News4 items as separate rows in the popup. Ideally I'd like to have all the 'News' variants appear under a single 'News' menu item rather than separately. Can anyone suggest a way to group these entries together or to truncate the digit off the end without effecting any other menu item? cheers kim -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Using MyODBC V 2.50.39.00
I found a note on the MySQL website that MyODBC has a limitation in the number of columns that it returns. Is this true? I am successfully connecting to a MySQL database but I keep getting the error: Warning: Field index is larger than the number of fields in (program-name) on line 78. I am running MySQL and Apache on a Win98 machine. I don't want to using mysql_ commands to the database because I don't want to make this specific to MySQL. I want generic code using ODBC. Is there a way around this? Why would anybody put this type of limitation in? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Pop up are you sure...
Hello!! What I was able to do was this On every form page I have, I have a checkbox that is labeled "Ok To Save", that the user would check or not.. I would then pass that variable to the next page and check to see if the value was true or not... If it is true then it would continue to insert the data into the database... If not then it would display the pop up messages The code looks something like this on the parse page.(in my case it is the insert3.php file) \n"); echo ("\n"); exit(); } require ("functions/java.inc"); echo ("\n"); echo (""); ?> It will popup a messages about not checking that checkboxAnd tell you have an error... I too messed around trying to just using PHP, but I gave up using just PHP, Javascript plays nice with PHP anyway!! Dan On Monday, April 1, 2002, at 12:57 PM, [EMAIL PROTECTED] wrote: > I was close. :) > > -Original Message- > From: Jason Wong [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 01, 2002 10:53 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] Pop up are you sure... > > > On Tuesday 02 April 2002 01:30, Jonathan Hilgeman wrote: >> You're so negative, Jason. :) > > No, my answer was just short and to the point ;-) > >> Long answer, Dave, it wouldn't be wise to do this via Javascript. > > My long answer was going to be: it's possible to do it in PHP, but then > it > would not look like a pop-up window, and it requires a trip back to the > server. > > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > > /* > Love is being stupid together. > -- Paul Valery > */ > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Pop up are you sure...
I was close. :) -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Monday, April 01, 2002 10:53 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Pop up are you sure... On Tuesday 02 April 2002 01:30, Jonathan Hilgeman wrote: > You're so negative, Jason. :) No, my answer was just short and to the point ;-) > Long answer, Dave, it wouldn't be wise to do this via Javascript. My long answer was going to be: it's possible to do it in PHP, but then it would not look like a pop-up window, and it requires a trip back to the server. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Love is being stupid together. -- Paul Valery */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Pop up are you sure...
On Tuesday 02 April 2002 01:30, Jonathan Hilgeman wrote: > You're so negative, Jason. :) No, my answer was just short and to the point ;-) > Long answer, Dave, it wouldn't be wise to do this via Javascript. My long answer was going to be: it's possible to do it in PHP, but then it would not look like a pop-up window, and it requires a trip back to the server. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Love is being stupid together. -- Paul Valery */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Pop up are you sure...
You're so negative, Jason. :) Long answer, Dave, it wouldn't be wise to do this via Javascript. Javascript can be turned off and also varies from browser to browser (like any client-side language/scripting), so this raises an issue of reliability. You may be able to do it if you're working on an intranet where you know that all users have the same browser, have Javascript turned on, and don't have access to turn it off, OR if this is for your own use and you don't want to make it screw up. Otherwise, it might be a nice feature, but you shouldn't rely on it. If you WERE going to do it, I would have your main form have a hidden input called "Confirm" and set it to a value of 1. Then, have a "Button" (not a submit button) use Javascript to open a new browser/popup window (you can format it to look like a regular Yes/No windows popup box). Have the "Yes" I-want-to-delete-this-record button change its parent window's form and change the "Confirm" input's value to 0 and submit the parent window's form in order to delete the record. Have the No button just close the popup/new window. Now, on the page that actually deletes the record, first check the Confirm variable. If it is set to 0, then you can figure that the Javascript set it to 0, and you can go ahead and delete the record without asking. Otherwise, show a regular HTML screen that asks if you really want to delete this record (no Javascript this time), so you can be covered if Javascript gets turned off. This is by no means a fool-proof method, and you should think carefully through all this before implementing a Javascript solution, but I find that there are better methods with PHP. For instance, you can have 3 checkboxes side-by-side that can act as the "yes-I-really-really-want-to-delete-this-record" safety. PHP can check to see if all 3 checkboxes were checked, and then you can know that the user was intentionally trying to delete that record, and you can go ahead and delete it - no Javascript needed. :) As far as the Javascripting goes, though, I would check out some JS forums for help on how to set up the actual scripting part of the popup box. But, as Jason probably was thinking, Javascript is never a very good thing to use with things that are delicate, fragile, or valuable in any way. It's like hiring an ex-thief to help you move - you can never be SURE that everything's going to be there in the end. - Jonathan -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Monday, April 01, 2002 12:45 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Pop up are you sure... On Monday 01 April 2002 16:44, Dave Carrera wrote: > Hi All > > > > How do you do this? Use javascript. > On click of button to delete a record make a popup yes / no box appear. > On yes then do it else stop. > > > > Is it possible to do with out using JS? Short answer, no. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Timing must be perfect now. Two-timing must be better than perfect. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Table structure and displaying certain thing
Hi Jennifer, Okay first, in your current page, just do one SQL statement that selects the 4 fields you want all at once, then use extract() to turn the record/result into variables, and print out your form like: 0) { print ""; // Get Record and Echo/Print Out Data while($rec = mysql_fetch_assoc($ret)) { extract($rec); echo ""; echo "$name"; echo "Quantity $quantity"; echo "Cost: $price SC"; echo ""; } print ""; } else { // Say there's a problem and echo the error message to an HTML comment. print "There was a problem while fetching the item from the database.\n"; print "\n"; } ?> ... Now you'll have a file that will post a field called ItemID containing the ID number (in this case, 1) to buyitem.php. Now you just code buyitem.php to add the product to the user's "basket". There are several ways of doing that, but this should be the proper stepping stone. - Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] int or tinyint
Hi Jennifer, In most cases, it's best to use int. The difference between the two is simply the range of numbers they can show. Tinyint is fine for cases where you know you'll never need more than 127 (or 255 if you tell MySQL that it is an UNSIGNED tinyint, which just means that it can't have negative numbers so it now has that much more room for positive numbers; the UNSIGNED literally means that it doesn't have a positive or negative sign, so everything's defaulted to positive). If you use a regular tinyint on an auto-incrementing field like "member_id" and you get 127 members, you won't get any more. Each attempted INSERT query after the 127th member will have an error saying something about duplicate keys for 127 (it's trying to insert a new one, but it can only go up to 127, so it tries to insert a new member with an id of 127, but there's already one there). So in short, use int in most cases. It doesn't take up that much more space, and has a much wider range of numbers it can hold (someone else said 2 billion-something, which I think is right). But from what I currently understand (someone can correct me if I'm wrong), you are also limited to the digits/length you specify for the field. For instance, an int(5) can only hold 5 digits, so you could go up to 99,999 maximum and down to -99,999 (unless you had an UNSIGNED int, in which case, there would be no negative numbers, but you're still limited to 5 digits). An int(6) could hold 6-digit numbers up to 999,999, etc... - Jonathan -Original Message- From: Jennifer Downey [mailto:[EMAIL PROTECTED]] Sent: Sunday, March 31, 2002 10:06 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] int or tinyint Hi all, Just a simple question (I think). When should I use tinyint over int. and what is the difference between the two? Thanks Jennifer -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: locking a record
MySQL can do this for you. Check the mysql.com manual and look for InnoDB, isam etc.. table types. -Chris >Hi to all, >I have a MySQL DB, and I'm retrieving the data using PHP. There will be >about 10 users that will work in a form at the same time. My question is how >do I lock the a record? for example user 1 access record 1; I don't want >user 2 be able to have access to the same record. >Is it possible to do this in PHP? or I have to do it in MySQL? > > >Thanks in advanced >Nato -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Table structure and displaying certain thing
Hello Jenniffer, I think the you could do like this: "; \\ The current id selected in the DB echo "".$result['name'].""; \\ it will print the name of product echo "Quantity ".$result['quantity'].""; \\ and the quantity echo "Cost: ".$result['price']." SC"; \\ price as well echo ""; \\ i don't know if if will be necessary but it won't appear in the Browser :) } } ?> i thinkk it's good At 19:33 31/03/02 -0800, you wrote: >Hi all, > >I have a table called items here is a dump: > >CREATE TABLE items ( > id int(10) NOT NULL auto_increment, > name varchar(50) NOT NULL default '', > item_type int(4) NOT NULL default '0', > image varchar(100) NOT NULL default '', > price int(10) NOT NULL default '0', > quantity int(5) NOT NULL default '0', > PRIMARY KEY (id) >) TYPE=MyISAM; > >Here is my code and I know there has to be an easier way to do this so any >help would be appreciated. > > > >// selects the image of the item from db >$query = "SELECT image FROM items where id = 1"; > $ret = mysql_query($query); > while(list($image) = > mysql_fetch_row($ret)) > echo ""; > >//select the name of the item >$query = "SELECT name FROM items where id = 1"; > $ret = mysql_query($query); > while(list($name) = > mysql_fetch_row($ret)) >echo "$name"; > >//shows the quantity of the item >$query = "SELECT quantity FROM items where id = 1"; > $ret = mysql_query($query); > while(list($quantity) = > mysql_fetch_row($ret)) >echo "Quantity $quantity"; > >//the price of the item >$query = "SELECT price FROM items where id = 1"; > $ret = mysql_query($query); > while(list($price) = > mysql_fetch_row($ret)) >echo "Cost: $price SC"; >?> > > >What I am trying to do is make it so the user clicks on the image and is >taken to buyitem.php through the form where it takes the item out of the >items table and updates the user table with that item. > >Any ideas how I can accomplish this? > >TIA >Jennifer > > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php Henrique Flach Latorre Moreno Smart Tech Consulting www.smartech.com.br Av. Rio Branco 181, 1005 Centro - Rio de Janeiro - RJ Tels : (21) 2532-6335 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] locking a record
Hi to all, I have a MySQL DB, and I'm retrieving the data using PHP. There will be about 10 users that will work in a form at the same time. My question is how do I lock the a record? for example user 1 access record 1; I don't want user 2 be able to have access to the same record. Is it possible to do this in PHP? or I have to do it in MySQL? Thanks in advanced Nato -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem with PHP connectivity with mySQL (RedHat package)
If that works fine, check out for the php-xxx rpms including the php-mysql- one. CK Raju ** Message from InterScan E-Mail VirusWall NT ** ** No virus found in attached file noname.htm This is a virus free message scanned by Zyberway * End of message *** -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Pop up are you sure...
On Monday 01 April 2002 16:44, Dave Carrera wrote: > Hi All > > > > How do you do this? Use javascript. > On click of button to delete a record make a popup yes / no box appear. > On yes then do it else stop. > > > > Is it possible to do with out using JS? Short answer, no. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Timing must be perfect now. Two-timing must be better than perfect. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Pop up are you sure...
Hi All How do you do this? On click of button to delete a record make a popup yes / no box appear. On yes then do it else stop. Is it possible to do with out using JS? Thanks for any pointers or code in advance. Dave Carrera Php Developer http://davecarrera.freelancers.net http://www.davecarrera.com
Re: [PHP-DB] Re - Direct a User after a completed Form
header is the appropriate one you're looking for: header( "Location: thanks.php" ); what i do is use the page that processes all the data to also validate the data. if the data does not pass through, it stays on this page with all the errors listed in the body. if it goes through.. then the 'header()' is loaded. example. page1 all the stuff in your form. i.e. email: .. page2 (send-form.php) Error!! Form not filled properly. you need to enter a valid email address .. page 3 (thanks.php) thanks Thanks! . hope this helps wes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php