Solved

How to get mysql query with variables

Posted on 2006-10-29
2
255 Views
Last Modified: 2011-09-20
I would like to query only members that owe dues.  

In mysql data base I have a record for dues, Yes/No.  If members dues are recorded as No I wish to only call those records.  What do I need to add, change to the code below?


Here is what I currently have for the code---->

<?php

      require_once('include\tal-sqllogin.php');

// Get all the data from the "talmembers" table AND SORT BY Last Name
$result = mysql_query("SELECT * FROM talmember ORDER BY 'name_last' asc")
or die(mysql_error());

echo "<table width=\"900\" align=\"left\" height=\"0\" border=\"1\" cellpadding=\"1\">";
echo "<tr bgcolor=\"ffffff\" align=\"center\"> <th>Last Name</th> <th>First Name</th>
 <th>Phone #</th> <th>Address</th> <th>City</th> <th>Zip</th>
<th>Dues Paid</th> ";

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {

// Print out the contents of each row into a table
echo "<tr align=\"center\"><td>";
echo $row['name_last'];
echo "</td><td>";
echo $row['name_first'];
echo "</td><td>";
echo $row['phone'];
echo "</td><td>";
echo $row['address_one'];
echo "</td><td>";
echo $row['address_city'];
echo "</td><td>";
echo $row['address_zip'];
echo "</td><td>";
echo $row['dues'];
echo "</td><td>";

}
echo "</table>";

?>
0
Comment
Question by:aumandg
2 Comments
 
LVL 17

Accepted Solution

by:
HuyBD earned 500 total points
ID: 17831466
Change query:

$result = mysql_query("SELECT * FROM talmember WHERE dues='No' ORDER BY name_last asc") or die(mysql_error());
0
 
LVL 3

Expert Comment

by:www-i-p-mu
ID: 17831478
hi aumandg,

try this SELECT * FROM talmember WHERE dues ='No' ORDER BY 'name_last' asc

let me know if it is what you want

regards,
www-i-p-mu
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Fulfillment API php code sample 1 56
hbo knew my windows software 4 60
Row insertion failed. Array 5 46
Test if unique ID is in log file 5 21
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

791 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