Advertisement

03.29.2008 at 10:30AM PDT, ID: 23279627
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.5

Compare Items

Asked by pertrai1 in PHP and Databases, PHP Scripting Language

Tags:

Hi all, I found a great piece of work, I believe, from here and I have had a hard time implementing it. It is to compare items on my website. I have attached the code and when I go to comparetest.php this is what I get:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Items,Compare)' at line 1

I do not know where Items, Compare is coming from.

Any and all help would be appreciated.

Thank you.
RobStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
------view_category.php-----
<form id="compare" name="compare" method="post" action="camparetest.php">
                  <td colspan="2" align="center"><table width="800" border="0" cellspacing="3" cellpadding="1">
                    <tr align="center">
                      <td><table width="100%" cellpadding="5" cellspacing="10" >
                        <tr>
                          <?php
$products_endRow = 0;
$products_columns = 4; // number of columns
$products_hloopRow1 = 0; // first row flag
 
do {
 
    if($products_endRow == 0  && $products_hloopRow1++ != 0) echo "<tr>";
   ?>
                          <td valign="top" bgcolor="#FFFFFF" class="productborder"><table width="100%" border="0" cellpadding="3" cellspacing="2">
                            <tr><td>
                              <input name="compare[]" type="checkbox" class="emailbox" id="compare[]" value="<?PHP echo $row_products['prod_id']; ?>" />
                            Compare Item
                            </td></tr><tr>
                              <td align="center"><img src="images/products/thumbnail/small/<?php echo htmlentities($row_products['small_thumb']); ?>" alt="<?php echo $row_products['prod_name']; ?>"  /></td>
                                    </tr>
                            <tr>
                              <td align="left"><a href="view_details.php?prod_id=<?PHP echo $row_products['prod_id']; ?>&amp;cat_id=<?PHP echo $row_products['cat_id']; ?>&amp;cat_parent=<?PHP echo $row_products['cat_parent']; ?>" class="brownlinks"><strong><?php echo htmlentities($row_products['prod_name']); ?></strong></a></td>
                                    </tr>
                            <tr>
                              <td align="left">Item #: <?php echo htmlentities($row_products['item_num']); ?></td>
                                    </tr>
                            <tr>
                              <td>Price: $<?php echo htmlentities($row_products['price']); ?></td>
                                    </tr>
                            <?PHP if ($row_products['clearance'] == '1') { ?>
                            <tr>
                              <td>Clearance Price: $<?php echo htmlentities($row_products['clear_price']); ?></td>
                                    </tr><?PHP } ?>
                            <?PHP if ($row_products['weekly_spec'] == '1') { ?>
                            <tr>
                              <td>Weekly Special: $<?php echo htmlentities($row_products['spec_price']); ?></td>
                                    </tr><?PHP } ?>
                            <?PHP if ($row_products['weekly_spec'] == '1') { ?>
                            <tr>
                              <td align="left"><strong>
                                <?PHP
                                    $price = $row_products['price'];
									$clearance = $row_products['spec_price'];
									$clearprice = $price - $clearance;
									$clearpercent = ($clearprice/$price)*100;
									echo 'You can save $'.$clearprice.'&nbsp;('.round($clearpercent,0).'%';
									
									?>
                                )</strong></td>
                                    </tr>
                                    
                            <?PHP } ?>
                            </table></td>
                                <?php  $products_endRow++;
if($products_endRow >= $products_columns) {
  ?>
                          </tr>
                        <?php
 $products_endRow = 0;
  }
} while ($row_products = mysql_fetch_assoc($products));
if($products_endRow != 0) {
while ($products_endRow < $products_columns) {
    echo("<td>&nbsp;</td>");
    $products_endRow++;
}
echo("</tr>");
}?>
                        
                        
                        
                        </table></td>
                          </tr>
                    <tr align="center">
                      <td><input type="submit" name="compare" id="compare" value="Compare Items" /></td>
                    </tr>
                  </table></td>
                    </form>
 
----camparetest.php----------
<?php
session_start();
$compareItems = isset($_REQUEST['compare']) ? $_REQUEST['compare'] : array();
 
//if $_SESSION["items_to_compare"] not exist or not an array, initialize this
if(!is_array($_SESSION["items_to_compare"]) || !isset($_SESSION["items_to_compare"]))
     $_SESSION["items_to_compare"] = array();
 
//if user has selected something to compare
if(count($compareItems)>0)
{
     //add the selected values in the session
     if(count($_SESSION["items_to_compare"])>0)
     {
          $_SESSION["items_to_compare"] = array_merge($compareItems, $_SESSION["items_to_compare"]);
          //remove the duplicate entries if any
          $_SESSION["items_to_compare"] = array_unique($_SESSION["items_to_compare"]);
      }
      else
          $_SESSION["items_to_compare"] = $compareItems;
     
}
 
if(!is_array($_SESSION["items_to_compare"]) || count($_SESSION["items_to_compare"]) == 0) {
  echo 'You havent selected any items to compare';
} else {
 
require_once('../Connections/catalog.php');
mysql_select_db($database_catalog, $catalog);
  $query = 'SELECT * FROM tblProducts WHERE prod_id IN ('.implode(',', $_SESSION["items_to_compare"]).')';
  $result = mysql_query($query) or die (mysql_error());
 while( $row = mysql_fetch_array($result) )
                             {
                 $photoId = $row[0];
                 $caption = $row[1];
                 $filename = $row[2];
                 $enddate = $row[3];
				 $result = array();
				 }
				 }
?>
[+][-]03.29.2008 at 10:40AM PDT, ID: 21237423

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 10:45AM PDT, ID: 21237444

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 10:53AM PDT, ID: 21237466

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 10:58AM PDT, ID: 21237489

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 11:01AM PDT, ID: 21237505

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 11:04AM PDT, ID: 21237513

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 11:09AM PDT, ID: 21237530

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 11:22AM PDT, ID: 21237579

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 11:32AM PDT, ID: 21237610

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 12:30PM PDT, ID: 21237801

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 12:49PM PDT, ID: 21237848

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 01:11PM PDT, ID: 21237914

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 01:23PM PDT, ID: 21237952

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 01:33PM PDT, ID: 21237998

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 02:08PM PDT, ID: 21238139

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 03:06PM PDT, ID: 21238329

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 03:07PM PDT, ID: 21238337

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 06:07PM PDT, ID: 21238955

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP and Databases, PHP Scripting Language
Tags: PHP and Databases
Sign Up Now!
Solution Provided By: Ray_Paseur
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.30.2008 at 03:43AM PDT, ID: 21240199

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628