PDA

View Full Version : PHP questions



Freeman
05-14-2007, 08:50 PM
I am applying for a job and I need to show them that I can use the internet to find the answers I need. I have just a few questions. What does Alert do, what does TRUNC() do, and what does **ALERT** Date will convert to NULL do. Thanks for any help, JF

mwinter
05-14-2007, 08:57 PM
I am applying for a job and I need to show them that I can use the internet to find the answers I need.

Doesn't that then mean that you need to search for answers, rather than ask others to do it for you?

Freeman
05-14-2007, 09:14 PM
They said that I could use the internet. That doesn't mean that I can't use the people on the internet as a resource. Think of it as you are part of the internet because that is only how I know you. I have also found most of the stuff myself but I can't find these few things.

mwinter
05-14-2007, 09:30 PM
What does Alert do

I don't know of any "Alert" in relation to PHP, but of course there is the global function, alert, in browser object models. You can find more about that, if you need to, in any browser scripting documentation.



what does TRUNC() do,

Again, I don't know of a "TRUNC" in PHP, but there is a built-in TRUNC function in SQL. An SQL reference will tell you more.



what does **ALERT** Date will convert to NULL do.

That seems a bit muddled, so I can't tell you anything.

Freeman
05-14-2007, 09:34 PM
NVM I found what I needed after a couple more hours.

mwinter
05-14-2007, 10:01 PM
I am supposed to tell them all about what this does.

It should depend upon what DBMS you're using. I would guess perhaps PostgreSQL. It would certainly be very boring under MySQL. I'm still not sure what the "Alert" is all about, though.



... I don't know what the numbers in the box_addr_stop,6,1 lines are all about.

Well, substr is a built-in SQL function, so look it up in a SQL reference. :)

Freeman
05-14-2007, 10:33 PM
while ($row = getrow($result))
{
$highest = 0;
foreach ($row as $value)
{
$value = trim($value);
$transnum = substr($value, (strlen($value) - 5));
if( $highest < $transnum ) $highest = $transnum;
}
}
What in the frick is this thing doing? It is a loop, thats all I have been able to figure out.

mwinter
05-15-2007, 06:15 PM
while ($row = getrow($result))
{
$highest = 0;
foreach ($row as $value)
{
$value = trim($value);
$transnum = substr($value, (strlen($value) - 5));
if( $highest < $transnum ) $highest = $transnum;
}
}

What in the frick is this thing doing? It is a loop, thats all I have been able to figure out.

Think about it logically. A foreach statement is used, which tends to involve an iterable object; an array, for example. There's a variable, $highest, and assignment to that variable later involves a relational comparison using that same variable.

boogyman
05-15-2007, 06:24 PM
something inside of me thinks that if you cannot figure that out that you are not ready for a web development "job" maybe an apprenticeship / internship but not a "job"

Freeman
05-15-2007, 09:26 PM
something inside of me thinks that if you cannot figure that out that you are not ready for a web development "job" maybe an apprenticeship / internship but not a "job"

In all fairness I started learning this five days ago and I think I am doing pretty good as it is. They know I don't know php but they said as long as I can learn I will be ok. So if this is comparing two things then it is searching for something in a set of predefined guidelines with the appropriate variables. Is it searching or comparing or both?

mwinter
05-15-2007, 09:35 PM
So if this is comparing two things then it is searching for something in a set of predefined guidelines with the appropriate variables. Is it searching or comparing or both?

I don't think I can really explain more without just giving you the answer, though the name of the variable I mentioned explicitly in my previous post should surely give you a big clue.

Freeman
05-16-2007, 04:17 AM
This is used when a search is being performed. It has a defined thing that it is looking for and looks at one line of database code at a time. When it is done looking in that line it adds one to the location of where it should be searching so that it moves to the next line. Is that it? I think it is.

mwinter
05-16-2007, 05:43 PM
This is used when a search is being performed.

It should be fairly clear what that search is, though, and probably what your potential employers want to know.



It has a defined thing that it is looking for and looks at one line of database code at a time.

From only the code posted, there's no definite sign of database involvement: the row from the function, getrow, could be from some other source.



When it is done looking in that line it adds one to the location of where it should be searching so that it moves to the next line.

That's the basis of iteration - moving from one position to the next - but there's more obvious things in the code: the comparison, subsequent assignment, and what that implies for the value of a particular variable are significant.