Hello guys, i am new to PHP and finding it interesting difficult at the same time. I need to connect to an access database depending on the selected menus in the drop down box and printing the selected field in a table.
Here is my code

<?php
    $ch1 = 'unchecked';
	$ch2 = 'unchecked';
	$ch3 = 'unchecked';
	$ch4 = 'unchecked';
	$ch5 = 'unchecked';
	$myform = $_POST['myform'];
  $bandwith = $_POST['bandwith'];
  $webspace = $_POST['webspace'];
  $payment =$_POST['payment'];	
	
			$dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq= E:\\wwwroot\php\hosting.mdb;Uid=;Pwd=;";
			$conn=odbc_connect($dsn,'','');
			if (!$conn )
			  {exit("Connection Failed: " . $conn);}
			  if ($webspace === '200 mb' && $bandwith === '3000 mb' $payment === '£22.90 per year' ){
			$sql="SELECT * FROM data"}
			$rs=odbc_exec($conn,$sql);
			if (!$rs)
			  {exit("Error in SQL");}
echo "<table><tr>"; 
echo "<th>Features</th>"; 
echo "<th>Bronze</th></tr>"; 
while (odbc_fetch_row($rs)) 
{ 
$feat=odbc_result($rs,"Features"); 
$br=odbc_result($rs,"Bronze"); 
echo "<tr><td>$feat</td>"; 
echo "<td>$br</td></tr>"; 
} 
odbc_close($conn); 
echo "</table>"; 
		

?>

What is the error ?
And, instead of

$webspace === '200 mb' && $bandwith === '3000 mb' $payment === '£22.90 per year'

I would suggest you to use only numbers. For example,

$webspace === '200' && $bandwith === '3000' && $payment === '22.90'

Also note that there is no && operator in your statement for $payment.
This query,

$sql="SELECT * FROM data"

isn't terminated with a semi colon.
One more, odbc_fetch_row returns records with numeric indices. You can't use $feat=odbc_result($rs,"Features"); use odbc_fetch_array instead. I guess thats it.

Edit: Oh and please, use [/code ] tags to wrap your codes.[code= php] [/code ] tags to wrap your codes.

Hi i have an example on dropdown + ms access + php

page1:

<font face="Verdana" color="#CC0000">
                    <?php
	$strConn = new COM("ADODB.Connection") or die("Cannot start ADO");
	$strConn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("db/dbExam.mdb")); 
	$strSQL = "SELECT * FROM tblKursus";
	$objRec = $strConn->Execute($strSQL);
      
    
?>        
                                                                                                                                              <form name="form1" method="post" action="process.php">
   
<select name="pilihankursus">
    <?php 
While (!$objRec->EOF)
{
?>   
<option value=<?php print $objRec->Fields(2)->Value;?>><?php print $objRec->Fields(1)->Value;?></option>
 <?php
	$objRec->MoveNext();
}
?> 
</select>
   <input type="submit" name="Submit" value="Submit"/>

</form>

page2 process.php:

<?php
	$strConn = new COM("ADODB.Connection") or die("Cannot start ADO");
	$strConn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("db/dbExam.mdb")); 
$strVar .= "KodKursus = '".$_POST["pilihankursus"]."' ";
      
      $SKursus = $_POST['pilihankursus'];
      
      echo "Variable yang dipost dari page lalu(default.php) ialah";
      echo "<p style=\"color:#FF8000\"> $SKursus</p>";
      echo "pembolehubah ini(variable)";
      echo "<p style=\"color:#0080ff\">$strVar</p>";
      echo "akan menentukan table yang akan dipilih untuk dipapar dan seterusnya untuk disimpan data-data ke dalamnya";
?>

<?php
$db_conn = new COM("ADODB.Connection");  
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("db/dbExam.mdb").";";  
$db_conn->open($connstr);  
$rS = $db_conn->execute("SELECT  * from $SKursus");  



$f1 =  $rS->Fields(0); 
$f2 =  $rS->Fields(1);
$f3 =  $rS->Fields(2);
$f4 =  $rS->Fields(3);
$f5 =  $rS->Fields(4);
$f6 =  $rS->Fields(5);
$f7 =  $rS->Fields(6);
$f8 =  $rS->Fields(7);
$f9 =  $rS->Fields(8);
?>
</br>
        <table>
            <tr>
                <td>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
<form name="form1" method="post" action="update.php">
<tr> 
<td> 
     
    <input name="txtKursus"   type="text" id="txtKursus" value="<?php print $SKursus;   ?>">
   
<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>
<td  align="center"><strong>Id</strong></td>
<td align="center"><strong>NoPendaftaran</strong></td>
<td align="center"><strong>S1</strong></td>
<td align="center"><strong>S2</strong></td>
<td align="center"><strong>S3</strong></td>
<td align="center"><strong>S4</strong></td>
<td align="center"><strong>S5</strong></td>
<td align="center"><strong>S6</strong></td>
<td align="center"><strong>S7</strong></td>
</tr>

<?php 
while (!$rS->EOF)  
{  ?>
<tr>
  
    <td  align="center"><input name="id[]" type="hidden"  type="text" id="id" value="<?php print $f1->value;   ?>"><?php $id[] = $f1->value;?> <?php echo $f1->value;?></td>
    <td align="center"><input  name="NoPendaftaran[]" type="text" STYLE="color: #FFFFFF; font-family: Arial;   font-size: 12px; background-color: #72A4D2;" size="10" maxlength="30" id="NoPendaftaran" value="<?php print $f2->value;  ; ?>"></td>
<td align="center"><input name="S1[]" size="4"  type="text" id="S1" value="<?php print $f3->value;   ?>"></td>
    <td align="center"><input  name="S2[]" size="4" type="text" id="S2" value="<?php print $f4->value;   ?>"></td>
    <td align="center"><input  name="S3[]" size="4" type="text" id="S3" value="<?php print $f5->value;   ?>"></td>
    <td align="center"><input  name="S4[]" size="4" type="text" id="S4" value="<?php print $f6->value;   ?>"></td>
    <td align="center"><input   name="S5[]"size="4" type="text" id="S5" value="<?php print $f7->value;   ?>"></td>
    <td align="center"><input  name="S6[]" size="4" type="text" id="S6" value="<?php print $f8->value;   ?>"></td>
    <td align="center"><input  name="S7[]" size="4" type="text" id="S7" value="<?php print $f9->value;   $rS->MoveNext();  ?>"></td>
 
    </tr>
    
<?php
}
?>
  


<tr>
<td colspan="9" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
        <?php
$rS->Close();  
$db_conn->Close();  
?><br>

I think this guy has probably found a solution after almost 3 years. :(
Necroposting to this thread has done nothing but clutter up the forum another dead post.

This article has been dead for over six months. Start a new discussion instead.