PHP MySQL Form query

Hello,
I want to use PHP in Dreamweaver to query a MySQL database.  I setup an HTML form and can successfully connect to my database.  

I just need to know how to input PatronID and LName then [submit] and output AccountBal.

Example..
http://fortcherry.schooltoweb.com/lunchbalance/find.php
php.jpg
LVL 1
fferrelAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

thedwillCommented:
open your 'application' tab.  You'll need to setup your testing server and make the connection to the database.

On the Insert menu -> Data Objects -> Insert Record -> Insert Record Form Wizard.

This will take care of everything for you once you get the application tab setup properly.
Take a few minutes and read help files for details if you can't get it instinctively
0
fferrelAuthor Commented:
i am using 1and1 for my host and their MySQL database can not connect through Dreamweaver or any other third party app.  So I have to edit and test live.

any suggestions?
0
fferrelAuthor Commented:
Making progress..

if ($PatronID == "")
{$PatronID = '%';}

if ($LName == "")
{$LName = '%';}

$result = mysql_query ("SELECT * FROM <lunch>      
      WHERE PatronID LIKE '$PatronID%'
      AND LName LIKE '$LName%'
      ");

if ($row = mysql_fetch_array($result)) {

do {
      print $row["$AccountBal"];
} while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found!";
}

I get it to say "Sorry, no records were found!"  I am having trouble getting it to locate the AccountBal.
0
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

kumaranmcaCommented:
Hi fferrel,

I found the mistake.change the below code.. to get the value of AccountBal

     print $row["AccountBal"];
<?php
 if ($PatronID == ""){
 	$PatronID = '%';
	}

if ($LName == ""){
	$LName = '%';
}

$result = mysql_query ("SELECT * FROM <lunch>      
      WHERE PatronID LIKE '$PatronID%'
      AND LName LIKE '$LName%'
      ");

if ($row = mysql_fetch_array($result)) {

do {
      print $row['AccountBal'];
} while($row = mysql_fetch_array($result));

} else {
print "Sorry, no records were found!";
}
?>

Open in new window

0
fferrelAuthor Commented:
even if I put print $row['$PatronID%'] or ['$PatronID']  or ['PatronID']   it still outputs "Sorry, no records were found!"  

I know the database information is correct.
0
thedwillCommented:
I would suggest installing wamp and setting up a testing server to allow you to use the application tab.  It will save you a ton of time.  Creating an insert form and all the code to do it takes about 30 seconds once setup
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fferrelAuthor Commented:
this is just a query form,  just to view.  no insert.  that can also be accomplished with the app tab?
0
thedwillCommented:
Yes - you've got a pretty good tool in dreamweaver, Let it do some of the heavy lifting.  :-)

0
fferrelAuthor Commented:
Installed WAMP walked through Dreamweaver in minutes and BAM! it works.  Thanks a lot!
0
thedwillCommented:
Great!  Thanks.  You've just opened up a whole new world of possibilities and more efficient development.  You'll still have to get your hands dirty on more complex sql statements, but for the basics, you just can't beat the speed at which it can kick out the basic building blocks.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.