[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[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!

9.1

PHP and MYSQL dat selection question

Asked by jackie777 in PHP and Databases, PHP Scripting Language

Hi

I have a piece of code that searches a database and pulls out the "Province" data in that database and lists them in a dropdown menu. I then want to use that dropdown menu to search the database again and return the data entries that contain that specific selected "Province" data. The current code I am using is currently retuning nothing, so it is not working. I am hoping to get some help with it. The two pieces of code and a dump from the database is listed below.
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:
<?php 
$hostname="localhost";
$username="xxx";
$password="xxx";
$dbname="moodybeedb";
$usertable="retailers";
$yourfield = "region";  
mysql_connect($hostname,$username, $password) or die ("CANNOT CONNET TO DATABASE");
mysql_select_db($dbname);   
echo "<form action=\"retailers_delete2.php\" method=\"post\"> 
<select name='Province'>"; 
$sql = "SELECT DISTINCT Province FROM retailers";
$result = mysql_query($sql)or die(mysql_error()); 
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$province = "{$row['Province']}";
echo "<option value='".$province."'>".$province."<br>";
} 
echo "</select><br><br><input type='submit' value='submit'> 
</form>";
?> 
<!-- the code below is the part that isn't working for me right now. I am trying to get it to display the data I want. After I accomplish that, I will want each piece of data displayed with a checkbox attached to it. The eventual plan for this secondary form is that when submitted anything checked will be deleted from the database --> 
<?php 

$hostname="localhost";
$username="xxx";
$password="xxx";
$dbname="moodybeedb";
$usertable="retailers";
$yourfield = "region"; 
$province = "Province"; 
echo "<form>"; 
if($_REQUEST['submit']) {
        
        mysql_connect($hostname,$username, $password) or die ("CANNOT CONNET TO DATABASE");
    mysql_select_db($dbname);  
        $query = "SELECT * from retailers where Province='" . $_REQUEST['Province']. "'";
    $result = mysql_query($query); 
    while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
        print "<pre>";
                print_r($row);
                print "</pre>";
    } 
    mysql_free_result($result);
}  

echo "<br><br><input type='submit' value='Submit'> 
</form>"; 
?> 

--
-- Database: `moodybeedb`
-- 
-- -------------------------------------------------------- 
--
-- Table structure for table `retailers`
-- 
CREATE TABLE `retailers` (
  `id` tinyint(5) NOT NULL auto_increment,
  `Province` varchar(500) NOT NULL,
  `region` varchar(500) NOT NULL,
  `store` varchar(500) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ; 
--
-- Dumping data for table `retailers`
-- 
INSERT INTO `retailers` VALUES(1, 'BRITISH COLUMBIA', '100 MILE HOUSE', 'Hight Ground Natural Foods<br>104 Birch Avenue South<br>100 Mile House');
INSERT INTO `retailers` VALUES(2, 'BRITISH COLUMBIA', 'ABBOTSFORD', 'Campbells Gold Honey Farm<br>2595 Lefeuvre Road<br>Abbotsford<br>www.bchoney.com ');
INSERT INTO `retailers` VALUES(3, 'BRITISH COLUMBIA', 'BURNABY', 'Choices In The Park<br>6855 Station Hill Drive<br>Burnaby<br>www.choicesmarket.com/burnaby-park.htm');
INSERT INTO `retailers` VALUES(4, 'BRITISH COLUMBIA', 'BURNABY', 'Choices At The Crest<br>8683 10th Avenue<br>Burnaby<br>www.choicesmarket.com/burnaby-crest.htm ');
INSERT INTO `retailers` VALUES(5, 'BRITISH COLUMBIA', 'BURNABY', 'Natural Focus Foods<br>6536 Hastings Street<br>Burnaby ');
INSERT INTO `retailers` VALUES(6, 'ALBERTA', 'ATHABASCA', 'Bovens Jewelry & Giftware<br>4916A 50 ST<br>Athabasca ');
[+][-]11/03/09 06:59 AM, ID: 25729534Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 07:37 AM, ID: 25729958Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 07:40 AM, ID: 25729989Accepted Solution

View this solution now by starting your 30-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
Sign Up Now!
Solution Provided By: Ray_Paseur
Participating Experts: 2
Solution Grade: A
 
[+][-]11/03/09 07:51 AM, ID: 25730120Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 12:30 PM, ID: 25733236Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625