Creating Interactive Product Selector with PHP - php

I am wanting to do something similar to this:
http://www.dimarzio.com/pickup-picker
My question involves the concept rather than any specific code on how to execute this.
For example, we are selling violins and we want the user to input info about their playing style, and give them the three best violins based on their entry. This is the data I've been given:
So if the user inputs Expert, Hard, Rock, and Dark I will get data sets of violins consisting of: Cannon, Soil, Ysaye, K.Joseph, Heifetz // Cannon, Kreisler, Soil, Heifetz // Kreisler, Diable, Vieuxtemps // Cannon, Diable, Plowden
Out of those I need to output to the user the three best choices for them. Cannon is listed in 3 out of the 4, so that has to be #1. Now there are three more violins that match two of the four criteria. The Soil, Kriesler and Diable. In order to drill that down to two choices, I would think the questions would have to be ranked according to importance. For instance Tone is most important, followed by bowing style, musical genre, and skill level. Based on that ranking, the program should choose the Diable and Kreisler.
I am not entirely sure how to approach this. Since this data will not change frequently, should this even get the database involved? Should the info just be stored in a multi-dimensional array? Once the data is in an array, whether from the DB or not, how should I go about programming the logic to examine the arrays in order of importance and grab the violins that are most relevant?
Any help is much appreciated! I figured this was going to be easy, until I actually started thinking about it!

To me this sounds like a sorting problem. I don't know anything about violins so I'm unable to absorb much from your example, but anyway...
You're probably familiar with how a database sorts across multiple columns. If I said order by firstname, lastname, phone it would compare the firstnames, and only if theres a tie, would it then compare the last names, and again if there's a tie, then it would compare the phone numbers.
Once sorted, you pick the top N entries and display.
You can do custom sorting like this in php code too. For example, you would want to order by num occurances in a list, tone, bowing style, etc...
Thats the gist of it. I would store it in a database merely because its data and for the most part, its a great place to keep it. Plenty of import export and other data management, viewing, editing and other functionality freebies come with using a database.
If you need some sample code that mimics the database order by clause, I can dig some up I know I have somewhere.

We have a start up company that solves the issue you are outlining. Basically we have created a semantically enabled product selector which guides users through a selection process to find a product or a solution.
Although we have designed our product for a different market sector (not vioins), I think it would help to solve the issue you describe.
The data is hosted on Amazon AWS and we have built an API so the product selector can be incorporated into iPhone apps, Android apps, websites etc.
If you want, our website www.productworld.com where you will get my contact details.

Related

Zend Lucene indexing/returning cross-reference part results on large data set

We have a “cross-reference” module that I’m attempting to build into a Zend Lucene search index and having major performance issues. Tried this ten different ways and either zero/bad results, or super accurate and extremely slow performance. The current solution described below results in accurate results, but painfully slow on our fairly large data set.
Essentially, let us say we have ACME Part #ABC123 and a couple of other part numbers. Manufactured by ACME, and distributed by WalMart, Costco, and Target. Each of these three stores has their OWN part number that they apply to the product on their website. The following table is a pretty clear example:
So, what we want to see is when a user searches for “Target 1009936”, would return both CASE and BOX sizes of ACME Part #ABC123. When I search for “WalMart WM0002353CS”, would return CASE size for ACME Part #DEF567. And so on.
The fact that some wholesaler/distributors work the unit of measure into their numbering system, and some to not, is irrelevant. What is relevant is getting Lucene to index and retrieve the data quickly, which is not currently the case for our database of over two million product SKUs.
In order to achieve this what we have done is to add an indexed field for each wholesaler, where cross-reference data for that item exists (let’s just call the fields crosstar, crosswal, and crosscostco. So, in this example we have cross-reference data for all, but in reality we only have for some (but a LOT… millions upon millions of cross-references). So, in this case, were I to save a log on the $hit->crosstar/crosswal/crosscostco values into a log file, we would see:
=>10001123
crosstar: 1009936
crosswal: WM0001256CS
crosscostco: CC5991243CA
crosstarfull: Target 1009936
crosswalfull: WalMart WM0001256CS
crosscostcofull: CostCo CC5991243CA
We are indexing both the part, and separately, wholesaler’s name + part (a lot of people in our business actually search this way - I know it sounds crazy), which is why there are six fields beneath the sku / primary key, not three.
Problem is, the way the data is being tokenized and indexed, because the wholesaler names are causing too much similarity between each of the indexed values, it’s causing Lucene to work a lot harder and longer to locate the record. And when a user types in simply “Target” or “WalMart” or “Costco”, it’s like brain overload, man. Poof.
I am a mediocre developer at best, and the fact that I cannot figure this out is pretty much proof of that. Does anyone have any recommendations on how this scenario could be reworked to produce the desired results?

Computing word, image, video and audio file counts in a scalable way?

I am attempting to gather as much interesting metadata as possible to display for readers of an expression engine site I'm developing and am looking for guidance on methods (or indeed the feasibility) of computing specific bits of this metadata in a scalable way.
Expression Engine allows for quite a few bits of data to be gathered and displayed natively, for example post totals and dates, comment totals and dates, tag totals, etc. However I'm specifically interested in finding a method to count and display totals for data like number of words, images, videos, or audio files, not only within individual posts but across a channel, as well as site-wide.
These totals would be displayed contextually depending on where they were accessed. So for example search results would display the number of words/images/etc contained in individual posts, a channel's "about" page would display totals for the entire channel, and the site's "about" page would display site-wide totals. I'm not clear on the best approach or whether this is even really feasible.
I'm not a professional web designer, so my knowledge of anything beyond html5/css3/ee is somewhat limited, but I've pondered:
Entering these numbers on a per-post basis, in custom fields, but am not clear on whether they can be added together for channel and site-wide totals.
Using PHP's "count" method, but am not very familiar with PHP so unsure of it's appropriate.
Using some mySql method to query the database, again unsure.
Utilizing the Expression Engine "Query Module." !?
Using some Jquery plug-in to do the counting individually and then adding after the fact.
It may be that the counting of words, images, video, and audio files and the scalability are different questions all together but the truth is I'm very confused as to what avenue to even explore. So any and all suggestions or guidance would be greatly appreciated.
Update: I'm looking into database methods to collect and add the results but am still interested in identifying the best ways to actually perform the word/image/video/audio file counts.
There's many solutions but I have a few in mind that may help you out. I'll just show the one I like really well that I even use for my own site.
One solution is to make a count column in tables you are interested in that is automatically updated when someone posts or does something. You can also make a new table called globalcount or whatever that counts everything site wide. This can then later just be displayed. You would need to first have a method/function of counting words and such if you want that info. And when someone makes a post, just count one up from the previous.
The above is what I use. I use a misc table (It has one row that contains all the data. You could instead make each row contain your info like 'name' 'value') that looks something like:
(`views`, `totalusers`, `totalgroups`, `totalthreads`, `totalposts`, `totalarticles`, `totalcomments`, `totalpms`, `activeusercount`)
And in something like my 'news' table I use 'totalcomments' to count the local comments posted in that article. So I have both the local and global comments.
In my case, if I wanted to update 'totalusers' in the 'misc' table after a new user registers, I'd just call my $misc array and go: $newtotalusers = intval($misc['totalusers'] + 1);
mysql_query("UPDATE `misc` SET `totalusers`='$newtotalusers'");
Or you could instead just use "totalusers+1".
Same can be done with any other thing you wish to do, such as with any file count or visa versa. Hope this helps :)
One last thing, you could also make a script that in the case the data becomes off because of an error that would update and fix any table's count values.

Integrating a 1-10 voting system effectively without common pitfalls

I'm planning on integrating a reasonable ranking/voting system into an existing application.
I'm familiar with how the traditional 5 star rating systems work and know the common pitfalls/problems associated with them therefore was wondering if there is other ways (I've heard of Wilsons, Bayesian etc. but not really sure on how to implement this with the below structure):
I'm planning on allowing users to vote on content between 1 to 10 via the contents page.
The score and total votes for that content will be displayed on the contents page.
I will also be displaying/listing the Top 10 Content so I'd need the method to be fair/realistic and not make a vote of 10 with total votes of 1 to go straight to number 1.
I'm using PHP and MySQL, I have a table for the content (which has a content_id which I guess I can JOIN on).
I'm wondering if you can suggest a way/method which achieves the above, I'd appreciate if you can attach some example PHP code and example MySQL schema so I can better understand it, as I've google'd and may have found potential solutions such as Wilsons and Bayesian...yet they provide a lengthy article with confusing mathematical equations - and mention no way which achieves the above (ie. the score....and implenting the method in PHP/MySQL) or atleast due to there not being any example PHP/MySQL code me misunderstanding this.
Perhaps this is easier then I think - I don't know as I've never had the need to implement this sort of "more complex" ranking/voting functionality before - so I'd appreciate your responses.
You should start by watching this video on youtube : Building Web Reputation Systems.
To emphasize the point, let me direct you to XKCD.
As for DB structure, you need following parts:
list of items ( with total_votes column )
list of user, which have voted
intersection table for the items-users ( with rating column, if you go with 5star thing )

Database structure for Tests

well, im really new to mysql, and i have no idea to do what i am intending to, or atleast not the efficient way.
i have to make a database that will hold people's information
within it every person has 3 courses to pass(courses as in educational courses) lets say its stage 1, 2 and 3, they cannot start course 2 without completing course 1
every course has 10 tests, they have the same name (eg. there is a test called example1 in course1 and also a test called example1 in course2, but its more difficult)
there aren't grades, just passed or failed
and lastly they are permitted into taking each test 3 times, i want to store the date(every try) and also who was the applier of the exam(every try), the names of the "teachers" are on a table
It is not a matter of mysql or php.
You should learn about Database Modelling.
And then use any of these tools (I like DB Designer for modelling)
Then you should learn how to integrate PHP and MySQL
Try Sakila database created by mySql, this is an example database used for training. You'll learn a few tricks from there, quite useful before creating your own database or maybe even before reading some books or the theme.
In additon to patricio's answer (which I consider valuable and good pointers). Take what you have written above and extend it. Find the key works in your description (i expect this will include people, course, test ...). For each key word identify all details you need to hold.
E.g. "I have to make a database that will hold peoples information" And for people I need to know ... maybe first name, last name, data of birth, employee number, etc. What ever details of a person is relevant to you. List them in a spreedsheet or document. Repeat this for each key word.
Then consider items you need to know to run the system, your last bullet point heads in this direction. Identify any new key words from that and then details you need to know about those key words.
Take your list of details and normalise it. As a general rule of thumb aim for 3rd normal form. In most cases it appears to be a workable compromise between higher levels of normalisation and not doing it. Maybe one of those 80/20 rules where by with 20% of the effort it takes to get there (as opposed to normalising to 6th normal form) you get 80% of the benefit of normalising.
Put together a proposal and feel free to come back for us to critique it if you want.

Array of all subjects

i want two arrays first one of all subjects and the second of all degrees which study in all universities (all over the world)
But a big problem is that i dont know how many subjects and how many
degree are there.? (in all over the world)
I just want two array the remaining logic i have made already.
All subject array list must be like.
$subject[0]=>'Computer Science',
$subject[1]=>'Mathematics',
$subject[2]=>'Engineering',
$subject[3]=>'Physics',
...
And secondly array of all degrees must be like.
$degree[0]=>'BS',
$degree[1]=>'MS',
$degree[2]=>'BA',
$degree[3]=>'MA',
...
Keep in mind that
**
I dont know how many subjects and how
many degree are there.? (in all over
the world)..
**
I just want these two categories in two individual array & thats all....
Could any one help me.?
Thanks.
Your problem appears to be twofold; there's the issue of getting hold of the data, and the issue of storing it in a manner which allows effective retrieval and use.
Obtaining the data is likely to be your biggest problem; you're literally asking for information about every institution in the world (or at least, as many as you can get). The available qualifications and nomenclature varies widely between different countries, and the list of courses at any given institution is going to be vast.
Finding a single decent, machine-readable source for this information is probably not going to happen. Your best bet would be to try and find multiple sources, but I'm struggling to think of any really good ones off the top of my head, and Google isn't looking too promising. You could attempt to scrape data from sites such as the Universities and Colleges Admissions Service (the UK body which basically catalogues higher education) - I've linked to their "course list" pages. Whether similar bodies (and similar data sets) exist for other regions, I've no idea.
The second problem is quite straightforward; you're going to have a ton of data, so you'll need to store it in a database. Then again, it's not that straightforward. Presumably, you want to catalogue courses by institution, and institutions by country, so make sure you normalise the data a little. You'll probably need to do some work to identify equivalent degree grades (as mentioned above) between different countries.
I don't understand exactly your question. But if you're trying to fetch records from your database and deposit 'em into an array, mysql_fetch_array() is what you need: http://php.net/mysql_fetch_array
As far as i could understand your question, you need to know how to store subjects in an array. See arrays in php. If you are looking for storing your subjects in database then see php and mysql tutorial. Because you want to store unknown number of subjects and degrees, don't use something like:
$subject[0]=>'Computer Science',
$subject[1]=>'Mathematics',
$subject[2]=>'Engineering',
$subject[3]=>'Physics',
Instead use:
$subject[]=>'Computer Science',
$subject[]=>'Mathematics',
$subject[]=>'Engineering',
$subject[]=>'Physics',
This will add subjects to the array without your puting index manually.

Categories