>model |
>maxspeed |
km |
>price |
L2 |
L4 |
LCD |
if( $meters>0 )
{
$o=round($meters*0.18);
echo "$meters m ($o Om) | ";
}
?>
note |
$h = pg_connect( "host=127.0.0.1 port=5432 dbname=modem user=pgsql password=123" );
$where='';
if( $meters>0 ) $where="meters>=$meters";
if( $speed>0 && $meters>0 ) $where="meters>=$meters and speed>=$speed";
$w2='';
$aaa="WHERE ";
if( strlen($where)>0 || $speed>0 ) $aaa="and ";
if( $l2=='t' and $l4=='t' ) $w2="$aaa (l2='t' or l4='t')";
if( $l2=='t' and $l4=='f' ) $w2="$aaa l2='t'";
if( $l2=='f' and $l4=='t' ) $w2="$aaa l4='t'";
if(strlen($where)==0)
{
if ($speed>0 )
{
$q="SELECT * FROM modem WHERE maxspeed>=$speed $w2 ORDER BY $sort";
#$rec=pg_exec($h,"SELECT * FROM modem WHERE maxspeed>=$speed $w2 ORDER BY $sort");
}
else
{
$q="SELECT * FROM modem $w2 ORDER BY $sort";
#$rec=pg_exec($h,"SELECT * FROM modem $w2 ORDER BY $sort");
}
}
else
{
$q="SELECT * FROM modem WHERE id IN (SELECT id FROM speed WHERE $where) $w2 ORDER BY $sort";
#$rec=pg_exec($h,"SELECT * FROM modem WHERE id IN (SELECT id FROM speed WHERE $where) $w2 ORDER BY name");
}
# echo "$q";
$rec=pg_exec($h,"$q");
$rec_c=pg_numrows($rec);
$color1="#e0e0e0";
$color2="#f0f0f0";
for($i=0;$i<$rec_c;$i++)
{
$id=pg_result($rec,$i,'id');
$model=pg_result($rec,$i,'name');
$maxspeed=pg_result($rec,$i,'maxspeed');
$price=pg_result($rec,$i,'price');
$note=pg_result($rec,$i,'note');
$url=pg_result($rec,$i,'url');
$l2=pg_result($rec,$i,'l2');
$l4=pg_result($rec,$i,'l4');
$lcd=pg_result($rec,$i,'lcd');
$rec2=pg_exec($h,"SELECT * FROM speed WHERE id=$id ORDER BY speed DESC");
if(pg_numrows($rec2)==0) $km='?';
else $km=pg_result($rec2,0,'meters')/1000.0;
if($i%2==0)echo "
";
else echo "
";
echo "$model | ";
echo "$maxspeed | $km | ";
echo "$price | ";
if( $l2=='t' ) echo "+ | ";
else echo "- | ";
if( $l4=='t' ) echo "+ | ";
else echo "- | ";
if( $lcd=='t' ) echo "+ | ";
else echo "- | ";
if($meters>0)
{
$rec2=pg_exec($h,"SELECT meters,speed FROM speed WHERE id=$id and meters>=$meters ORDER BY speed DESC");
$s=pg_result($rec2,0,'speed');
$km=pg_result($rec2,0,'meters')/1000.0;
echo "$s / $km km | ";
}
echo "$note | ";
echo "
\n";
}
?>