• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 387
  • Last Modified:

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
0
fferrel
Asked:
fferrel
  • 5
  • 4
2 Solutions
 
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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now