Consult a mysql+php linked list query output problem

Source: Internet
Author: User
Tags php mysql
SQL PHP mysql select CMS

Fields in table Cms_archives15
Aid Mediumint (8) UNSIGNED no 0
Subject varchar (255) Gbk_chinese_ci No
Jumpurl varchar (GBK_CHINESE_CI) No
CAID smallint (5) UNSIGNED no 0
Chid tinyint (3) UNSIGNED no 0
Mid Mediumint (8) UNSIGNED no 0
Mname char (GBK_CHINESE_CI) No
Ucid Mediumint (8) UNSIGNED no 0
Author Char (GBK_CHINESE_CI) No
SOURCE varchar (GBK_CHINESE_CI) No
Abstract Text Gbk_chinese_ci No
Keywords char (+) Gbk_chinese_ci No
Thumb varchar (255) Gbk_chinese_ci No
Imgnum tinyint (3) UNSIGNED no 0
Letter char (2) Gbk_chinese_ci No
Vieworder smallint (6) UNSIGNED no 500
initdate Int (10) No 0
CreateDate Int (Ten) UNSIGNED no 0
Updatedate Int (Ten) UNSIGNED no 0
refreshdate Int (10) No 0
EndDate Int (10) No 0
Checked tinyint (1) UNSIGNED no 0
CustomURL varchar (+) Gbk_chinese_ci No
Nowurl varchar (255) Gbk_chinese_ci No
clicks Int (Ten) UNSIGNED no 0
Downs Int (Ten) UNSIGNED no 0
Mclicks Int (Ten) UNSIGNED no 0
Wclicks Int (Ten) UNSIGNED no 0
mdowns Int (Ten) UNSIGNED no 0
wdowns Int (Ten) UNSIGNED no 0
Mplays Int (Ten) UNSIGNED no 0
Wplays Int (Ten) UNSIGNED no 0
Dpmid smallint (6) No-1
Plays Int (ten) UNSIGNED no 0
DJ Float No 0
DT varchar (+) Gbk_chinese_ci No
GGDT varchar (+) Gbk_chinese_ci No
Dt_0 Double No 0
Dt_1 Double UNSIGNED No 0
Answercid Mediumint (8) UNSIGNED no 0
Close tinyint (1) UNSIGNED no 0
FinishDate Int (Ten) UNSIGNED no 0
CCID1 smallint (6) UNSIGNED no 0
Ccid2 smallint (6) UNSIGNED no 0
CCID3 smallint (6) UNSIGNED no 0
CCID12 varchar (255) Gbk_chinese_ci No
CCID14 smallint (6) UNSIGNED no 0
Ccid18 smallint (6) UNSIGNED no 0
PID3 Mediumint (8) UNSIGNED no 0
Inorder3 smallint (6) UNSIGNED no 0
Incheck3 tinyint (1) UNSIGNED no 0
Aesfys Int (Ten) UNSIGNED no 0
Aczfys Int (Ten) UNSIGNED no 0
LPCZSL Int (11) No 0
LPESFSL Int (11) No 0
CSJDJ Float No 0
Csjgz Float No 0
CSPJJ float UNSIGNED No 0
CZZDJ Float No 0
CZZGJ Float No 0
CZPJJ float UNSIGNED No 0
AHDS Int (Ten) UNSIGNED no 0
Azxs Int (Ten) UNSIGNED no 0
ATPs Int (Ten) UNSIGNED no 0
AHSS Int (Ten) UNSIGNED no 0
ADPs Int (Ten) UNSIGNED no 0
ADPF float UNSIGNED No 0
Ayss Int (Ten) UNSIGNED no 0
Agzs Int (Ten) UNSIGNED No
PID5 Mediumint (8) UNSIGNED no 0
Inorder5 smallint (6) UNSIGNED no 0
Incheck5 tinyint (1) UNSIGNED no 0
Pid6 Mediumint (8) UNSIGNED no 0
Inorder6 smallint (6) UNSIGNED no 0
Incheck6 tinyint (1) UNSIGNED no 0
Color varchar (GBK_CHINESE_CI) No
Relatedaid varchar (255) Gbk_chinese_ci No
ccid41 smallint (6) UNSIGNED no 0
CCID51 smallint (6) UNSIGNED no 0
ccid53 smallint (6) UNSIGNED no 0
Tid smallint (6) UNSIGNED no 0
Editorid Mediumint (8) UNSIGNED no 0
Editor char (GBK_CHINESE_CI) No
From_mid Mediumint (8) UNSIGNED no 0
From_mname char (GBK_CHINESE_CI) No
Needstatics varchar (255) Gbk_chinese_ci No
Arctpls varchar (255) Gbk_chinese_ci No
AWDs Int (Ten) UNSIGNED no 0
Atjs Int (Ten) UNSIGNED No
Azbs Int (Ten) UNSIGNED no 0
Ayxs Int (Ten) UNSIGNED No
ccid54 smallint (6) UNSIGNED no 0
Fields in table Cms_archives_4
Field Type Grooming property Null default extra action
Aid Mediumint (8) UNSIGNED no 0
Address varchar (GBK_CHINESE_CI) No
Xkzh varchar (+) Gbk_chinese_ci No
DFL varchar (GBK_CHINESE_CI) No
LHL varchar (GBK_CHINESE_CI) No
YJL varchar (GBK_CHINESE_CI) No
Wygs varchar (GBK_CHINESE_CI) No
WYF varchar (GBK_CHINESE_CI) No
QTBZ varchar (255) Gbk_chinese_ci No
KPRQ varchar (GBK_CHINESE_CI) No
Jfrq varchar (GBK_CHINESE_CI) No
JZMJ varchar (GBK_CHINESE_CI) No
ZDMJ varchar (GBK_CHINESE_CI) No
CKSM varchar (+) Gbk_chinese_ci No
Content Text Gbk_chinese_ci No
Xqjs Text Gbk_chinese_ci No
Loupanlogo varchar (255) Gbk_chinese_ci No
LPHF varchar (255) Gbk_chinese_ci No
Tel varchar (+) Gbk_chinese_ci No
Sldz varchar (255) Gbk_chinese_ci No
XQSS varchar (GBK_CHINESE_CI) No
JTXL varchar (GBK_CHINESE_CI) No
Zxcd Int (10) No 0
JGJJ Float No 0
JDJJ Float No 0
BDSM varchar (255) Gbk_chinese_ci No
LTBK varchar (255) Gbk_chinese_ci No
Lpbbs varchar (GBK_CHINESE_CI) No
XQHS varchar (GBK_CHINESE_CI) No
jgdate Int (10) No 0
LPPMTU varchar (255) Gbk_chinese_ci No
Wydz varchar (GBK_CHINESE_CI) No
leixing varchar (1) gbk_chinese_ci no 0
LCS varchar (GBK_CHINESE_CI) No
HxS Int (10) No 0
TSLP varchar (255) Gbk_chinese_ci No
Fkxs varchar (255) Gbk_chinese_ci No
LPXZ varchar (255) Gbk_chinese_ci No
DTSM Text Gbk_chinese_ci No
Fields in table Cms_housesrecords
Field Type Grooming property Null default extra action
CID Int (Ten) UNSIGNED no auto_increment
Aid Mediumint (9) UNSIGNED No
IsNew tinyint (1) No
Highest float UNSIGNED No
Average float UNSIGNED No
Lowest float UNSIGNED No
Message varchar (255) Gbk_chinese_ci No
CreateDate Int (one) UNSIGNED no
The function that needs to be implemented is if the last recorded price is higher than this record price output ↑ the same → Drop ↓
Here is the code, help to see, dead and alive do not come out of things.
$sql = "Select a. ' Aid ', a. ' Subject ' from Cms_archives15 a left JOIN cms_archives_4 C on (c.aid=a.aid) WHERE a.caid = ' 2 ' and A.chid= ' 4 ' and (c.leixing= ' 0 ' OR c.leixing= ' 1 ') and ' ccid1 ' = ' 211 ' ORDER by a.updatedate DESC LIMIT 0,80 ";

$query = mysql_query ($sql);
while ($arr = Mysql_fetch_array ($query)) {
$jgsql = "Select ' Average ' from ' cms_housesrecords ' where ' aid ' = '". $arr [' aid ']. "' ORDER BY ' createdate ' desc limit 2";

$jgquery = mysql_query ($jgsql);
$i = 0;
while ($jgarr = Mysql_fetch_array ($jgquery)) {
if ($i <1) {
$f _jiage = $jgarr [' Average '];
}else{
$s _jiage = $jgarr [' Average '];
}
$i + +;

}
if ($f _jiage> $s _jiage) {

$jgstyle = ' ↑';

}
ElseIf ($f _jiage== $s _jiage) {

$jgstyle = ' →';
}else{

$jgstyle = ' ↓';

}

?>


  • . html "> Meta



  • }
    ?>

    The above is I write a price comparison of the query output, but what does not show, experts to guide, see is not what field, or forget what things?


    Reply to discussion (solution)

    The amount of information is too large dizzying have a point?

    Step by step debugging; output $jgarr look, and then compare by If.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.