Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

PHP4& MS ACCESS 97

Posted on 2003-03-07
5
Medium Priority
?
251 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
  • 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

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

564 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