Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Auto Calculations


I've seen on a few sites that in a shopping enviroment if you choose a price from a drop down and then maybe a delivery ares, the actual price shown for the product is updated instantly without page refresh.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Calculations
i want it to calculate a value that is in the db if the db has the value 6 pound(s) (i have a submit button) and the users enters in the input box a value for more pounds then how do i make it calculate in fractions or even divisions.. cause see this is what i have. PHP Code:

Calculations
<?php
echo 04 - 1;
?>

that echo's
3
I need it to echo 03, is there an easy way to do this?

Binary Calculations
I'm not sure if PHP can do this but I have a client that would like to provide unlock codes for a CD they have. They have given me a document that describes the Binary calculation that is required to calculate the unlock code based on the CD serial number. They also refer to EX/OR or exclusive or. The also refer to hex data which I'm assuming is hexidecimal which I'm pretty sure PHP can deal with.

I'm interested in finding out if PHP can work with binary, ex/or and hexidecimal data. If not any other possible solution, ie. library or other language such as Perl. I would also appreciate any links to additional info.

Date Calculations
in my script i have this varaibles PHP Code:

Doing Time Calculations...
For a project I am working on right now I need to be able to calculate the
time difference between to given times.
(For example...The difference between 11:30 am and 1:45pm being 2:15)

Right now the input is setup as 2 text boxes, 2 dropdowns, and 2 radio
groups. The text boxes get the hour entered into them, the drop downs holdd
a list contaning 00, 15, 30, and 45 (the minutes) and the radio groups being
am or pm.

Is it possible to use that configuration and somehow get the time
difference? or do I need to change the input? The goal is to be able to
enter the two values and immediately see a calculated difference in a third
textbox on the page.

I'm thinking something like....
User enters hour in first text box(textHFrom) - 11
User selects minue value from second dropdown(cboMFrom) - 30
User selects am/pm from radio group(radioF) - am
User enters hour in second text box(textHTo) - 1
User selects minue value from second dropdown(cboMTo) - 45
User selects am/pm from radio group(radioT) - pm

onChange of second RadioGroup time is calculated and result in inserted into
third text box(textHours) - 2:15

I'm not sure if/how to bet do this.

Time Calculations
i have a field in mysql which contains a timestamp: 2007-07-25 22:52:14 i was going to add a new variable but adding 1 hour to it so it would read: 2007-07-25 23:52:14
im not sure how to format the date to read add 1 hour to the date stamp.

Calculations With Date
i've got 2 date values, both in the format yyyy-mm-dd, has anyone any ideas how to perform a calculation, so that I can take one date away from the other and be left with the days/difference between

Calculations Within A Field
i have a field which is float, it stored the price of an item, i need to create another field called points which times the price by 0.1 and stores that value.

how would i do this? can the sql database do it itself or would i need to create a function in php that will convert it then store the points?

Date Calculations
I'm doin the old calculate persons age from database routine. Had a good search around and found out about Unix timestamps. Been looking those up and trying to figure out how to use them properly.

My dates are of the d-m-Y format.. I.E.. today is 11-02-2007
I did it this way so i can use date("d-m-Y") to grab todays date elsewhere in the site and it's all the same format.

Problem is that I can't quite grasp timestamps.
I tired something like this..

$dobts = strtotime($dateofbirth);
$todaysdate = date("d-m-Y");
$todaysdatets = strtotime($todaysdate);

$agets = $todaysdatets - $dobts;

$age = date("d-m-Y", $agets);

Didn't work of course but it thought that was the point of these timestamps?

Date Calculations?
I'm having trouble with a simple date calculation. Basically I have to time stamps, $todays_date and $date_joined. I want to find out how long a member has been registered on my forum in days months years atm I'm taking  $date_joined off $todays_date but its giving me an actual date which is 1971-06-05 but I actually want something like 30 days or 2 months 3 days not the actual date if that makes any sense.

Heres my code:
$todays_date=time();
$date_joined=$member_row['user_joined'];
$join_time=$todays_date-$date_joined;
echo "Join time: ". date('Y-m-d', $join_time)."
";

How To Do Calculations Using JOIN Statement?
I have three tables -:

Customer Table
AccountID field
Name field

Invoice Table
InvoiceID field
invoice_date field
CustomerID field
Amount field

Payment
InvoiceID field
Payment_Amount field
payment_date field

PHP Code:

PHP And MySQL Date Calculations
I have a date type in mySQL, and I want PHP to run a select where it grabs todays date, checks against my database, and returns all values that are new within 30 days. I cant seem to find any help anywhere. Here's what I got so far for it:

$current = getdate();
$this_month = $current["mon"];

that will at least get me the month, the problem is testing it against the date type in the select statement.

Date Calculations Advice
I am getting the date like this $date = strtotime(date());
ok, there you have it, a Unix time stamp of the time, date, and everything else.
From here, is this the best way to do calculations.

Like if I wanted to tell when 48 hours had passed from this date, how do I go about doing that. I know for example if you wanted to add a day, you check on how many "number's" here are in a day and put + that number onto the strength.
Can someone tell me some stuff about this, so I am more familiar with dates, before I start all of these calculations.

Simple Date Calculations
What I am trying to do is show the difference between two dates - one will be "today" and the other will be the date on which an entry was made into the database for that particular user.

I tried doing $difference = $today - $entrydate but this did not give me any kind of figure. Both dates are stored in the format of, for example, 21 Feb 07, 11:22am Would the time cause problems?

Auto-Tab
I have a page that has 5 input boxes, the first box holds 5 characters, the second holds 4 and carries on varying in length. I need to find a way so that when a user enters the 5th char in the first box, then the cursor moves to the second box and so on...

Auto Variable
Say I have fetched these from my mysql database:

13
14
23
39
80

How do I make them assigned into an automatic variable?

Forms In PHP With Auto Tab
anyone knows how to achieve a form with at least 12 input fields that need an automatic tab since the application uses bar code reader?

Auto Run A 2nd Script ?
I have 2 scripts, After the 1st script is run/activated, i'll like it to automatically forward the result (POST) to the 2nd script ....

Auto Increment By More Than 1
I have a table that I want to automatically generate an account number. I previously developed a simple database using appleworks that allows one to enter the amount she needs to add to the ID field with each new record. MySQL does not allow for this so I figure I must add it to the PHP script. PHP Code:

What Will The Next Auto Increment Be?
I have a MYSQL table with a field that auto increments 'ID'. I need to know what the next ID will be. Is there a simple way to do this?

One solution I've thought of is to query all the records and sort it by ID, and then just take the last record +1. But that seems awfully inefficient. Does anybody have any other suggestions or know of any functions that will do this?

Auto Number
How to generate auto number for php? For example, every time I submit the details to another page, the number will add from 10001 to 10002.

Auto Backup
how will i take auto backup mysql database table data after 6 hours daily? i know that this is very easy to take backup database table or full database manualy by using mysql dump syntax but i need to take it autometicaly daily after 6 hours.

Auto Php Upload
Senario A:

I've a form actually .csv, when a user finished filling out the form,after that when user click save button auto upload the file .csv file from server A where original .csv file(testing server) to server B (life server).

Senario B:

Same concept but when user click save button,the save button disable and button upload will appear but cannot browser and it is possible to put value in input type="file"??? The reason don;t want user to have capability to browse server A(testing server).

Auto Increment
how when you have an auto-incremented mysql list? And you know how when you delete an entry, the entry's auto-increment value just gets dropped and skipped? What I need to know is if there is a way to sort of re-number the list, preferably using a Query, such as an ALTER command or something. Code:

Auto Load
I am tring to figure out how to do something. I am starting to build a collection of coomon used php class, kind of a framework but not really, that i will be using for all my site.  For instance i have a database class that handle all mysql database stuff.  I have a site class that handles html stuff(generating header/footer, form elements, etc..,

i just have all these classes included in 1 folder but it is starting get big and i would like to be able to start searating them with folders. the problem is how can i tell the auto load where the class is without changing the name of the class?

Auto Session_start();
Is there a way without code <?php session_start();?> ontop of each page to get that affect?

PHP Auto Counter
I want to be able to make a list of number in a colum that changes when a line is added to the middle of it. I have looked for it but cant find anything about it.
I will put an axample to explain myself better.

 #  |   |   |   |   |
------------------
 1  | a | a | a | a |
 2  | h | h | h | h |
 3  | n | n | n | n |
 4  | z | z | z | z |

Now i want to add a c value between  a and h

 #  |   |   |   |   |
------------------
 1  | a | a | a | a |
 2  | h | h | h | h |
                            <----------  3  | c | c | c | c |   I want it to get number 3  automatically and that the rest of the numbers rols one forward.
 3  | n | n | n | n |
 4  | z | z | z | z |

Auto Linebreaks?
Is there a certain way to 'auto-magically' add line breaks when enter is pressed?

That way, you don't need to say something like..

This is a message.<br /><br />

Messages are fun!
Normally, if you type...

This is a message.

Messages are fun!
It would turn out like this.

This is a message. Messages are fun!

Auto Drop Down Box
I need to create an auto drop down box. For example I already have a list of states that are pulled from the database. When the user selects a state, a drop down box below should populate with the cities from that state. (that's where I'm having trouble)

This is a search form so the results have to reflect what city and state they chose. (along with some other criteria)

I've searched all evening for instructions on how to do this and so far I've only seen javascript that you put directly in the code. If I have all 50 states along with their related cities that's an awful lot of code to put in the page.

Isn't there a way to automatically pull the cities from the database to populate the box when the user clicks a state? I have no idea where to start to make that work.

Getting Last Id Of The Auto-increment Key
I have two tables and I need to get the last id of the primary key in one of the tables. I did some searching and found a solution that works.

$sql=mysql_query("INSERT INTO (table) (column) VALUES ('test')") or die (mysql_error());
$insert_id=mysql_insert_id();
$num = $insert_id + 1;   //need to increase the last id by one to match new entry in other table

This works well. The downside is in order for this to work an actual value is filed into a new row of (table) after the last id found in (column) thus giving me a blank row. While this isn't too bad, I could imagine I'll end up with a bunch of empty rows in my table. Is there a way to prevent this from happening -- i.e., a bunch of empty rows?

Auto Run Scripts
This is probably a real simple thing to do but I have never done it before!

I have an apache server on my server (XAMPP) running PHP and I want to be able to programme it to run a php script at certain times.  Is this a server or PHP task and how would it be done?

Getting An Auto-increment Id?
When someone creates a topic, the following is executed:

$sql = mysql_query("INSERT INTO `reflexproj`.`topics` (`topic_name`, `topic_desc`, `poster`, `forumid`) VALUES ('". $posttitle ."', '". $desc ."', '". $sessionu ."', '". $forum ."');");

This inserts the topic into the topic table. However, then this is executed:

$sql = mysql_query("INSERT INTO `reflexproj`.`posts` (`poster`, `post`, `topicid`) VALUES ('". $sessionu ."', '". $fp ."' '". $id ."');");

This is meant to insert a post into the posts table that starts the topic. However, this is a problem. The problem is, that $id hasn't been defined.

My question is this, really: How do I get $id? Basically, I've got to find a way of getting an auto_increment value from a database. Anyone any ideas?

Auto Linking
i'm tryin go to do a auto link thing and i'm running into some problems with my mysql statements

$sql_query = "SELECT * FROM tags";
$result = mysql_query($sql_query) or die(mysql_error());
$result = mysql_fetch_assoc($result);

foreach($result as $res){
$res["tag"] = $tag;
$res["link"] = $link;
}
echo "Test".$tag;

$keyword_array = array(
$tag => $link,
);

How Can I Auto-save The .pdf?
i've gotten used to using the ezPDF class to create and stream a pdf.  Now i've encountered a project where I want the created pdf to be emailed rather than streamed to the browser. 

I'm comfortable enough with phpmailer to send the file if I can only figure out how to save the PDF.  The documentation for the ezPDF class mentions a function called ezOutput... but that seems to do the same thing as ezStream.

Auto Delete
This script was meant to delete a file after X days...in this case I wanted it to delete files that were older than 1 day except .htaccess. what the script is doing is deleting everything in the specified folders except htaccess even though the files are less than a day old. any suggestions? Code:

Auto Executing PHP Code
Right now i am on a matrimonial site. i wanna do an auto match finder. ie; there may be many registrations in the site. i wanna findout all those matched profiles on a daily basis, say by 12 midnight each day. i wanna get that list as a mail even if i didn't checked the admin screens. ie; the script should execute on 12 midnight each day automatically. is there any way. can i do it using PHP.

Get Last Auto-increment Number
I am inserting related data into 2 tables. The first table I insert into has an auto-incremented field. The second table i insert into has a field which needs to hold the same number as the number in the auto-increment field from the first table. I cannot auto-increment the field in the second table because the number will occur more than once in the second table.

How can I retrieve this auto-incremented number from the first table?

Auto Code Colouring
I am building a tutorial site and I was wondering what you had to do to a piece of text to make it automatically format the colour!

Eg. on this forum anything in the code/php BBtags the code is coloured for easy of editing and viewing!

Need Auto Save Code
Hi every oneI have to use auto save functionality just like gmail. If some already used such function then please send me code.

Pause An Auto-refresh?
I have a couple of php scripts running that allow users on line to
enter brief lines of text, chat style. When they are posting a line
of text and an auto-refresh command is executed, Internet Explorer
users lose the line they were in the middle of typing. I was
researching how to stop the auto-refresh if the form post box was in
use and found some reference to a "pause button" that can be placed on
the user side as HTML. Anyone know about this?

Auto-increment Field
I have query which returns the value of a auto-increment field last entered. That is:

$sqlquery = "SELECT MAX(field-id) from table";
$result = mysql_query($sqlquery);

The query itself seams to work fine alone, but when I run it in a php script and try to print $result it returns "Resource id #6" . No idea what this is or where it came from.

Auto-Increment And Deleting
When i delete a record from my MySQL database it works fine, but then when i reload the form to Insert another record, it sticks the record into the database but at the position where i deleted the record. Can someone show me a way of keeping the autoincrement at the last record in the database even after i delete a record?

Get Auto Number On Insert
i need to implement it in PHP so im posting this here. i have a table that auto numbers each row, and i need to get the primary key of each now row as it is added for further use.... for example: PHP Code:

How To Make Auto Run CD For PHP/ My SQL Project
How to make auto run CD for installation on Windows and Linux of PHP/My SQL project to any computer which already installed PHP & MySQL software.

MySQL Auto Increment
I have a site that is about to go into production
and it has a couple of tables that it uses that
could get quite large once in full swing, most of
them have a column called "id" and it auto
increments every time a new row is added. When
setting this up, what do you recommend using at
the column type and size. atm I have gone for a
big-int with the size of 20. I wonder over time
will 20 be enough... Should I just think of a big
number and use it?

Anyone else in this situation and what would you do?

Auto Linking To Html
Iam building a login form page in PHP that runs a PHP script. The form contains a $variable that passes to the script. Then I would like to direct automatically to the link below: http://www.$variable.com/login.htm What would the PHP command be to action the above link?

I Am Trying To Pipe In Some Auto-generated PHP Into Php.exe
I am trying to pipe in some auto-generated PHP into php.exe, to no
avail:

PHP / MySQL - Auto Increment Id
I just did my first PHP/MySQL database (a simple survey) that works
fine. It is ordered by an id field that auto increments. Apparently, one
entry repeated (I'm thinking the user hit the submit button twice). So,
I deleted a record. My question is, how do I make it so the next entry
will use the id# that I deleted, so there won't be a gap in the id numbers?

Problems With The Auto-index.
I'm setting up a guestbook using PHP and MySQL. It's set up to read one entry at a time. I would like to be able to delete entries if needed. The problem is that the auto_increment of the id continues where it left off, even if some of the entries have been deleted.....

The script that reads the entries relies on the id to find them in the correct order. So it creates 'blank' entries where the script tries to read id numbers that no longer exist.

I suspect that the solution might be to change the read script so that instead of reading 'the entry with id# ___' it reads 'the ___ entry in the table'. I just dont know how to set this up.


Copyright © 2005-08 www.BigResource.com, All rights reserved