Page 1 of 1

noob help!

Posted: Sun Mar 29, 2009 5:53 pm
by tezza
hey guys new here dont know where to post this but here we go.

im trying to make a basic website linked to an access database. the website is a basic hosting website where the database stores one simple table that has five rows. first being the features, second the gold pack, then silver etc etc.
I have managed to link it so that it shows the table im after however how can i add either a drop down menu or search bar where the user can type in a particular amount of disk space they want and it produces the correct row.

heres the current code to link the database. as its on an apache server.

Code: Select all

<?php
            $dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=E:\\wwwroot\packages.mdb;Uid=;Pwd=;";
            $conn=odbc_connect($dsn,'','');
            if (!$conn)
              {exit("Connection Failed: " . $conn);}
            $sql="SELECT * FROM hosting";
            $rs=odbc_exec($conn,$sql);
            if (!$rs)
              {exit("Error in SQL");}
 
    echo "<table border=1><tr>";
    echo "<th> Features/Products </th>";
    echo "<th> Bronze </th>";
    echo "<th> Silver </th>";
    echo "<th> Gold </th>";
    echo "<th> Platinum </th>"; 
    echo "</tr>";
    while (odbc_fetch_row($rs))
    {
      $f1=odbc_result
      ($rs,"Features/Products");
      $f2=odbc_result($rs,"Bronze");
      $f3=odbc_result($rs,"Silver");
      $f4=odbc_result($rs,"Gold");
      $f5=odbc_result($rs,"Platinum");
      
      echo "<tr>";
      echo "<td>$f1</td>";
      echo "<td>$f2</td>";
      echo "<td>$f3</td>";
      echo "<td>$f4</td>";   
      echo "<td>$f5</td>";
      echo "</tr>";
    }
    odbc_close($conn);
    echo "</table>";
        ?>
              <br>
              <br>
            </p>
i have tried to find a good tutorial or sample but cant find one anywhere. any help would be greatly appreciated.

Re: noob help!

Posted: Sun Mar 29, 2009 6:20 pm
by phpbaby2009
Hi, If you don't have a lot of content, you could display everything and allow users to sort etc using Javascript/Ajax. http://tablesorter.com/docs/

<form method="POST">
Search
<input type="text" name="q">
<select name="findInColumn">
<option>Silver</option>
<option>Gold</option>
<option>Other1</option>
<option>Other2</option>
</select>
<input type="submit" name="submit" value="search">
</form>

<?
$findInColumn=$_POST['findInColumn'];
$q=$_POST['q'];
$sql="SELECT * FROM hosting WHERE column LIKE '"%.$q."%'";
?>
Is that what you meant ?