php-general Digest 26 Dec 2008 05:51:58 -0000 Issue 5865

Topics (messages 285064 through 285070):

Re: MERRY XMAS
        285064 by: ragsagar
        285065 by: ragsagar

Re: Round to a given value?
        285066 by: Anders Norrbring
        285068 by: Anders Norrbring
        285070 by: Jim Lucas

Re: Passing var from one page to itself
        285067 by: Aslan

Re: Help with a Search Function
        285069 by: Vicente

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Merry Christmas to all....from India :)

-- 
blog : ragsagar.wordpress.com
site : ragsagar.freehostia.com

--- End Message ---
--- Begin Message ---
 Merry Christmas to all....from India :)




-- 
blog : ragsagar.wordpress.com
site : ragsagar.freehostia.com

--- End Message ---
--- Begin Message ---
> > On Wed, 2008-12-24 at 20:38 +0100, Anders Norrbring wrote:
> > > Rounding an integer to the closest divisor by ten is easy with
> > round() and a
> > > negative precision, but I turn out to be lost if I want to round to
> a
> > given
> > > number..
> > >
> > > Example, round to the closest 5000, or closest 400? Any great
> ideas?
> > >
> > > Thanks, and merry x-mas!
> > > Anders.
> > >
> > >
> > >
> > http://www.alixaxel.com/wordpress/wp-content/2008/05/Round.php
> >
> > Someone was way ahead of you and found the answer and posted on the
> PHP
> > manual pages back in May. The manual pages are always useful, even if
> > only for the user-written functions!
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> 
> 
> Thanks Ash.
> I browse the pages frequently for ideas, and also did it yesterday..
> However, I must have missed that post, maybe because it was so small in
> the
> list.. ;-)
> 
> Thanks for the tip!
> 
> Anders.


I cheered too fast.. That function rounds to the closest 500, literally..
So, 1100 is rounded to 1500, not to 1000 which would be the correct value.

Any more ideas from anyone? My mind isn't working right at the moment, so a
"ready-to-plug-in" function would be really great!

Thanks,
Anders.



--- End Message ---
--- Begin Message ---
> > > On Wed, 2008-12-24 at 20:38 +0100, Anders Norrbring wrote:
> > > > Rounding an integer to the closest divisor by ten is easy with
> > > round() and a
> > > > negative precision, but I turn out to be lost if I want to round
> to
> > a
> > > given
> > > > number..
> > > >
> > > > Example, round to the closest 5000, or closest 400? Any great
> > ideas?
> > > >
> > > > Thanks, and merry x-mas!
> > > > Anders.
> > > >
> > > >
> > > >
> > > http://www.alixaxel.com/wordpress/wp-content/2008/05/Round.php
> > >
> > > Someone was way ahead of you and found the answer and posted on the
> > PHP
> > > manual pages back in May. The manual pages are always useful, even
> if
> > > only for the user-written functions!
> > >
> > >
> > > Ash
> > > www.ashleysheridan.co.uk
> >
> >
> > Thanks Ash.
> > I browse the pages frequently for ideas, and also did it yesterday..
> > However, I must have missed that post, maybe because it was so small
> in
> > the
> > list.. ;-)
> >
> > Thanks for the tip!
> >
> > Anders.
> 
> 
> I cheered too fast.. That function rounds to the closest 500,
> literally..
> So, 1100 is rounded to 1500, not to 1000 which would be the correct
> value.
> 
> Any more ideas from anyone? My mind isn't working right at the moment,
> so a
> "ready-to-plug-in" function would be really great!


Dear Lord.. It seems like it was so much simpler than I would even guess..
Maybe that's why I didn't see it?

function roundto($number, $to) {
        return round($number / $to) * $to;
}

Anders.


--- End Message ---
--- Begin Message ---
Anders Norrbring wrote:
On Wed, 2008-12-24 at 20:38 +0100, Anders Norrbring wrote:
Rounding an integer to the closest divisor by ten is easy with
round() and a
negative precision, but I turn out to be lost if I want to round
to
a
given
number..

Example, round to the closest 5000, or closest 400? Any great
ideas?
Thanks, and merry x-mas!
Anders.



http://www.alixaxel.com/wordpress/wp-content/2008/05/Round.php

Someone was way ahead of you and found the answer and posted on the
PHP
manual pages back in May. The manual pages are always useful, even
if
only for the user-written functions!


Ash
www.ashleysheridan.co.uk

Thanks Ash.
I browse the pages frequently for ideas, and also did it yesterday..
However, I must have missed that post, maybe because it was so small
in
the
list.. ;-)

Thanks for the tip!

Anders.

I cheered too fast.. That function rounds to the closest 500,
literally..
So, 1100 is rounded to 1500, not to 1000 which would be the correct
value.

Any more ideas from anyone? My mind isn't working right at the moment,
so a
"ready-to-plug-in" function would be really great!


Dear Lord.. It seems like it was so much simpler than I would even guess..
Maybe that's why I didn't see it?

function roundto($number, $to) {
        return round($number / $to) * $to;
}

Anders.



Isn't what you wrote the same as the following?

function Multiple($number, $multiple)
{
    return round($number / $multiple) * $multiple;
}

The above was on the page that Ash linked to...

Named differently true, but it was right there in front of you...

--- End Message ---
--- Begin Message ---
Hi there,

Thanks so much everyone I really appreciate the help! I have it working now using hidden tags from each page to the next.
www.adslgeek.com/troubleshooter

Merry Christmas!
Cheers
Aslan

tedd wrote:
At 4:10 PM +1300 12/21/08, Aslan wrote:
Hey there,

I have a problem where I have a simple -script that I am wanting to pass back to itself three times
1) Symptoms - > 2) Troubleshooting questions 3) Answer to problem
-snip-

I have it currently all on one page, but it isn't quite what I was after
..
Any help would be appreciated!

Hi Aslan:

Keeping it all on one page (one script) is fine -- no problems with that.

Here's the technique I use.

$step = isset($__POST ['step']) ? $__POST ['step'] :1;

if($step == 1)
   {
   // do the first page stuff (Symptoms)
// with a POST form that has an <input type="hidden" name="step" value="1">
   }

if($step == 2)
   {
   // do the second page stuff ( Troubleshooting questions)
// with a POST form that has an <input type="hidden" name="step" value="2">
   }

if($step == 3)
   {
   // do the third page stuff (Answer to problem)
// with a POST form that has an <input type="hidden" name="step" value="3">
   }

If you want to pass variables between pages (trips from client to the server nad back again), you have four options, namely: 1) writing/reading a file; 2) writing/reading a database entry; 3) passing via a POST/GET; 4) or using SESSIONS.

For most things, I prefer using POST/GET and/or SESSIONS. Try this format:

$var1 = isset($_POST['var1']) ? $_POST['var1'] : null;
$var2 = isset($_SESSION['var2']) ? $_SESSION['var2'] : null;

That's the way I pass data between client and server.

However, what you are describing sounds a bit like this:

http://webbytedd.com/b/exam/

With this example, I'm not passing anything to the server -- everything is kept client-side and is quick.

If interested, all the code is there.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com


--- End Message ---
--- Begin Message ---
Terion wrote:

> Hey Everyone, been steaming right along for a couple days but now I'm stuck
> on writing a search function, could you all take a look at it and see what
> it could be, I will mark the line throwing the error in red, I did try just
> commenting out that line and searching for a record by OrderID that I know
> is there but it does not return anything , I am trying to search several
> tables in one db:

you can add some code to get more error information:

<?php
session_start();
error_reporting(E_ALL);
include("inc/dbconn_open.php");

function error_mysql($query) {
  die ("Error <b>".mysql_errno().": ".mysql_error()."</b>
        <br>SQL query: <b>".$query."</b>");
}


// ...then you can end your last line with this:

$result = mysql_query($sql) or error_mysql($sql);




hope it helps,



--- End Message ---

Reply via email to