Solved

How to get mysql query with variables

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

746 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

13 Experts available now in Live!

Get 1:1 Help Now