?
Solved

PHP4& MS ACCESS 97

Posted on 2003-03-07
5
Medium Priority
?
245 Views
Last Modified: 2006-11-17
1) How you code a query in PHP4 (with MS ACCESS 97)that requires a Where statement. For example, select * from employee where department = Health?

2) How do you display a checkbox field value in Access 97 to a checkbox on the web using PHP4?

3) How do you display a picture on a web page using PHP4 where the picture name is stored in a MS ACCESS 97 and the picture is actual stored on a windows directory?

Many Thanks

Will
0
Comment
Question by:willwatters
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
carchitect earned 60 total points
ID: 8092935
hi

<?php

$db = "C:\\Program Files\\Microsoft Office\\Office\\Samples\\Northwind.mdb";

$conn = new COM("ADODB.Connection");
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");


$sql = "SELECT   ProductName, QuantityPerUnit, UnitPrice
      FROM     Products
      ORDER BY ProductName";
$rs = $conn->Execute($sql);

?>

<table>
<tr>
      <th>Product Name</th>
      <th>Quantity Per Unit</th>
      <th>Unit Price</th>
</tr>
<?php while (!$rs->EOF): ?>
      <tr>
               <td><?= $rs->Fields['ProductName']->Value ?></td>
               <td><?= $rs->Fields['QuantityPerUnit']->Value ?></td>
               <td><?= $rs->Fields['UnitPrice']->Value ?></td>
      </tr>
      <?php $rs->MoveNext() ?>
<?php endwhile ?>
</table>

<?php

$rs->Close();
$conn->Close();

?>


may this help you little....just to start with php and msaccess...
regards
0
 

Expert Comment

by:vulpine
ID: 8097129
Checkboxes in Access are just Yes/No true/False fields, access just puts in checkboxes to make it user friendly. To do this on a php page you would need to use checkboxes and set the default status of the checkbox according to the value in the database. Using the above example, and assuming the access value is yes/no:

<?php
  if($rs->Fields['Available']->Value=='Yes'){
    $checked="CHECKED";
  } else {
    $checked="";
  }
?>

<INPUT TYPE="Checkbox" NAME="Available" VALUE="Yes" <?=$checked?>>

Should help with point no 2
0
 
LVL 6

Expert Comment

by:carchitect
ID: 8097244
thats right
0
 

Expert Comment

by:vulpine
ID: 8099851
And point number 3

This is easy just store the location of the graphic in the database.

Or if you kept all your images in the one directory, you would only need to store the image name and then you just add the rest of the dir in the IMG tag. Using the above example:

<IMG SRC="pathto/images/<?=$rs->Fields['ImageName']->Value?>" ALT="This is an image">

Hope it helps

0
 

Author Comment

by:willwatters
ID: 8104163
I tried passing in a parameter using the header format but don't know how, can you fix this code please:

header('Location: Customer_Mare_Progress_Status.php’)

?CustomerNo.=<?print $CustomerNo?>
0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question