help with online databases

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
sokie-rich
Forum Newbie
Posts: 1
Joined: Fri Oct 30, 2009 3:08 am

help with online databases

Post by sokie-rich »

hi everyone my name is rich im doing a project with online PHP and SQL, im trying to get data from a database and show it on a on-line database here is my code am i on the right tracks??

<?php
//password parameter
if ($_POST["user"] == "user" &&$_POST["password"]== "password")

//this is if the users password matches the one on the systems, it will then load into the main website
{header('location:http://Fcetdev1.student.staffs.ac.uk/ww ... 1/Hospital Login Success.html');}
// if the password is not correct then the user will be show a incorrect password screen and then re-directed back to the main log in page
else
{header('location:http://Fcetdev1.student.staffs.ac.uk/ww ... 1/Hospital Login Denied.html');}


?>

<?php
// this creates a connection to the database
$adCon = new COM ('ADODB.Connection');

// this is the path to the folder holding this PHP script
$sHere = dirname (_FILE_);
//MS Access
//this opens the commection using a standard Access connection string
$adoCon-> Open('Provider=Microsoft.ACE.OLDBE.12.0; Data Source=$sHere/intermed (1).accdb');

$sSQL= 'SELETC * FROM tblProducts WHERE
productReference Like '$SProductSurname'
$sBoolean
productName Like '$sProductName'
productDescription Like '$sProductDescription'
productPrice Like '$sProductPrice'

echo 'Running the SQL command:<br /> $sSQL <br /><br />';

// this will now search the DB
$rsMain = $adoCon->Execute( $sSQL );
//this will now output the selected fields that i have selected from 'tblProducts'
while (!$rsMain->EOF)
{ // gets each of the selected feilds from the DB
$sProductReference = $rsMain->Fields('ProductReference')->value;
$sProductName = $rsMain->Fields('ProductName')->value;
$sProductDescription = $rsMain->Fields('ProductDescription')->value;
$sProductPrice = $rsMain->Fields('ProductPrice')->value;

//prints each of the reccords onto the website, thats has been found from the database
print '$nID: $sProductReference; $sProductName; $sProductDescription; $sProductPrice<br />\n'

//this will move to the next reccord, or if no reccords then the count will run out
$rsMain->MoveNext();
}

// closes the reccord
$rsMain->Close();
$rsMain->Release();
$rsMain = null;

//closes the connection
$adoCon->Close();
$adoCon = null;

?>
</body>
</html>
milanm
Forum Newbie
Posts: 3
Joined: Tue Jul 22, 2008 6:46 am

Re: help with online databases

Post by milanm »

Hi, i am not quite sure what exactly do you want to do with your database output page but here is something i thought might be interesting for you:
http://www.w3schools.com/PHP/php_ajax_database.asp

These are ways to combine php code with ajax, i think it is giving interesting results.
Cheers, Milan
Post Reply