How can I check the data in another table field? now I have a tb_activity table and a tb_participant table.
The p_activity field in table tb_participant ipate is the same as the_num value in table tb_activity.
Pass
';}?>
I can output all values of the p_activity field in the table tb_participant ipate (that is, the value of a_num in the table tb_activity)
However, I want to output the value of the_name field in tb_activity at the same time.
How can I rewrite the code?
Reply to discussion (solution)
$ Sql8 = "select * from tb_participant ipate a inner join tb_activity B on a. p_activity = B. a_num where a. p_voluteer = '$ fnum '";
$ Result8 = mysql_query ($ sql8) or die ('database query failed! ');
While ($ row = mysql_fetch_array ($ result8 )){
Echo $ row ['p _ active']. ''. $ row ['A _ name'].'
';
}
$ Sql8 = "select * from tb_participant ipate, tb_activity where tb_participant ipate.p_activity = tb_activity.a_num and tb_participant ipate.p_voluteer = '$ fnum '";
$ Sql8 = "select * from tb_participant ipate, tb_activity where tb_participant ipate.p_activity = tb_activity.a_num and tb_participant ipate.p_voluteer = '$ fnum '";
$ Sql8 = "select * from tb_participant ipate, tb_activity where tb_participant ipate.p_activity = tb_activity.a_num and tb_participant ipate.p_voluteer = '$ fnum '";
$ Result8 = mysql_query ($ sql8) or die ('database query failed! ');
While ($ row = mysql_fetch_array ($ result8 )){
Echo $ row ['TB _ participant. p_activity '].'. $ row ['TB _ activity. a_name '].'
';
}
?>
In this way, nothing can be printed after modification.
Echo $ row ['TB _ participant. p_activity '].'. $ row ['TB _ activity. a_name '].'
'
How can I write it like this? Didn't you write this?
Echo $ row ['p _ active']. ''. $ row ['A _ name'].'
'
$ Sql8 = "select * from tb_participant ipate a inner join tb_activity B on a. p_activity = B. a_num where a. p_voluteer = '$ fnum '";
$ Result8 = mysql_query ($ sql8) or die ('database query failed! ');
While ($ row = mysql_fetch_array ($ result8 )){
Echo $ row ['p _ active']. ''. $ row ['A _ name'].'
';
}
$ Sql8 = "select * from tb_participant ipate a inner join tb_activity B on a. p_activity = B. a_num where a. p_voluteer = '$ fnum '";
$ Result8 = mysql_query ($ sql8) or die ('database query failed! ');
While ($ row = mysql_fetch_array ($ result8 )){
Echo $ row ['p _ active']. ''. $ row ['A _ name'].'
';
}
?>
I can print out the original code.
HD090515
HD090517
Two rows, but nothing can be printed after modification.
Echo $ row ['TB _ participant. p_activity '].'. $ row ['TB _ activity. a_name '].'
'
How can I write it like this? Didn't you write this?
Echo $ row ['p _ active']. ''. $ row ['A _ name'].'
'
$ Sql8 = "select * from tb_participant ipate, tb_activity where tb_participant ipate.p_activity = tb_activity.a_num and tb_participant ipate.p_voluteer = '$ fnum '";
$ Result8 = mysql_query ($ sql8) or die ('database query failed! ');
While ($ row = mysql_fetch_array ($ result8 )){
Echo $ row ['p _ active']. ''. $ row ['A _ name'].'
';
}
?>
No response ...... Nothing can be printed
We recommend that you paste your table structure
We recommend that you paste your table structure
My QQ: 273041720
Can I add it?
Great God jordan102 & moderator xuzuning
It is suspected that the table data does not meet the conditions. You can paste the SQL statement into phpmyadmin and execute it.
It is suspected that the table data does not meet the conditions. You can paste the SQL statement into phpmyadmin and execute it.
-- PhpMyAdmin SQL Dump
-- Version 2.11.6
Http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation date: May 17, 2013
-- Server version: 5.0.51
-- PHP version: 5.2.6
SET SQL _MODE = "NO_AUTO_VALUE_ON_ZERO ";
--
-- Database: 'DB _ voluteer'
--
----------------------------------------------------------
--
-- Table structure 'TB _ activity'
--
Create table 'TB _ activity '(
'A _ num' varchar (8) not null,
'A _ name' varchar (20) default NULL,
'A _ date' date default NULL,
'A _ place 'varchar (20) default NULL,
'A _ number' int (3) default NULL,
'A _ department 'varchar (20) default NULL,
'A _ principal' varchar (20) default NULL,
'A _ telephone 'varchar (20) default NULL,
'A _ partition Sor 'varchar (20) default NULL,
'A _ remark' text,
Primary key ('a _ num ')
) ENGINE = InnoDB default charset = utf8;
--
-- Export the data in the table 'TB _ active'
--
Insert into 'TB _ active' ('a _ num', 'a _ name', 'a _ date', 'a _ place', 'a _ number ', 'A _ department ', 'a _ prinal al', 'a _ telephone ', 'a _ partition Sor', 'a _ remark') VALUES
('Hd130512', 'Physical fitness test', '1970-05-12 ', '4th floor of the College of Science', 0, 'iec Department of Work ',', '123 ','', ''),
('Hd130515', 'Sad ', '2017-00-00', 'SD', 0 ,'','','','',''),
('Hd130517', 'test', '1970-05-17 ', 'D', NULL, 'iec work part', NULL, '20140901', NULL, NULL ),
('Hd130525', 'August day "tomorrow's Rebirth" concert ', '2017-00-00', 'Harbin International Convention and Exhibition Center', 0, 'telecommunication department ','', '20140901', 'wx ','');
----------------------------------------------------------
--
-- Table structure 'TB _ department'
--
Create table 'TB _ department '(
'D _ num' int (2) not null,
'D _ name' varchar (20) default NULL,
'D _ minister 'varchar (10) 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, 'information environment department ', 'shenqi '),
(2, 'telecommunication department ', 'puwei '),
(9, 'iec Department of Work ', 'Wang Wei ');
----------------------------------------------------------
--
-- Table structure 'TB _ finance'
--
Create table 'TB _ finance '(
'F _ num' varchar (8) not null,
'F _ type' varchar (10) default NULL,
'F _ date' date default NULL,
'F _ money' int (10) default NULL,
'F _ activity' varchar (20) default NULL,
'F _ users' varchar (20) default NULL,
'F _ telephone 'varchar (11) 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') VALUES
('Zc090515', 'revenue ', '1970-00-00', 0000, '', 'Sad ', '123', 'AD '),
('Zc090516', 'expenditure ', '2017-00-00', 0000 ,'','','','');
----------------------------------------------------------
--
-- Table structure 'TB _ goods'
--
Create table 'TB _ goods '(
'G _ num' varchar (8) not null,
'G _ name' varchar (20) default NULL,
'G _ type' varchar (10) default NULL,
'G _ count' int (10) default NULL,
'G _ date' date default NULL,
'G _ user' varchar (20) default NULL,
'G _ activity' varchar (20) default NULL,
'G _ telephone 'varchar (20) default NULL,
'G _ place 'varchar (20) 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 _ active', 'G _ telephone ', 'G _ place', 'G _ remark') VALUES
('Ck090515', 'MX ', 'Warehouse output', 0, '2017-00-00 ','','','','',''),
('Rk090516', 'mx2 ', 'Warehouse receiving', 5, '2017-00-00 ', '', 'test ','','','');
----------------------------------------------------------
--
-- Table structure '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 table structure is 'TB _ predicate'
--
Create table 'TB _ predicate '(
'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 _ deleipate'
--
Insert into 'TB _ exception' ('P _ num', 'p _ voluteer ', 'p _ active') VALUES
(1, '123', 'hd090515 '),
(2, '123', 'hd090515 '),
(3, '123', 'hd130525 '),
(4, '20140901', 'hd130525 '),
(5, '123', 'hd090517 ');
----------------------------------------------------------
--
-- Table structure 'TB _ users'
--
Create table 'TB _ users '(
'U _ username' varchar (10) not null,
'U _ password' varchar (10) not null,
'U _ role' varchar (10) 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
('Hangzhou', '123', 'admin ');
----------------------------------------------------------
--
-- Table structure 'TB _ voluteer'
--
Create table 'TB _ voluteer '(
'V _ num' int (6) not null,
'V _ name' varchar (20) default NULL,
'V _ stunum' int (10) default NULL,
'V _ sex' varchar (2) default NULL,
'V _ id' varchar (18) default NULL,
'V _ birth 'date default NULL,
'V _ place' varchar (10) default NULL,
'V _ nation' varchar (10) default NULL,
'V _ politics 'varchar (10) default NULL,
'V _ department 'varchar (20) default NULL,
'V _ position' varchar (10) default NULL,
'V _ cellphone' varchar (11) default NULL,
'V _ QQ' varchar (20) default NULL,
'V _ email 'varchar (20) default NULL,
'V _ enterdate' date default NULL,
'V _ college 'varchar (20) default NULL,
'V _ major' varchar (20) default NULL,
'V _ dormitory 'varchar (20) 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 _ category', 'V _ position ', 'V _ cellphone', 'V _ QQ', 'V _ mail', 'V _ enterdate', 'V _ college ', 'V _ major ', 'V _ dormitory ') VALUES
(90101, 'shen', 0, 'male', '0', '1970-00-00 ', '','', 'Party members', 'zihuan Department of Work ', 'Ministers ', '0', '0', '', '2017-00-00 ','','',''),
(90201, 'pu', 2009020000, '', '000000', '2017-00-00 ','', '', 'Member', 'telecommunication department ', 'Ministers ', '0', '0', '', '2017-00-00 ','','',''),
(90202, 'min Min ', 2009020001, 'female', '000000', '2017-00-00 ', 'Party members', 'telecommunication department ', 'Ministers ', '', '000000','', '2017-00-00 ','','',''),
(90301, 'Lil', 2009020003, 'female ', '000000', '000000-00', 'Party members', 'mechanical Department of Work ', 'Ministers ', '000000', '','', '2017-00-00', 'School of mechanical engineering ','',''),
(90401, 'Sun Peng', 2009025837, 'male', '', '1970-00-00 ','', '', 'Party members', 'construction department ', 'Ministers ', '', '2017-00-00', 'Architecture and Engineering College ','',''),
(90402, 'Zeng ', 2009020006, 'female', '', '2017-00-00 ','', '', 'masses', 'Computer Department of Work ', 'Ministers ', '', '2017-00-00', 'Architecture and Engineering College ','',''),
(90501, 'zhaolu ', 2009020007, 'female', '000000', '000000-00 ', 'group members', 'General Assembly propaganda department ', 'Ministers ', '', '2017-00-00', 'School of Economics and Management ','',''),
(90901, 'Wang ', 2009025838, 'male', '0', '2017-00-00', 'Shanghai', '','', 'iec Department of Work ', 'Ministers ', '000000', '000000', 'wxsyd966 @ gmail.com', '2017-00-00 ', 'School of International Education', 'Computer 09-1 in Canada ', '16 #604 '),
(91101, 'Song ta', 2009025836, 'male', '', '1970-05-10 ','', '', 'Member', 'security Department of Work ', 'Ministers ', '', '2017-00-00', 'security Engineering College ','',''),
(100901, 'Ru ', 0, 'female', '0', '2017-00-00 ', '','', 'masses', 'iec Department of Work ', 'Officers ', '0', '0', '', '2017-00-00 ','','',''),
(100902, 'hangzhou', 2010020666, 'female ', '000000', '2017-00-00', '','', 'masses ', 'iec Department of Work ', 'Officers ', '', '2017-00-00 ','','','');
What is your $ fnum, echo $ sql8.
Put the SQL statement in phpmyadmin and execute it. no result is returned.
What is your $ fnum, echo $ sql8.
Put the SQL statement in phpmyadmin and execute it. no result is returned.
$ Fnum = 90901
Echo $ sql8; if I use my code to print the select * from tb_participant ipate where p_voluteer = '000000' select * from tb_participant ipate where p_voluteer = '000000'
Echo $ sql8; the gods and moderators are not displayed
I keep SQL in phpmyadmin. this is my graduation project.
Please add me QQ, 273041720, remote
When p_voluteer = '100, there is no data for tb_participant ipate.p_activity = tb_activity.a_num, so there is no display.
When p_voluteer = '100, there is no data for tb_participant ipate.p_activity = tb_activity.a_num, so there is no display.
Let me go !!!!!!!!!!
FXXX, thank you !!!!!!!!!!!!
Mighty !!!!!!!!!!!!
Jordan has two more BUG http://bbs.csdn.net/topics/390460423