•mihaim1980
Strain
Karma: 1
Deconectat
Mesaje: 2
|
|
« : Ianuarie 02, 2012, 15:38:29 » |
|
Salut! Vreau sa afisez niste date ca intr-un catalog scolar adica: sa afisez pe un rand materile si pe randurile urmatoare notele corespunzatoare fiecarei materie si va rog sa ma ajutati o niste lini de cod Am incercat eu, dar nu mi-a iesit: Script php(e cam varza): <?php require_once('auth.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <center> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <body bgcolor="#b4cff0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Catalog</title> <link rel="stylesheet" href="footer.css" /> <font face="Berlin Sans FB Demi" color="white" size="2"> </head> <body> <div class="wrapper"> <h1>Bine ai venit, <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1> <a href="logout.php">Logout</a> <a href="chpass.php">Schimba parola</a> </font>
<font face="Berlin Sans FB Demi" color="white" size="3"> <? require_once('config.php'); //Connect to mysql server error_reporting (E_ALL ^ E_NOTICE); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } echo '<br><br>'; $query=mysql_query("select * from elev where nume='".$_SESSION['SESS_FIRST_NAME']."'"); $result=mysql_fetch_array($query); echo '<h1>Informatii elev</h1>'; echo '<table border="1">'; echo "<tr><td>Nume si prenume</td><td>".$result['nume']."</td> <tr><td>Clasa</td><td>".$result['clasa']."</td> <tr><td>CNP</td><td>".$result['cnp']."</td>"; echo '</table>'; $query2=mysql_query("SELECT * from materie"); $a=array(); $i=0; while ($result2=mysql_fetch_array($query2)) { $a[$i]=$result2['nume']; $i++; } echo '<br><br>'; echo '<h1>Note</h1>'; echo '<center>'; echo '<table border="1"><b><tr>'; for($x=0;$x<$i;$x++) { echo "<tr><td>".$a[$x]."</td></tr>"; } for($x=0;$x<$i;$x++) { $matid=$x+1; $sql=mysql_query("select nota from note where materie_id='".$matid."' and elev_id='".$_SESSION['SESS_MEMBER_ID']."'"); while ($result=mysql_fetch_array($sql)) { echo "<td>".$result['nota']."</td>"; } } echo '</tr></table>'; echo '</center>'; echo '<br><br>'; echo '<h1>Absente</h1>'; echo '<center>'; echo '<table border="1"><b><tr>'; echo '</tr><tr>'; echo '</tr></table>'; ?> </b> </font> </body> </div>
</center> </html> Dump phpmyadmin: -- phpMyAdmin SQL Dump -- version 3.4.5 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Dec 31, 2011 at 09:35 PM -- Server version: 5.5.16 -- PHP Version: 5.3.8
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */;
-- -- Database: `mydb` --
-- --------------------------------------------------------
-- -- Table structure for table `clase` --
CREATE TABLE IF NOT EXISTS `clase` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nume` text NOT NULL, `materie_id` int(11) NOT NULL, `profesor_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
-- -- Dumping data for table `clase` --
INSERT INTO `clase` (`id`, `nume`, `materie_id`, `profesor_id`) VALUES (1, '9A', 1, 1), (2, '9A', 2, 1), (3, '9C', 0, 0), (4, '10A', 0, 0), (5, '10B', 0, 0), (6, '10C', 0, 0), (7, '11A', 0, 0), (8, '11B', 0, 0), (9, '11C', 0, 0), (10, '12A', 0, 0), (11, '12B', 0, 0), (12, '12C', 0, 0);
-- --------------------------------------------------------
-- -- Table structure for table `elev` --
CREATE TABLE IF NOT EXISTS `elev` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nume` text NOT NULL, `parola` text NOT NULL, `cnp` int(11) NOT NULL, `clasa` text NOT NULL, `email` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
-- -- Dumping data for table `elev` --
INSERT INTO `elev` (`id`, `nume`, `parola`, `cnp`, `clasa`, `email`) VALUES (1, 'Mihai', '7c37ed5b5b72d2c6927e25357e6c488a', 0, '9A', '[email protected]');
-- --------------------------------------------------------
-- -- Table structure for table `elev_has_materie` --
CREATE TABLE IF NOT EXISTS `elev_has_materie` ( `elev_id` int(11) NOT NULL, `materie_id` int(11) NOT NULL, `abs` varchar(45) DEFAULT NULL, KEY `fk_elev_has_materie_materie1` (`materie_id`), KEY `fk_elev_has_materie_elev` (`elev_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- -- Dumping data for table `elev_has_materie` --
INSERT INTO `elev_has_materie` (`elev_id`, `materie_id`, `abs`) VALUES (1, 1, '1'), (1, 1, '2'), (1, 1, '10'), (1, 2, '10/2x');
-- --------------------------------------------------------
-- -- Table structure for table `main` --
CREATE TABLE IF NOT EXISTS `main` ( `bgcolor` text NOT NULL, `textcolor` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
-- -- Table structure for table `materie` --
CREATE TABLE IF NOT EXISTS `materie` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nume` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;
-- -- Dumping data for table `materie` --
INSERT INTO `materie` (`id`, `nume`) VALUES (1, 'Limba romana si literatura romana'), (2, 'Limba moderna 1'), (3, 'Limba moderna 2'), (4, 'Matematica'), (5, 'Fizica'), (6, 'Chimie'), (7, 'Biologie'), (8, 'Istorie'), (9, 'Geografie'), (10, 'Socio-umane / Educatie pentru societate'), (11, 'Socio-umane'), (12, 'Religie'), (13, 'Educatie muzicala'), (14, 'Educatie plastica'), (15, 'Educatie fizica'), (16, 'Consiliere si orientare'), (17, 'Tehnologia informatiei si a comunicatiilor '), (18, 'Informatica'), (19, 'Educatie antreprenoriala');
-- --------------------------------------------------------
-- -- Table structure for table `note` --
CREATE TABLE IF NOT EXISTS `note` ( `elev_id` int(11) NOT NULL, `materie_id` int(11) NOT NULL, `nota` float NOT NULL, KEY `elev_id` (`elev_id`), KEY `materie_id` (`materie_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- -- Dumping data for table `note` --
INSERT INTO `note` (`elev_id`, `materie_id`, `nota`) VALUES (1, 1, 10), (1, 2, 1), (1, 1, 4), (1, 1, 10), (1, 1, 10), (1, 1, 10), (1, 1, 1010), (1, 2, 10);
-- --------------------------------------------------------
-- -- Table structure for table `profesori` --
CREATE TABLE IF NOT EXISTS `profesori` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nume` text NOT NULL, `parola` text NOT NULL, `dirig` text NOT NULL, `email` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
-- -- Dumping data for table `profesori` --
INSERT INTO `profesori` (`id`, `nume`, `parola`, `dirig`, `email`) VALUES (2, 'admin', '7c37ed5b5b72d2c6927e25357e6c488a', 'admin', '[email protected]'), (4, 't', 't', 't', 't'), (5, 'Mihai', '2eff751817560434a16345d8f94a8abe', '9A', '[email protected]');
-- -- Constraints for dumped tables --
-- -- Constraints for table `elev_has_materie` -- ALTER TABLE `elev_has_materie` ADD CONSTRAINT `fk_elev_has_materie_elev` FOREIGN KEY (`elev_id`) REFERENCES `elev` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, ADD CONSTRAINT `fk_elev_has_materie_materie1` FOREIGN KEY (`materie_id`) REFERENCES `materie` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|