Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.52 KB | None | 0 0
  1. lab3->>>>>>>>>>>>>>>> SQL
  2.  
  3. //meniu html
  4. <body>
  5. <form method="GET"
  6. action="http://localhost/introducere_studenti.php">
  7. <table border="3" align=”center” BGCOLOR="Silver">
  8. <tr>
  9. <td>Marca:</td>
  10. <td><input type="text" name="marca_form"></td>
  11. </tr>
  12. <tr>
  13. <td>Nume:</td>
  14. <td><input type="text" name="nume_form"></td>
  15. </tr>
  16. <tr>
  17. <td>Prenume:</td>
  18. <td><input type="text" name="prenume_form"></td>
  19. </tr>
  20. <tr>
  21. <td>An studiu:</td>
  22. <td>
  23. <select name="an_form">
  24. <option value="1">An 1</option>
  25. <option value="2">An 2</option>
  26. <option value="3">An 3</option>
  27. <option value="4">An 4</option>
  28. </option>
  29. </select>
  30. </td>
  31. </tr>
  32. <tr>
  33. <td colspan="2" align="center">
  34. <input type="SUBMIT" value="Add">
  35. <input type="RESET" value="Reset">
  36. </td>
  37. </tr>
  38. </table>
  39. </form>
  40. </body>
  41. </html>
  42.  
  43. //conexiune php
  44. <body>
  45. <?php
  46. mysql_connect("localhost","root","") or die ("Nu se poate
  47. conecta la serverul MySQL");
  48. mysql_select_db("facultate") or die("Nu se poate selecta baza
  49. de date");
  50.  
  51. ?>
  52. </body>
  53. </html>
  54.  
  55. //inserare php
  56. <body>
  57. <?php
  58. include ("conexiune.php");
  59.  
  60. $marca=$_GET['marca_form'];
  61. $nume=$_GET['nume_form'];
  62. $prenume=$_GET['prenume_form'];
  63. $an=$_GET['an_form'];
  64.  
  65. $query=@mysql_query("select count(*) from studenti_ac where Marca=’$marca’");
  66. $row=@mysql_fetch_row($query);
  67. $nr=$row[0];
  68. if ($nr==0){
  69. $query1=@mysql_query("insert into studenti_ac values('$marca','$nume','$prenume',$an)");
  70.  
  71. header("Location: afisare.php");
  72.  
  73. }
  74. else{
  75. echo"<center>";
  76. echo "Studentul respectiv exista deja in baza de date!";
  77. echo"</center>";
  78. }
  79. mysql_close();
  80. ?>
  81.  
  82. </body>
  83. </html>
  84.  
  85. //afisare php
  86. <body>
  87. <?php
  88. include ("conexiune.php");
  89.  
  90. $query2=@mysql_query("select * from studenti_ac ");
  91.  
  92. //calculeaza nr. de inregistrari returnate prin interogare
  93. $nr_inreg=@mysql_num_rows($query2);
  94.  
  95. if ($nr_inreg>0){
  96. echo "<table border='2' align='center'>";
  97. $coln=mysql_num_fields($query2); //nr. de campuri
  98. echo"<tr bgcolor='silver'>";
  99.  
  100. // realizare automata a capului de tabel (continând toate câmpurile)
  101. for ($i=0; $i<$coln; $i++){
  102. //numele câmpurilor ca si cap de tabel
  103. $var=mysql_field_name($query2,$i);
  104. echo "<th> $var </th>";
  105. }
  106. echo"</tr>";
  107.  
  108. // afiseaza inregistrarile gasite in urma interogarii
  109. while($row=mysql_fetch_row($query2)){
  110. echo"<tr>";
  111. foreach ($row as $value){
  112. echo "<td>$value</td>";
  113. }
  114. echo"</tr>";
  115. }
  116. echo"</table>";
  117. }
  118. else{
  119. echo"<center>";
  120. echo "Nu s-a gasit nici o inregistrare!!!";
  121. echo"</center>";
  122. }
  123.  
  124. ?>
  125.  
  126. </body>
  127. </html>
  128.  
  129. //stergere html
  130. <body>
  131. <form method="POST" action="http://localhost/stergere_studenti.php">
  132. <table border="3" align="center" bgcolor="silver">
  133. <tr>
  134. <td>Marca:</td>
  135. <td>
  136. <input type="text" name="marca_form">
  137. </td>
  138. </tr>
  139. <tr>
  140. <td colspan="2" align="center">
  141. <input type="SUBMIT" value="Sterge">
  142. <input type="RESET" value="Anulare">
  143. </td>
  144. </tr>
  145. </table>
  146. </form>
  147. </body>
  148. </html>
  149.  
  150. //steregere studenti php
  151. <body>
  152. <?php
  153.  
  154. include ("conexiune.php");
  155.  
  156. @$marca=$_POST['marca_form'];
  157.  
  158. // cautare dupa câmpul nume a înregistrarilor care vor fi sterse
  159. $query=mysql_query("select * from studenti_ac where Marca='$marca' ");
  160.  
  161. //calculeaza nr. de inregistrari returnate prin interogare
  162. $nr_inreg=mysql_num_rows($query);
  163.  
  164. if ($nr_inreg>0){
  165. echo "<center>";
  166. echo "S-au gasit " . $nr_inreg . " inregistrari";
  167. echo"</center>";
  168.  
  169. // creare tabela de afisare rezultate
  170. echo "<table border='3' align='center'>";
  171. //numarare campuri
  172. $coln=mysql_num_fields($query);
  173. echo"<tr bgcolor='silver'>";
  174. // realizare automata a capului de tabel (continând toate câmpurile)
  175. for ($i=0; $i<$coln; $i++){
  176. //numele câmpurilor ca si cap de tabel
  177. $var=mysql_field_name($query,$i);
  178. echo "<th> $var </th>";
  179. }
  180. echo"</tr>";
  181. // extragere informatii si afisare
  182. while (list ($marca,$nume,$prenume,$an) =mysql_fetch_row($query)){
  183. print ("<tr>" . " <td>$marca</td>" . " <td>$nume</td>" . " <td>$prenume</td>" . " <td>$an</td>" . " </tr>");
  184. }
  185. echo"</table>";
  186.  
  187. // Apelarea scriptului de stergere efectiva/anulare (cu transmitere mai departe
  188. // a parametrilor de intrare, în cazul de fata ‘nume’ dupa care se face cautarea)
  189.  
  190. echo "<form method='POST' action='http://localhost/stergere2.php'>";
  191.  
  192. // ”pasare”, transmitere mai departe a parametrului nume ($nume)
  193. //sub numele ‘ nume1’
  194.  
  195. echo "<input type='hidden' name='marca1_form' value= ".$_POST['marca_form'].">";
  196. echo "<input type='SUBMIT' value='Stergere efectiva'>";
  197. echo "</form>";
  198. // link pt. revenire la pagina de start si anulare stergere
  199. echo "<a HREF='http://localhost/stergere.html'>Renunt si revin...</a>";
  200. }
  201. else
  202. die("Nu gasesc nici o inregistrare ...");
  203. mysql_close();
  204. ?>
  205.  
  206. </body>
  207. </html>
  208.  
  209.  
  210. //stergere 2 php
  211. <body>
  212. <?php
  213. include ("conexiune.php");
  214. @$marca1=$_POST['marca1_form'];
  215. // stergere efectiva
  216. $query =mysql_query("DELETE FROM studenti_ac where Marca='$marca1'");
  217. mysql_close ();
  218. ?>
  219.  
  220. </body>
  221. </html>
  222.  
  223. //cautare html
  224. <body>
  225. <form method="POST" action="http://localhost/Update1_Studenti.php">
  226. <table border="3" align="center" bgcolor="Silver">
  227. <tr>
  228. <td>Nume:</td>
  229. <td><input type="text" name="nume_form"></td>
  230. </tr>
  231. <tr>
  232. <td>Prenume:</td>
  233. <td><input type="text" name="prenume_form"></td>
  234. </tr>
  235. <tr>
  236. <td colspan=”2” align=”center”>
  237. <input type="SUBMIT" value="Cauta">
  238. <input type="RESET" value="Anulare">
  239. </td>
  240. </tr>
  241. </table>
  242. </form>
  243.  
  244. </body>
  245. </html>
  246.  
  247. //update 1 php
  248. <body>
  249. <?php
  250. include ("conexiune.php");
  251. $nume=$_POST['nume_form'];
  252. $prenume=$_POST['prenume_form'];
  253.  
  254. // cautarea înregistrarii care va fi modificata
  255. $query=@mysql_query("select * from studenti_ac where nume='$nume' and prenume=$'prenume'");
  256.  
  257. $nr_inreg=@mysql_num_rows($query);
  258.  
  259. if ($nr_inreg>0){
  260. echo "<center>";
  261. echo "S-au gasit " . $nr_inreg . " inregistrari";
  262. echo"</center>";
  263.  
  264. echo "<table border='2' align='center'>";
  265. echo"<tr bgcolor='silver'>";
  266. $coln=mysql_num_fields($query);
  267.  
  268. for ($i=0; $i<$coln; $i++){
  269. $var=mysql_field_name($query,$i);
  270. echo "<th> $var </th>";
  271. }
  272. echo"</tr>";
  273.  
  274. $nr_val=0; // contor indice array
  275. while ($row = mysql_fetch_row($query)){
  276. echo"<tr>";
  277. foreach ($row as $value) {
  278. echo "<td BGCOLOR='Yellow'> $value</td>";
  279. // memorare într-un sir (array) a datelor din articolul gasit
  280. $sir[$nr_val]=$value;
  281. $nr_val++;
  282. }
  283. echo "</tr>";
  284. }
  285. echo "</table>";
  286.  
  287. // Rezolvarea este valabila pentru o singura înregistrare gasita
  288. // Pentru mai multe înregistrari gasite, modificarile efectuate se aplica asupra tuturor
  289. echo '<br><hr>'; // trasarea unei linii
  290.  
  291. // apel script pentru modificarea efectiva
  292. echo "<form method='POST' action='http://localhost/Update2_Studenti.php'>";
  293.  
  294. // transfer (ascuns) spre script a parametrilor de cautare
  295. echo "<input type='hidden' name='nume2_form' value=".$sir[1].">";
  296. echo "<input type='hidden' name='prenume2_form' value=".$sir[2].">";
  297.  
  298. // transfer spre script ca parametrii a datelor care pot fi modificate
  299. echo "<table>";
  300. echo "<tr>";
  301. echo "<td>";
  302. echo "<input type='text' name='marca1_form' value=".$sir[0].">";
  303. echo "<input type='text' name='nume1_form' value=".$sir[1].">";
  304. echo "<input type='text' name='prenume1_form' value=".$sir[2].">";
  305. echo "<input type='text' name='an1_form' value=".$sir[3].">";
  306. echo "</td>";
  307. echo "</tr>";
  308. echo "<tr>";
  309. echo "<td>";
  310. echo "<input type='SUBMI' value='Modifica!' >";
  311. echo "</td>";
  312. echo "</tr>";
  313. echo "</table>";
  314. echo "</form>";
  315.  
  316. // link de revenire si renuntare la modificare
  317. echo '<a HREF="http://localhost/cautare.html"> Renunt si revin...</a>';
  318. }
  319. else
  320. die ("Nu gasesc nici o inregistrare ...");
  321. mysql_close();
  322. ?>
  323. </body>
  324. </html>
  325.  
  326. //update 2 php
  327. <body>
  328. <?php
  329. include ("conexiune.php");
  330. echo $nume2=$_POST['nume2_form'];
  331. echo $prenume2=$_POST['prenume2_form'];
  332. echo $marca1=$_POST['marca1_form'];
  333. echo $nume1=$_POST['nume1_form'];
  334. echo $prenume1=$_POST['prenume1_form'];
  335. echo $an1=$_POST['an1_form'];
  336. // modificare efectiva
  337. $query =mysql_query("update studenti_ac set marca='$marca1',nume='$nume1', prenume='$prenume1',an_studiu='$an1' where nume='$nume2' and prenume='$prenume2'");
  338.  
  339. // afisare mesaj de eroare pentru date incorect introduse (daca se doreste)
  340. $var=mysql_error();
  341. echo $var;
  342. echo "OK, am modificat!";
  343. mysql_close ();
  344. ?>
  345. </body>
  346. </html>
  347. *****************************************************************************************************************
  348.  
  349. lab4->>>>>>>>>>>>>>>>>>>>>>>>>>> oracle
  350.  
  351. ----meniu
  352. <body>
  353. <a href="http://localhost/lab4/inserare.html">inserare </a>
  354. <hr>
  355. <a href="http://localhost/lab4/stergere.html">stergere </a>
  356. <hr>
  357. <a href="http://localhost/lab4/imprumut.html">imprumut_carte </a>
  358. <hr>
  359. <a href="http://localhost/lab4/afisare.php">afisare_carti</a>
  360.  
  361. </body>
  362. </html>
  363.  
  364.  
  365. ---inserare html
  366. <body>
  367. <form method="POST"
  368. action="http://localhost/lab4/inserare.php">
  369. <table border=”3” align=”center” BGCOLOR="Silver">
  370. <tr>
  371. <td>Cod_ISBN:</td>
  372. <td><input type="text" name="Cod_isbn"></td>
  373. </tr>
  374. <tr>
  375. <td>Titlu_carte:</td>
  376. <td><input type="text" name="Titlu_carte"></td>
  377. </tr>
  378. <tr>
  379. <td>Autor_carte:</td>
  380. <td><input type="text" name="Autor_carte"></td>
  381. </tr>
  382. <tr>
  383. <td>Editura:</td>
  384. <td><input type="text" name="Editura"></td>
  385. </tr>
  386. <tr>
  387. <td>Nr_exemplare:</td>
  388. <td><input type="text" name="Nr_exemplare"></td>
  389. </tr>
  390. <tr>
  391. <td>Anul_aparitiei:</td>
  392. <td><input type="text" name="Anul_aparitiei"></td>
  393. </tr>
  394. <tr>
  395. <td colspan=”2” align=”center”>
  396. <input type="SUBMIT" value="Add">
  397. <input type="RESET" value="Reset">
  398. </td>
  399. </tr>
  400. </table>
  401. </form>
  402. </body>
  403. </html>
  404. ------------inserare php
  405. <body>
  406. <?php
  407. $connection=OCI_connect("student", "student", "xe");
  408.  
  409. $cod_isbn=$_POST['Cod_isbn'];
  410. $titlu_carte=$_POST['Titlu_carte'];
  411. $autor_carte=$_POST['Autor_carte'];
  412. $editura=$_POST['Editura'];
  413. $nr_exemplare=$_POST['Nr_exemplare'];
  414. $anul_aparitiei=$_POST['Anul_aparitiei'];
  415.  
  416. $stmt=OCI_Parse($connection,"SELECT count(*) FROM Evidenta_carti where cod_isbn='$cod_isbn'");
  417. OCI_Execute($stmt);
  418. $row=OCI_Fetch_row($stmt);
  419. $nr=$row[0];
  420. if ($nr==0){
  421.  
  422.  
  423. $stmt1=OCI_Parse($connection, "insert into Evidenta_carti values('$cod_isbn', '$titlu_carte', '$autor_carte', '$editura', $nr_exemplare, $anul_aparitiei) ");
  424. OCI_Execute($stmt1);
  425. @OCI_Free_Statement($stmt1);
  426.  
  427. }
  428. else{
  429. echo "Cartea exista deja!";
  430. }
  431. OCI_Free_Statement($stmt);
  432. OCI_close($connection);
  433. ?>
  434.  
  435. </body>
  436. </html>
  437. ----afisare
  438. <body>
  439. <?php
  440. $connection=OCI_connect("student", "student", "xe");
  441. $stmt=OCI_Parse($connection,"SELECT * FROM Evidenta_carti");
  442. OCI_Execute($stmt);
  443.  
  444. echo "<table border='4' align='center'>";
  445. echo "<tr>";
  446. echo "<th>COD_ISBN</th>";
  447. echo "<th>TITLU_cARTE</th>";
  448. echo "<th>AUTOR_cARTE</th>";
  449. echo "<th>EDITURA</th>";
  450. echo "<th>NR_EXEMPLARE</th>";
  451. echo "<th>ANUL_APARITIEI</th>";
  452. echo "</tr>";
  453. while($row=OCI_Fetch_row($stmt))
  454. {
  455. print("<tr>\n".
  456. "<td>$row[0]</td>\n".
  457. "<td>$row[1]</td>\n".
  458. "<td>$row[2]</td>\n".
  459. "<td>$row[3]</td>\n".
  460. "<td>$row[4]</td>\n".
  461. "<td>$row[5]</td>\n".
  462. "</tr>\n");
  463. }
  464. OCI_Free_Statement($stmt);
  465. OCI_close($connection);
  466. ?>
  467. </body>
  468. </html>
  469.  
  470. ---------------stergere html
  471. <body>
  472. <form method="GET"
  473. action="http://localhost/lab4/stergere.php">
  474. <table border=”3” align=”center” BGCOLOR="Silver">
  475. <tr>
  476. <td>Carte_de_sters:</td>
  477. <td><input type="text" name="Carte_de_sters"></td>
  478. </tr>
  479. <tr>
  480. <td colspan=”2” align=”center”>
  481. <input type="SUBMIT" value="Sterge">
  482. <input type="RESET" value="Reset">
  483. </td>
  484. </tr>
  485. </table>
  486. </form>
  487. </body>
  488. </html>
  489. --------------stergere php
  490. <body>
  491. <?php
  492. $connection=OCI_connect("student", "student", "xe");
  493. $numecarte=$_GET['Carte_de_sters'];
  494. $stmt=OCI_Parse($connection,"SELECT count(*) FROM Evidenta_carti where titlu_carte='$numecarte' ");
  495. @OCI_Execute($stmt);
  496. @$row=OCI_Fetch_row($stmt);
  497. $nr=$row[0];
  498. if ($nr==0){
  499. echo "Cartea nu exista !";
  500. }
  501. else
  502. {
  503. $stmt=OCI_Parse($connection,"DELETE from Evidenta_carti where titlu_carte='$numecarte' ");
  504. OCI_Execute($stmt);
  505. }
  506. OCI_Free_Statement($stmt);
  507. OCI_close($connection);
  508. ?>
  509. </body>
  510. </html>
  511. ----------------update html
  512. <body>
  513. <form method="GET"
  514. action="http://localhost/lab4/imprumut.php">
  515. <table border=”3” align=”center” BGCOLOR="Silver">
  516. <tr>
  517. <td>Carte_de_imprumutat:</td>
  518. <td><input type="text" name="Carte_de_imprumutat"></td>
  519. </tr>
  520. <tr>
  521. <td colspan=”2” align=”center”>
  522. <input type="SUBMIT" value="Imprumuta">
  523. <input type="RESET" value="Reset">
  524. </td>
  525. </tr>
  526. </table>
  527. </form>
  528. </body>
  529. </html>
  530.  
  531. -----------update php
  532. <body>
  533. <?php
  534. $connection=OCI_connect("student", "student", "xe");
  535. $carteimprumutat=$_GET['Carte_de_imprumutat'];
  536. $stmt=OCI_Parse($connection,"SELECT count(*) FROM Evidenta_carti where titlu_carte='$carteimprumutat'");
  537. @OCI_Execute($stmt);
  538. @$row=OCI_Fetch_row($stmt);
  539. $nr=$row[0];
  540. if ($nr==0){
  541. echo "Cartea nu exista !";
  542. }
  543. else
  544. {
  545. $stmt=OCI_Parse($connection,"UPDATE Evidenta_carti SET nr_exemplare=nr_exemplare-1 WHERE titlu_carte='$carteimprumutat' ");
  546. OCI_Execute($stmt);
  547. echo "Nr de exemplare a fost decrementat!";
  548. }
  549. OCI_Free_Statement($stmt);
  550. OCI_close($connection);
  551. ?>
  552. </body>
  553. </html>
  554.  
  555. ___________________________________************************************************************************8888888
  556.  
  557. subiect test
  558.  
  559.  
  560.  
  561.  
  562. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  563. <html>
  564. <head>
  565. <title>Meniu</title>
  566. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  567. </head>
  568.  
  569. <body>
  570. <div class="menubar">
  571. <a href="update.php">Update</a>
  572. <a href="afisare.php">afisare</a>
  573. <a href="stergere.php">stergere</a>
  574. <a href="afisare2.php">afisare2</a>
  575. </div>
  576. </body>
  577. </html>
  578.  
  579.  
  580.  
  581.  
  582. ORACLE---------------
  583.  
  584. afisare
  585.  
  586. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  587. <html>
  588. <head>
  589. <title>afisare2</title>
  590. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  591. </head>
  592.  
  593. <body>
  594. <?php
  595. $connection=OCI_connect("localhost", "root", "root");
  596. $stmt=OCI_Parse($connection,"SELECT * FROM candidati where media_bac='10'");
  597. OCI_Execute($stmt);
  598.  
  599. echo "<table border='4' align='center'>";
  600. echo "<tr>";
  601. echo "<th>id</th>";
  602. echo "<th>nume</th>";
  603. echo "<th>prenume</th>";
  604. echo "<th>adresa</th>";
  605. echo "<th>media_bac</th>";
  606. echo "<th>media_multianuala</th>";
  607. echo "</tr>";
  608. while($row=OCI_Fetch_row($stmt))
  609. {
  610. print("<tr>\n".
  611. "<td>$row[0]</td>\n".
  612. "<td>$row[1]</td>\n".
  613. "<td>$row[2]</td>\n".
  614. "<td>$row[3]</td>\n".
  615. "<td>$row[4]</td>\n".
  616. "<td>$row[5]</td>\n".
  617. "</tr>\n");
  618. }
  619. OCI_Free_Statement($stmt);
  620. OCI_close($connection);
  621. ?>
  622. </body>
  623. </html>
  624.  
  625.  
  626. stergere
  627.  
  628. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  629. <html>
  630. <head>
  631. <title>Untitled Document</title>
  632. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  633. </head>
  634.  
  635. <body>
  636. <body>
  637. <form method="GET"
  638. action="http://localhost/stergere.php">
  639. <table border=”3” align=”center” BGCOLOR="Silver">
  640. <tr>
  641. <td>Student_de_sters:</td>
  642. <td><input type="text" name="Student_de_sters"></td>
  643. </tr>
  644. <tr>
  645. <td colspan=”2” align=”center”>
  646. <input type="SUBMIT" value="Sterge">
  647. <input type="RESET" value="Reset">
  648. </td>
  649. </tr>
  650. </table>
  651. </form>
  652. <?php
  653. $connection=OCI_connect("localhost", "root", "root");
  654. $cnp=$_GET['Student_de_sters'];
  655. $stmt=OCI_Parse($connection,"SELECT count(*) FROM candidati where cnp='$cnp' ");
  656. @OCI_Execute($stmt);
  657. @$row=OCI_Fetch_row($stmt);
  658. $nr=$row[0];
  659. if ($nr==0){
  660. echo "Studentul nu exista !";
  661. }
  662. else
  663. {
  664. $stmt=OCI_Parse($connection,"DELETE from candidati where cnp='$cnp' ");
  665. OCI_Execute($stmt);
  666. }
  667. OCI_Free_Statement($stmt);
  668. OCI_close($connection);
  669. ?>
  670. </body>
  671. </html>
  672. </body>
  673. </html>
  674.  
  675.  
  676.  
  677. SQL------------------
  678.  
  679.  
  680. conexiune
  681.  
  682. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  683. <html>
  684. <head>
  685. <title>conexiune</title>
  686. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  687. </head>
  688.  
  689. <body>
  690. <?php
  691. mysql_connect("localhost", "root", "") or die ("nu se poate conecta la server");
  692. mysql_select_db("admitere") or die("nu se poate conecta la baza de date");
  693. ?>
  694. </body>
  695. </html>
  696.  
  697.  
  698. afisare
  699.  
  700. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  701. <html>
  702. <head>
  703. <title>afisare</title>
  704. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  705. </head>
  706.  
  707. <body>
  708. <?php
  709. include ("conexiune.php");
  710. $queryCandidati = @mysql_query("select * from candidati");
  711.  
  712. $nr_inreg = @mysql_num_rows($queryCandidati);
  713.  
  714. if($nr_inreg>0){
  715. echo "<table border='2' align 'center'>";
  716. $coln=mysql_num_fields($queryCandidati);
  717. echo "<tr bgcolor='silver'>";
  718.  
  719. for($i=0; $i<$coln; $i++)
  720. {
  721. //numele campurilor ca si cap de tabel
  722. $var=mysql_field_name($queryCandidati, $i);
  723. echo"<th> $var</th>";
  724. }
  725. echo "</tr>";
  726.  
  727. //afisare inregistrari gasite in urma interogarii
  728. while($row = mysql_fetch_row($queryCandidati)){
  729. echo"<tr>";
  730. foreach ($row as $value){
  731. echo"<td>$value</td>";
  732. }
  733. echo "</tr>";
  734. }
  735. echo"</table>";
  736. }
  737. else{
  738. echo"<center>";
  739. echo "Nu s au gasit inregistrari";
  740. echo"</center>";
  741. }
  742. ?>
  743.  
  744.  
  745. </body>
  746. </html>
  747.  
  748.  
  749.  
  750. update1
  751.  
  752. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  753. <html>
  754. <head>
  755. <title>Update</title>
  756. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  757. </head>
  758.  
  759. <body>
  760. <?php
  761. include ("conexiune.php");
  762. $id=$_POST['id'];
  763.  
  764. // cautarea înregistrarii care va fi modificata
  765. $query=@mysql_query("select * from candidati where id='$id' ");
  766.  
  767. $nr_inreg=@mysql_num_rows($query);
  768.  
  769. if ($nr_inreg>0){
  770. echo "<center>";
  771. echo "S-au gasit " . $nr_inreg . " inregistrari";
  772. echo"</center>";
  773.  
  774. echo "<table border='2' align='center'>";
  775. echo"<tr bgcolor='silver'>";
  776. $coln=mysql_num_fields($query);
  777.  
  778. for ($i=0; $i<$coln; $i++){
  779. $var=mysql_field_name($query,$i);
  780. echo "<th> $var </th>";
  781. }
  782. echo"</tr>";
  783.  
  784. $nr_val=0; // contor indice array
  785. while ($row = mysql_fetch_row($query)){
  786. echo"<tr>";
  787. foreach ($row as $value) {
  788. echo "<td BGCOLOR='Yellow'> $value</td>";
  789. // memorare într-un sir (array) a datelor din articolul gasit
  790. $sir[$nr_val]=$value;
  791. $nr_val++;
  792. }
  793. echo "</tr>";
  794. }
  795. echo "</table>";
  796.  
  797. // Rezolvarea este valabila pentru o singura înregistrare gasita
  798. // Pentru mai multe înregistrari gasite, modificarile efectuate se aplica asupra tuturor
  799. echo '<br><hr>'; // trasarea unei linii
  800.  
  801. // apel script pentru modificarea efectiva
  802. echo "<form method='POST' action='http://localhost/update2.php'>";
  803.  
  804. // transfer (ascuns) spre script a parametrilor de cautare
  805. echo "<input type='hidden' id='id2_form' value=".$sir[1].">";
  806.  
  807. // transfer spre script ca parametrii a datelor care pot fi modificate
  808. echo "<table>";
  809. echo "<tr>";
  810. echo "<td>";
  811. echo "<input type='text' name='media_bac1' value=".$sir[0].">";
  812. echo "<input type='text' name='media_multianuala1' value=".$sir[1].">";
  813.  
  814. echo "</td>";
  815. echo "</tr>";
  816. echo "<tr>";
  817. echo "<td>";
  818. echo "<input type='SUBMI' value='Modifica!' >";
  819. echo "</td>";
  820. echo "</tr>";
  821. echo "</table>";
  822. echo "</form>";
  823.  
  824. else
  825. die ("Nu gasesc nici o inregistrare ...");
  826. mysql_close();
  827. ?>
  828. </body>
  829. </html>
  830.  
  831.  
  832. update2
  833.  
  834. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  835. <html>
  836. <head>
  837. <title>Untitled Document</title>
  838. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  839. </head>
  840.  
  841. <body>
  842. <?php
  843. include ("conexiune.php");
  844. echo $id2=$_POST['id2'];
  845. echo $media_bac1=$_POST['media_bac1'];
  846. echo $media_multianuala1=$_POST['media_multianuala1'];
  847.  
  848. // modificare efectiva
  849. $query =mysql_query("update candidati set id='$id1',media_bac='$media_bac1', media_multianuala='$media_multianuala1' where id='$id2'");
  850.  
  851. // afisare mesaj de eroare pentru date incorect introduse (daca se doreste)
  852. $var=mysql_error();
  853. echo $var;
  854. echo "OK, am modificat!";
  855. mysql_close ();
  856. ?>
  857. </body>
  858. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement