Php implementation recent browsing problems

Source: Internet
Author: User
Php implementation of the latest browsing problem functionproduct_view ($ pdid) // What is the value represented by the parameters in this function {$ limit = 8; if (is_numeric ($ pdid) & amp; & amp; $ pdid & lt; & gt; 0) {if (! $ _ SE php implementation of recent browsing problems
Function product_view ($ pdid) // What are the values of parameters in this function?
{
$ Limit = 8; if (is_numeric ($ pdid) & $ pdid <> 0)
{
If (! $ _ SESSION ['PD _ viewed'])
{
$ _ SESSION ['PD _ viewed'] = array ($ pdid );
}
Else
{
If (count ($ _ SESSION ['PD _ viewed '])> = $ limit)
{If (! In_array ($ pdid, $ _ SESSION ['PD _ viewed'])
{
$ _ SESSION ['PD _ viewed '] = array_reverse ($ _ SESSION ['PD _ viewed']);
Array_pop ($ _ SESSION ['PD _ viewed']);
$ _ SESSION ['PD _ viewed'] [] = $ pdid;
$ _ SESSION ['PD _ viewed '] = array_reverse ($ _ SESSION ['PD _ viewed']);
}
}
Else
{
If (! In_array ($ pdid, $ _ SESSION ['PD _ viewed'])
{$ _ SESSION ['PD _ viewed'] [] = $ pdid;
}
}
}
}
}
Please help me explain this program in detail. I don't know much about it. what are the variables in the session?

------ Solution --------------------
These things need to be parsed in conjunction with the entire system.

The pdid should be the product number, so the automatic number in the database or the number of the custom product itself is unclear.

The session is to add the viewed numbers to the array pd_viewed.





Finally, you seem to have posted a lot of posts but none of them are closed. if you continue to do so, no one will answer your questions. if you do not know how to fix the posts, go to the community to help you.
------ Solution --------------------
Function product_view ($ pdid) // $ pdid the column number currently in use
{
$ Limit = 8; // specify the maximum capacity
If (is_numeric ($ pdid) & $ pdid <> 0) // $ pdid is a number and is not 0
{
If (! $ _ SESSION ['PD _ viewed ']) // if it has never been saved
{
$ _ SESSION ['PD _ viewed '] = array ($ pdid); // Save
}
Else
{// Otherwise, insert it to the front of the array.
If (count ($ _ SESSION ['PD _ viewed '])> = $ limit)
{If (! In_array ($ pdid, $ _ SESSION ['PD _ viewed'])
{// The following code only requires writing array_unshift ($ _ SESSION ['PD _ viewed'], $ pdid );
$ _ SESSION ['PD _ viewed '] = array_reverse ($ _ SESSION ['PD _ viewed']);
Array_pop ($ _ SESSION ['PD _ viewed']);
$ _ SESSION ['PD _ viewed'] [] = $ pdid;
$ _ SESSION ['PD _ viewed '] = array_reverse ($ _ SESSION ['PD _ viewed']);
}
}
Else
{
If (! In_array ($ pdid, $ _ SESSION ['PD _ viewed'])
{$ _ SESSION ['PD _ viewed'] [] = $ pdid;
}
}
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.