Solved

How to get mysql query with variables

Posted on 2006-10-29
2
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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.

696 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