Fredrik.r Posted February 15, 2006 Posted February 15, 2006 Hi, As default the reviews pages shows the customers full name. I would prefer "by firstname, city". When looking in the Reviews database table there is no first name and city. I believe I will need to get these values from the Customers table. I would very much appreciate an example of how this can be done. Can I fetch the first name and city from the Customers table or is it possible to add these in the Reviews database table? Thanks!!
Guest Posted February 15, 2006 Posted February 15, 2006 Its the product_reviews_write.php you have to modify. There is an sql line there (line-27) that pulls out the customers first and last names. Modify it to pull out the columns you want. Then when the form is processed (action - few lines down) it inserts the entry by appending and setting the customer colums as customer's name. Just use the columns you pulled out from the first query (line-48).
Fredrik.r Posted March 3, 2006 Author Posted March 3, 2006 I did the following changes in products_review_write.php; $customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); to $customer_query = tep_db_query("select customers_firstname, ab.entry_city from " . TABLE_ADDRESS_BOOK . " ab, " . TABLE_CUSTOMERS . " where ab.customers_id = '" . (int)$customer_id . "' and customers_id = '" . (int)$customer_id . "'"); and tep_db_query("insert into " . TABLE_REVIEWS . " (products_id, customers_id, customers_name, reviews_rating, date_added) values ('" . (int)$HTTP_GET_VARS['products_id'] . "', '" . (int)$customer_id . "', '" . tep_db_input($customer['customers_firstname']) . ' ' . tep_db_input($customer['customers_lastname']) . "', '" . tep_db_input($rating) . "', now())"); $insert_id = tep_db_insert_id(); to tep_db_query("insert into " . TABLE_REVIEWS . " (products_id, customers_id, customers_name, reviews_rating, date_added) values ('" . (int)$HTTP_GET_VARS['products_id'] . "', '" . (int)$customer_id . "', '" . tep_db_input($customer['customers_firstname']) . ' (' . tep_db_input($customer['entry_city']) . ")', '" . tep_db_input($rating) . "', now())"); $insert_id = tep_db_insert_id(); but then I got an error; 1052 - Column 'customers_id' in where clause is ambiguous select customers_firstname, ab.entry_city from address_book ab, customers where ab.customers_id = '7' and customers_id = '7' [TEP STOP]
Guest Posted March 4, 2006 Posted March 4, 2006 yea specify the table identifier: your code: $customer_query = tep_db_query("select customers_firstname, ab.entry_city from " . TABLE_ADDRESS_BOOK . " ab, " . TABLE_CUSTOMERS . " where ab.customers_id = '" . (int)$customer_id . "' and customers_id = '" . (int)$customer_id . "'"); change it to this: $customer_query = tep_db_query("select c.customers_firstname, ab.entry_city from " . TABLE_ADDRESS_BOOK . " ab, " . TABLE_CUSTOMERS . " c where ab.customers_id = '" . (int)$customer_id . "' and c.customers_id = '" . (int)$customer_id . "'");
Fredrik.r Posted March 4, 2006 Author Posted March 4, 2006 Thank you! Is it possible to change already written reviews in reviews.php and product_reviews.php (I don't use product_reviews_info.php). There were 33 reviews written with firstname lastname before I changed this. I suppose it is not possible without changing in my database?
AlanR Posted March 4, 2006 Posted March 4, 2006 I suppose it is not possible without changing in my database? Right. You'll have to change the entries in the db. With phpMyAdmin this wouldn't take very long. Just browse table reviews and they're easy to see. Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management)
Fredrik.r Posted March 4, 2006 Author Posted March 4, 2006 Hi Alan! Do you mean I should just manually change customers_name in table Reviews to Firstname and City? Customers_name in Reviews does not affect or is linked to anything else? (It does not seem like that but I want to be sure)
AlanR Posted March 4, 2006 Posted March 4, 2006 Hi Alan! Do you mean I should just manually change customers_name in table Reviews to Firstname and City? Customers_name in Reviews does not affect or is linked to anything else? (It does not seem like that but I want to be sure) I can't see why anything else would need the value of that field. It's already a composite built from other values. Just change one and then look for problems. You can always change it back. edit: Remember that you wouldn't be doing anything that your new code is not already doing. Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management)
honk_alert Posted March 19, 2006 Posted March 19, 2006 What if customers have the same first name and live in the same city? :blink:
rabbitseffort Posted March 19, 2006 Posted March 19, 2006 Just wanted to say thanks for this post--it is useful and should be standard to osc---I do agree with aaron above about maybe 2 customers in the same city but that wouldnt really be of importance--the anonymity is. "I must admit that I personally measure success in terms of the contributions an individual makes to her or his fellow human beings." ---Margaret Mead--- "The answer is never the answer. What's really interesting is the mystery. If you seek the mystery instead of the answer, you'll always be seeking. I've never seen anybody really find the answer -- they think they have, so they stop thinking. But the job is to seek mystery, evoke mystery, plant a garden in which strange plants grow and mysteries bloom. The need for mystery is greater than the need for an answer. --Ken Kesey"
Fredrik.r Posted March 20, 2006 Author Posted March 20, 2006 What if customers have the same first name and live in the same city? :blink: Well, in that case it will look like the same person has written both reviews.. :/
Fredrik.r Posted March 20, 2006 Author Posted March 20, 2006 Just wanted to say thanks for this post--it is useful and should be standard to osc---I do agree with aaron above about maybe 2 customers in the same city but that wouldnt really be of importance--the anonymity is. Yes it is a compromise.. But I also think the anonymity is more important.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.