Now I have a tb_activity table and a tb_participate table
The P_activity field in table Tb_participate is the same as the A_num value in table tb_activity
Pass
';}? >
I can output all the values of the P_activity field in the table Tb_participate (that is, the A_num value in table tb_activity)
But I want to output the value of the A_name field in the table tb_activity at the same time
How should I rewrite the code?
Reply to discussion (solution)
$sql 8= "SELECT * from Tb_participate a inner joins tb_activity B on a.p_activity=b.a_num where a.p_voluteer = ' $fnum '";
$result 8=mysql_query ($sql 8) or Die (' database query failed! ');
while ($row =mysql_fetch_array ($result 8)) {
echo $row [' p_activity ']. ' '. $row [' A_name ']. '
';
}
$sql 8= "SELECT * from Tb_participate, tb_activity where Tb_participate.p_activity=tb_activity.a_num and Tb_ Participate.p_voluteer = ' $fnum ';
$sql 8= "SELECT * from Tb_participate, tb_activity where Tb_participate.p_activity=tb_activity.a_num and Tb_ Participate.p_voluteer = ' $fnum ';
$sql 8= "SELECT * from Tb_participate, tb_activity where Tb_participate.p_activity=tb_activity.a_num and Tb_ Participate.p_voluteer = ' $fnum ';
$result 8=mysql_query ($sql 8) or Die (' database query failed! ');
while ($row =mysql_fetch_array ($result 8)) {
echo $row [' tb_participate.p_activity ']. ' '. $row [' Tb_activity.a_name ']. '
';
}
?>
You can't print anything if you change it.
echo $row [' tb_participate.p_activity ']. ' '. $row [' Tb_activity.a_name ']. '
'
How did you write that? I didn't ask you to write that, did I?
echo $row [' p_activity ']. ' '. $row [' A_name ']. '
'
$sql 8= "SELECT * from Tb_participate a inner joins tb_activity B on A.p_activity=b.a_num where a.p_ Voluteer = ' $fnum ';
$result 8=mysql_query ($sql 8) or Die (' database query failed! ');
while ($row =mysql_fetch_array ($result 8)) {
echo $row [' p_activity ']. ' '. $row [' A_name ']. '
';
}
!--? php
$sql 8= "SELECT * from Tb_participate a inner joins tb_activity B on A.p_activity=b.a_num wh ere a.p_voluteer = ' $fnum ';
$result 8=mysql_query ($sql 8) or Die (' database query failed! ');
while ($row =mysql_fetch_array ($result 8)) {
echo $row [' p_activity ']. ' '. $row [' A_name ']. '
';
}
?>
My original code can print out
HD090515
HD090517
Two lines but nothing will print after the change
echo $row [' tb_participate.p_activity ']. ' '. $row [' Tb_activity.a_name ']. '
'
How did you write that? I didn't ask you to write that, did I?
echo $row [' p_activity ']. ' '. $row [' A_name ']. '
'
$sql 8= "SELECT * from Tb_participate, tb_activity where Tb_participate.p_activity=tb_activity.a_num and Tb_ Participate.p_voluteer = ' $fnum ';
$result 8=mysql_query ($sql 8) or Die (' database query failed! ');
while ($row =mysql_fetch_array ($result 8)) {
echo $row [' p_activity ']. ' '. $row [' A_name ']. '
';
}
?>
Still no response ... I can't print anything.
Suggest to put down your table structure
Suggest to put down your table structure
My QQ number: 273041720
Can you add a little bit?
Great God jordan102&& Moderator adult xuzuning
Table data, suspect that there is no data to meet the criteria. SQL can be pasted into the phpmyadmin inside the execution of the know.
Table data, suspect that there is no data to meet the criteria. SQL can be pasted into the phpmyadmin inside the execution of the know.
--PhpMyAdmin SQL Dump
--Version 2.11.6
--Http://www.phpmyadmin.net
--
--Host: localhost
--Date of generation: May 17, 2013 08:35
--Server version: 5.0.51
--PHP version: 5.2.6
SET sql_mode= "No_auto_value_on_zero";
--
--Database: ' Db_voluteer '
--
-- --------------------------------------------------------
--
--The structure of the table ' tb_activity '
--
CREATE TABLE ' tb_activity ' (
' A_num ' varchar (8) Not NULL,
' a_name ' varchar default NULL,
' a_date ' date default NULL,
' a_place ' varchar default NULL,
' A_number ' int (3) default NULL,
' a_department ' varchar default NULL,
' a_principal ' varchar default NULL,
' a_telephone ' varchar default NULL,
' a_sponsor ' varchar default NULL,
' A_remark ' text,
PRIMARY KEY (' A_num ')
) Engine=innodb DEFAULT Charset=utf8;
--
--Export the data in the table ' tb_activity '
--
INSERT into ' tb_activity ' (' a_num ', ' a_name ', ' a_date ', ' a_place ', ' a_number ', ' a_department ', ' a_principal ', ' A_ ' Telephone ', ' a_sponsor ', ' A_remark ') VALUES
(' HD130512 ', ' Stamina test ', ' 2013-05-12 ', ' 4 floor ' of the Science faculty ', 0, ' IEC work ', ' ', ' 2147483647 ', ' ', '),
(' HD130515 ', ' SAD ', ' 0000-00-00 ', ' SD ', 0, ' ', ' ', ' ', ', '),
(' HD130517 ', ' TEST ', ' 2013-05-17 ', ' D ', NULL, ' IEC work ', NULL, ' 18646665427 ', NULL, NULL),
(' HD130525 ', ' May days of Tomorrow's Rebirth ' concert ', ' 0000-00-00 ', ' Harbin International Convention and Exhibition Center ', 0, ' telecommunications Department ', ' ', ' 15114590656 ', ' WX ', ');
-- --------------------------------------------------------
--
--The structure of the table ' Tb_department '
--
CREATE TABLE ' tb_department ' (
' D_num ' int (2) is not NULL,
' d_name ' varchar default NULL,
' d_minister ' varchar default NULL,
PRIMARY KEY (' D_num ')
) Engine=innodb DEFAULT Charset=utf8;
--
--Export the data in the table ' Tb_department '
--
INSERT into ' tb_department ' (' d_num ', ' d_name ', ' d_minister ') VALUES
(1, ' Shen Qi ', ' work Department '),
(2, ' Telecommunications Department ', ' Bu Wei '),
(9, ' IEC Work Department ', ' Meilong ');
-- --------------------------------------------------------
--
--The structure of the table ' Tb_finance '
--
CREATE TABLE ' tb_finance ' (
' F_num ' varchar (8) Not NULL,
' f_type ' varchar default NULL,
' f_date ' date default NULL,
' F_money ' int (ten) is default NULL,
' f_activity ' varchar default NULL,
' f_users ' varchar default NULL,
' F_telephone ' varchar (one) default NULL,
' F_remark ' text,
PRIMARY KEY (' F_num ')
) Engine=innodb DEFAULT Charset=utf8;
--
--Export the data in the table ' Tb_finance '
--
INSERT into ' tb_finance ' (' f_num ', ' f_type ', ' f_date ', ' F_money ', ' f_activity ', ' f_users ', ' f_telephone ', ' F_remark ') VAL UES
(' ZC090515 ', ' income ', ' 0000-00-00 ', ' + ', ' SAD ', ' 12412421 ', ' AD '),
(' ZC090516 ', ' spending ', ' 0000-00-00 ', 100, ', ', ', ', ');
-- --------------------------------------------------------
--
--The structure of the table ' Tb_goods '
--
CREATE TABLE ' Tb_goods ' (
' G_num ' varchar (8) Not NULL,
' g_name ' varchar default NULL,
' g_type ' varchar default NULL,
' G_count ' int (ten) is default NULL,
' g_date ' date default NULL,
' g_user ' varchar default NULL,
' g_activity ' varchar default NULL,
' g_telephone ' varchar default NULL,
' g_place ' varchar default NULL,
' G_remark ' text,
PRIMARY KEY (' G_num ')
) Engine=innodb DEFAULT Charset=utf8;
--
--Export the data in the table ' Tb_goods '
--
INSERT into ' tb_goods ' (' g_num ', ' g_name ', ' g_type ', ' g_count ', ' g_date ', ' g_user ', ' g_activity ', ' g_telephone ', ' g_place ' ', ' G_remark ') VALUES
(' CK090515 ', ' MX ', ' out of the library ', 0, ' 0000-00-00 ', ' ', ' ', ' ', ' ', '),
(' RK090516 ', ' MX2 ', ' warehousing ', 5, ' 0000-00-00 ', ' ', ' test ', ', ', ', ');
-- --------------------------------------------------------
--
--The structure of the table ' Tb_organization '
--
CREATE TABLE ' tb_organization ' (
' O_num ' int (8) not NULL auto_increment,
' o_department ' varchar (8) Default NULL,
' o_activity ' varchar (8) Default NULL,
PRIMARY KEY (' O_num ')
) Engine=innodb DEFAULT Charset=utf8 auto_increment=1;
--
--Export the data in the table ' Tb_organization '
--
-- --------------------------------------------------------
--
--The structure of the table ' Tb_participate '
--
CREATE TABLE ' Tb_participate ' (
' P_num ' int (8) not NULL auto_increment,
' P_voluteer ' varchar (8) Default NULL,
' p_activity ' varchar (8) Default NULL,
PRIMARY KEY (' P_num ')
) Engine=innodb DEFAULT Charset=utf8 auto_increment=6;
--
--Export the data in the table ' Tb_participate '
--
INSERT into ' tb_participate ' (' p_num ', ' p_voluteer ', ' p_activity ') VALUES
(1, ' 90901 ', ' HD090515 '),
(2, ' 90902 ', ' HD090515 '),
(3, ' 100901 ', ' HD130525 '),
(4, ' 100902 ', ' HD130525 '),
(5, ' 90901 ', ' HD090517 ');
-- --------------------------------------------------------
--
--The structure of the table ' Tb_users '
--
CREATE TABLE ' Tb_users ' (
' u_username ' varchar () not NULL,
' U_password ' varchar () not NULL,
' u_role ' varchar () not NULL,
PRIMARY KEY (' U_username ')
) Engine=innodb DEFAULT Charset=utf8;
--
--Export the data in the table ' Tb_users '
--
INSERT into ' tb_users ' (' u_username ', ' U_password ', ' u_role ') VALUES
(' Wangxun ', ' 900727 ', ' admin ');
-- --------------------------------------------------------
--
--The structure of the table ' Tb_voluteer '
--
CREATE TABLE ' Tb_voluteer ' (
' V_num ' int (6) is not NULL,
' v_name ' varchar default NULL,
' V_stunum ' int (ten) is default NULL,
' V_sex ' varchar (2) Default NULL,
' v_id ' varchar default NULL,
' V_birth ' date default NULL,
' v_place ' varchar default NULL,
' v_nation ' varchar default NULL,
' v_politics ' varchar default NULL,
' v_department ' varchar default NULL,
' v_position ' varchar default NULL,
' V_cellphone ' varchar (one) default NULL,
' v_qq ' varchar default NULL,
' v_email ' varchar default NULL,
' v_enterdate ' date default NULL,
' v_college ' varchar default NULL,
' v_major ' varchar default NULL,
' v_dormitory ' varchar default NULL,
PRIMARY KEY (' V_num ')
) Engine=innodb DEFAULT Charset=utf8;
--
--Export the data in the table ' Tb_voluteer '
--
INSERT into ' tb_voluteer ' (' v_num ', ' v_name ', ' v_stunum ', ' v_sex ', ' v_id ', ' V_birth ', ' v_place ', ' v_nation ', ' v_politics ' , ' v_department ', ' v_position ', ' v_cellphone ', ' v_qq ', ' v_email ', ' v_enterdate ', ' v_college ', ' v_major ', ' v_dormitory ') VALUES
(90101, ' Shen ', 0, ' Male ', ' 0 ', ' 0000-00-00 ', ' ', ' ', ' Party members ', ' work of the ministry ', ' minister ', ' 0 ', ' 0 ', ' ', ' 0000-00-00 ', ', ', ', '),
(90201, ' Pu ', 2009020000, ' ', ' 2147483647 ', ' 0000-00-00 ', ', ', ' League of Ministers ', ' telecom work ', ' minister ', ' 0 ', ' 0 ', ' ', ' 0000-00-00 ', ', ', ''),
(90202, ' Min Min ', 2009020001, ' female ', ' 230606199007200850 ', ' 0000-00-00 ', ', ', ' Party member ', ' Telecommunications department ', ' minister ', ' ', ' 99999999999 ', ', ' 00 00-00-00 ', ', ', '),
(90301, ' Li ', 2009020003, ' female ', ' 230606199007270999 ', ' 0000-00-00 ', ' ', ' ', ' Party members ', ' mechanical work ', ' minister ', ' 15114590685 ', ', ', ' 000 0-00-00 ', ' College of Mechanical Engineering ', ', '),
(90401, ' Sun Peng ', 2009025837, ' Male ', ' ', ' 0000-00-00 ', ' ', ' ', ' Party members ', ' construction work ', ' minister ', ' ', ' ', ' ' 0000-00-00 ', ' the ' School of Architecture ', ', '),
(90402, ' Zeng ', 2009020006, ' female ', ' ', ' 0000-00-00 ', ' ', ' ', ' mass ', ' computer work ', ' minister ', ' ', ' ', ' ' 0000-00-00 ', ' The Institute of Architecture ', ', '),
(90501, ' Zhao Deer ', 2009020007, ' female ', ' 230606199007270891 ', ' 0000-00-00 ', ' ', ' ', ' League members ', ' general Propaganda Department ', ' minister ', ' ', ' ', ' ', ' 0000-00-00 ' , ' The School of Economic management ', ', '),
(90901, ' King ', 2009025838, ' Male ', ' 0 ', ' 0000-00-00 ', ' Shanghai ', ' ', ' ', ' IEC work ', ' minister ', ' 21474836478 ', ' 273041720 ', ' Wxsyd966@gmai L.com ', ' 0000-00-00 ', ' International Institute of Education ', ' Go to Canada computer 09-1 ', ' 16#604 '),
(91101, ' Westport ', 2009025836, ' Male ', ' ', ' 0113-05-10 ', ' ', ' ', ' members ', ' safe work ', ' minister ', ' ', ' ', ' ' 0000-00-00 ', ' Safety Engineering Institute ', ', '),
(100901, ' Ru ', 0, ' female ', ' 0 ', ' 0000-00-00 ', ' ', ' ', ' mass ', ' IEC work ', ' officer ', ' 0 ', ' 0 ', ' ', ' 0000-00-00 ', ', ', ', '),
(100902, ' Yi ', 2010020666, ' female ', ' 230606199007270002 ', ' 0000-00-00 ', ' ', ' ', ' mass ', ' IEC work ', ' Officer ', ' ', ', ', ' 0000-00-00 ', '', '', '');
What's your $fnum, echo $sql 8; Look.
Put SQL in phpMyAdmin and execute it and see if there's any result.
What's your $fnum, echo $sql 8; Look.
Put SQL in phpMyAdmin and execute it and see if there's any result.
$fnum =90901
echo $sql 8; If using my code is to print out select * from tb_participate where p_voluteer = ' 90901 ' select * from tb_participate where p_voluteer = ' 90901 '
echo $sql 8; The great gods and moderators of the show without any
I've been phpmyadmin the SQL all the time. This is my graduation project.
Please god add me qq,273041720, can remote
P_voluteer = ' 90901 There is no tb_participate.p_activity=tb_activity.a_num data, so there is no display.
P_voluteer = ' 90901 There is no tb_participate.p_activity=tb_activity.a_num data, so there is no display.
I'll go!!!!!!!!!!
FXXX, kneel and thank the Great God!!!!!!!!!!!!
Great God Mighty!!!!!!!!!!!!
Jordan still has two bugs http://bbs.csdn.net/topics/390460423