TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-10-2009, 01:59 PM   #21 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Ok, I beleive I've got it working the way you wanted it to. You can see the example here:

http://www.gatebattle.com/kay.html


The first output shows items with SOLD status. Which I made only 2 set to "sold". The other 8 are set to "used".

Then in the dropdown you can see that it shows everything but the attic and basement output from the first list...

The code is basically the same, so I'm not sure why you are getting errors.


The only thing I changed was the first query slightly ONLY to provide an output since your query is asking for a form to be submited, so I'm just simulating the form being submitted....
allworknoplay is offline  
Reply With Quote
Old 05-10-2009, 02:01 PM   #22 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Sorry here's the code......



PHP Code:
<?php

    $origPC 
$_POST['postcode'];
    
$postcodestrtoupper($origPC);
    
$first_list = array();


    
$con=mysql_connect(localhost"#####""#####"); 
        
mysql_select_db("######"); 
    
    
    if (!
$con)
      {
          die(
'Could not connect: ' mysql_error());
      }

            
$sql "SELECT cat_name, postcode FROM postalcode WHERE status='sold'";

            
$qry mysql_query($sql);
            
           
           echo 
"Sold Items: <br />";
           
            if (
mysql_num_rows($qry) > 0) {
                while (
$rs mysql_fetch_assoc($qry)) {
                    
$cat_name $rs['cat_name'];
                    
$postcode $rs['postcode'];
                    
$first_list[] = $cat_name;
                     echo 
$cat_name.'<br/>';
                }
            } else {
                print 
'<h4>no result found</h4>';
            }
            
        print 
'<form method="POST" action="index.php?ID=15">';
    
        echo 
"<br />Available Items: <br />";
        
        
$query="SELECT DISTINCT cat_name FROM category GROUP BY cat_name";
                            
        
$result mysql_query ($query);
        
        echo 
"<select name='cat_name' value=''>";
        
                echo 
"<option value=''>View Other Categories</option>";
                while(
$nt=mysql_fetch_array($result))
                {
                    
$kitty=$nt[cat_name];
                    
                   if(!
in_array($kitty,$first_list)) { 
                        echo 
"<option value=''>$kitty</option>"
                    } 
                }
        echo 
"</select><br/>";
                

        print 
'<input type="submit" value="Contact Us for More Information"> </form>';
?>
allworknoplay is offline  
Reply With Quote
The Following User Says Thank You to allworknoplay For This Useful Post:
Kay1021 (05-11-2009)
Old 05-11-2009, 06:05 AM   #23 (permalink)
The Wanderer
 
foobarph's Avatar
 
Join Date: May 2009
Posts: 23
Thanks: 4
foobarph is on a distinguished road
Default

it's supposed to work on my part. oh well, im lost i think. ahehe
foobarph is offline  
Reply With Quote
Old 05-11-2009, 06:35 PM   #24 (permalink)
The Contributor
 
Join Date: May 2008
Posts: 36
Thanks: 5
Kay1021 is on a distinguished road
Default

Omg it finally worked!!!

I tried the code you posted...just copy and pasted basically to make sure i didn't make any mistakes and then i was getting the fatal error again...and then the next time i would get T_variable or T_string or something it was really weird....even when i tried to go back to before I started doing this something was wrong. I think my file got messed up some how. So what I did was start ALL over again...new document....typed everything out line by line...no copying or pasting....and just tested line by line incase I got an error i'd know exactly where it was ...but it worked...no errors and the whole purpose of this worked too. So I apologize something was wrong with my file I guess and this could have all worked from the very start. Sorry you had to do the whole thing...but I really appreciate it!

Thanks so much!
Kay1021 is offline  
Reply With Quote
Old 05-11-2009, 06:49 PM   #25 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

No problem....glad to hear it worked....
allworknoplay is offline  
Reply With Quote
Old 05-11-2009, 07:01 PM   #26 (permalink)
The Contributor
 
Join Date: May 2008
Posts: 36
Thanks: 5
Kay1021 is on a distinguished road
Default

Sorry one more question

When the user chooses something from the drop down....what is the variable that holds that result

I thought it was cat_name but that gives you the last choice on the list above the drop down and then i thought it was kitty but that just gives you the last option in the drop down.


So now i'm not sure..lol
Kay1021 is offline  
Reply With Quote
Old 05-11-2009, 07:08 PM   #27 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

You have to provide a value for the select option, so it would be something like this:



PHP Code:
 $query="SELECT DISTINCT cat_name,category_id FROM category GROUP BY cat_name";
                            
        
$result mysql_query ($query);
        
        echo 
"<select name='cat_name'>";
        
                echo 
"<option value=''>View Other Categories</option>";
                while(
$nt=mysql_fetch_array($result))
                {
                    
$kitty=$nt[cat_name];
                    
$cat_id=$nt[category_id];
                    
                   if(!
in_array($kitty,$first_list)) { 
                        echo 
"<option value=\"$cat_id\">$kitty</option>"
                    } 
                }
        echo 
"</select><br/>"
allworknoplay is offline  
Reply With Quote
Old 05-12-2009, 03:46 PM   #28 (permalink)
The Contributor
 
Join Date: May 2008
Posts: 36
Thanks: 5
Kay1021 is on a distinguished road
Default

hmm still gives me the last option in the drop down
Kay1021 is offline  
Reply With Quote
Old 05-12-2009, 03:59 PM   #29 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Kay1021 View Post
hmm still gives me the last option in the drop down

How are you checking for the results? What variable are you checking for exactly?
allworknoplay is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Pagination of search results universalhope Advanced PHP Programming 5 09-01-2011 01:13 PM
Cleaning results from dict://dict.org/ sidisinsane General 0 08-26-2008 02:48 PM
Keyword Search Form Jako General 1 08-21-2008 07:44 AM
Building a MySQL search delayedinsanity MySQL & Databases 4 08-14-2008 04:21 AM
Outputting MySQL Results Andrew Advanced PHP Programming 5 01-13-2008 04:59 PM


All times are GMT. The time now is 09:32 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design