how do i change this code to view all

Discussion in 'PHP' started by dougvcd, Sep 11, 2008.

  1. #1
    ok i have this code on a page where you selest which to view
    but i would like it to start with view all then select
    if you see what i mean
    cheers
    Doug

    <div id="contents">
    <p>  
     <form name="search" method="post" action="<?=$PHP_SELF?>"> 
    <Select NAME="county">
    <option value="*">All</option>
    <Option VALUE="South West">South West</option>
      <Option VALUE="South East">South East</option>
      <Option VALUE="Wales">Wales</option>
      <option value="Scotland">Scotland</option>
      <option value="London">London</option>
      <option value="East England">East of England</option>
      <option value="West Midlands">West Midlands</option>
      <option value="East Midlands">East Midlands</option>
      <option value="Yorkshire">Yorkshire & Humberside</option>
      <option value="Northwest">North West</option>
      <option value="Northeast">North East</option>
      <option value="Other">Other</option>
    </Select>
    <input type="hidden" name="searching" value="yes" />
    <input type="submit" name="search" value="Search" />
    </form>
    PHP:

     
    dougvcd, Sep 11, 2008 IP
  2. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is just a form will need to see javascript and or PHP/ASP.
     
    Sleeping Troll, Sep 11, 2008 IP
  3. mariuspompier

    mariuspompier Peon

    Messages:
    323
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Replace <Select NAME="county"> with <Select NAME="county" size="13">
    See if it helps you. :D
     
    mariuspompier, Sep 11, 2008 IP
  4. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <?php
    
    
    // Connects to your Database 
    $dbh=mysql_connect("localhost", "vcd", "57") or die('I cannot connect to database because: ' .mysql_error()) ; 
    mysql_select_db("users"); 
     
    //Retrieves data from MySQL
    $strcounty = mysql_real_escape_string($_POST['county']);
    if ($strcounty == "*")
    {
      $data = mysql_query("SELECT * FROM members WHERE region='HIRE' OR region='EXCHANGE/HIRE' or region='hire'") or die(mysql_error());
    }
    else
    {
      $data = mysql_query("SELECT * FROM members WHERE (region='HIRE' OR region='EXCHANGE/HIRE' or region='hire') AND county='$strcounty'") or die(mysql_error());
    }
    //Puts it into an array 
    while($info = mysql_fetch_array( $data )) 
    { 
    //Outputs the image and other data
    Echo "<img src=http://www.djbcaravanhire.co.uk/images2/".$info['pname'] ." alt=\"Image\" align=\"left\" width=\"150px\" height=\"100px\" hspace=\"10px\" vspace=\"8px\"> <br>";
    Echo "<b>Available for:</b><font color=blue> ".$info['region'] . "</font><br>";
    Echo "<b>County:</b> ".$info['county'] . " <br>";
    Echo "<b>Park Name:</b> ".$info['parkname'] . " <br>";
    Echo "<b>Park Location:</b> ".$info['parklocation'] . " <br>";
    Echo "<b>Make & Model:</b> ".$info['make'] . " <br>";
    if(empty($info[web]))
    {
    $web = "Not Provided" ;  }
    else {
    $web = "<a href=$info[web]>More Info</a> "; }
    echo   '<b>Information:  </b><a href="display.php?id='.$info['username'].'&slide='.$info['slide'].'">More Info</a><hr>';  
    } 
    
    
    ?>  
    PHP:
     
    dougvcd, Sep 11, 2008 IP
  5. Funk-woo10

    Funk-woo10 Peon

    Messages:
    1,108
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #5
    errr you are showing us you Database username and password remove it super quick..Change this -$dbh=mysql_connect("localhost", "**", "**")

    To this -

    $dbh=mysql_connect("localhost", "***REMOVE***", "***REMOVE***")

    note: just for showing here.
     
    Funk-woo10, Feb 25, 2009 IP