Solved

How to get mysql query with variables

Posted on 2006-10-29
2
243 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
The viewer will learn how to dynamically set the form action using jQuery.
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.

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now