Stephen,
You're very close! I think these changes will fix it:
1. Replace your $query line with:
$query = mysql_query("SELECT * FROM spot where freq BETWEEN $que
order by time desc LIMIT 10");
Based on your code to display the data, it looks like you have a column
called "time", not "datetime", in your "spot" table so you should sort
by that column. Also, replaced the "=" with "BETWEEN" in the WHERE clause.
2. Change each of your $que lines to remove the 'between '. Your first
one would look like:
$que = "'1000' and '30000'";
This assumes that the datatype of the freq column is VARCHAR. If its an
numeric datatype (like INT), then you don't need the single quotes
around the frequencies and your lines will look like this instead:
$que = "1000 and 30000";
Hope that helps!
Best regards,
Jim Mullen
http://www.iDimensionz.com - professional web site programming and
affordable web site hosting.
Stephen wrote:
> I am a Amateur Radio Operator (Ham Radio) I am trying to write a page
> and this script will not work can someone look at it tell me what I am
> doing wrong it will not display the data. I believe I have this line
> worg but not sure:
>
> $query = mysql_query("SELECT * FROM spot where freq = $que order by
> datetime desc LIMIT 10");
> Thanks
>
> <?php
>
>
> if ( $band == "HF" ) {
> $que = "between '1000' and '30000'";
> }
>
> if ( $band == "160m" ) {
> $que = "between '1000' and '2000'";
> }
> if ( $band == "80m" ) {
> $que = "between '3000' and '4000'";
> }
>
> if ( $band == "40m" ) {
> $que = "between '7000' and '8000'";
> }
> if ( $band == "30m" ) {
> $que = "between '10000' and '11000'";
> }
> if ( $band == "20m" ) {
> $que = "between '14000' and '15000'";
> }
> if ( $band == "17m" ) {
> $que = "between '18000' and '19000'";
> }
> if ( $band == "15m" ) {
> $que = "between '21000' and '22000'";
> }
> if ( $band == "12m" ) {
> $que = "between '24000' and '25000'";
> }
> if ( $band == "10m" ) {
> $que = "between '28000' and '30000'";
> }
> if ( $band == "6m" ) {
> $que = "between '50000' and '60000'";
> }
> if ( $band == "4m" ) {
> $que = "between '70000' and '80000'";
> }
> if ( $band == "VHF" ) {
> $que = "between '30000' and '148000'";
> }
>
> if ( $band == "2m" ) {
> $que = "between '144000' and '148000'";
> }
>
> if ( $band == "70cm" ) {
> $que = "between '430000' and '445000'";
> }
> if ( $band == "23cm" ) {
> $que = "between '1200000' and '1300000'";
> }
> if ( $band == "13cm" ) {
> $que = "between '2000000' and '2700000'";
> }
> if ( $band == "9cm" ) {
> $que = "between '3000000' and '4900000'";
> }
> if ( $band == "6cm" ) {
> $que = "between '5000000' and '6700000'";
> }
> if ( $band == "3cm" ) {
> $que = "between '6000000' and '11000000'";
>
> }
>
>
>
> date_default_timezone_set('UTC');
> $timestamp=time();
> echo date("l d M Y H:i:s",$timestamp);
>
> $con = mysql_connect("localhost","XXXX","XXXX");
> #MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection
> unavailable");
> @mysql_select_db("dxspider") or die( "Unable to select database");
>
> $query = mysql_query("SELECT * FROM spot where freq = $que order by
> datetime desc LIMIT 10");
>
>
>
> while ($row = @mysql_fetch_array($query))
> {
> $dxcall=$row["spotcall"];
> $freq=$row["freq"];
> $datetime=$row["time"];
> $spotter=$row["spotter"];
> $comments=$row["comment"];
> $origin=$row["origin"];
>
>
> print ("<tr><center>");
> print ("<td><div align='center'><a
> href='http://www.qrz.com/database?callsign=$dxcall' target=_blank
>
>> $dxcall </a></td>");
>>
>
> print ("<td><div align='center'> $freq</td>");
> print ("<td><center>");
> $dt = date('d-M-Y H:i ', $datetime);
> echo $dt;
> print ("</td>");
> print ("<td><center><a
> href='http://www.qrz.com/database?callsign=$spotter'
> target=_blank>$spotter</a></td>");
> echo "<td><center>";
> echo strip_tags($comments);
> print ("<td><center><a
> href='http://www.qrz.com/database?callsign=$origin'
> target=_blank>$origin</a></td>");
> echo "</td>";
>
>
> print ("</tr>");
> }
> ?>
>
>
> Thanks
> Stephen
>
>
>
[Non-text portions of this message have been removed]