Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to get mysql query with variables

Posted on 2006-10-29
2
Medium Priority
?
276 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

782 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