MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old September 24th, 1999, 10:49 AM
chaz goodsell
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I'm a newbie to all the above.
What I'm looking for is an example on using a form to query the database and displaying the information to the current page.I have a small database "workdb" comprised of 1 table "employees" 6 fields "id, first, last, address, position,phone number". I'm attempting to allow a regular user to type a field value into the form and have all the information associated with that value display. ie; typing in last"a last name".
Thanks for any help.
chaz

Reply With Quote
  #2  
Old September 24th, 1999, 11:53 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Well, it's not quite that simple. What do you do if you have more than one employee with the same last name? (or any other field that might not be unique)

Do you want to display information only? Then it's no problem, you'd display all individuals with the same last name.

If you wanted to allow editing you could display all individuals with matching criteria with a radio button and let the user select which person he wanted before going to the edit form. You could also just display each individual in their own form on the same page but that could get confusing, make mistakes more likely, and also introduce more difficulties to keep track of all the data.

Post more info on what you envision happening and what you want it to do.

Rod

Reply With Quote
  #3  
Old September 24th, 1999, 12:01 PM
chaz goodsell
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Rod,

I'm just looking to display the information. Ihave already created a form for editing and adding a record " locked down by rights". the goal here is to simply display the info "all" associated with the last name even if duplicates exist. thanks for the help.

Reply With Quote
  #4  
Old September 27th, 1999, 08:19 AM
chaz goodsell
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
This what I have managed to learn thus far, but still not working.
<?php
$db =mysql_connect ("localhost","user name","valid password");
mysql_select_db("workdb",$db);
if($last) {
// query DB
$sql = "SELECT * FROM employees WHERE last ='$last'";
$result = mysql_query($sql);

//display data
}else{
//display form
?>
<form method=post action="<?php echo $PHP_SELF?>">
<input type="text" name="last"> <input type="submit">
</form>
<?php
}
echo $sql
?>
With the echo $sql " I verify correct sql statement. With it commented out I get the following:
Document contains no data.
Anyone out there see what I'm missing?
I've tried placing the name in all caps, lower and as it show's up with in the database.

Reply With Quote
  #5  
Old September 27th, 1999, 12:12 PM
wesb
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Try adding this piece of code just below the line "$result = mysql_query($sql);"

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>if(mysql_num_rows($result) > 0){
while($row=mysql_fetch_array($result)){
echo "First Name: $row[first]<br>";
echo "Last Name: $row[last]<br><br>";
}
}else{
echo "No results found.";
}[/quote]

The document contains no data error means exactly what it says, your script is returning a document to the browser that contains nothing.

------------------
URL
www.devshed.com

Reply With Quote
  #6  
Old September 27th, 1999, 12:59 PM
chaz goodsell
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Thanks wesb.
That has done the trick!!!!!
Outstanding....

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Using Forms MySQL and PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway