Jump to content

Php | Sorgulama Hakkında Yardıma Ihtiyacım Var


Recommended Posts

Merhaba arkadaşlar.
- Aşağıdaki gibi bir formdan veri alıyorum.
Gelen veri veritabanındaki veri ile eşleşirse yeşil renkte veriyi göstermesini, eğer veri eşleşmezse de yeşil renkte veritabanındaki veriyi yanında da kırmızı renkte formdan gelen veriyi göstermek istiyorum. Yani doğru ve yanlış mantığı. Bunun sorgulaması nasıl olabilir. Ben if ile denedim ama istediğim sonuca ulaşamadım maalesef.

- İki soru olsun ve sorulardan biri işaretlenmemiş olsun. İşaretlenmemiş soru aşağıdaki döngüde gösterilsin ama yanında Boş yazsın istiyorum

Arkadaşlar henüz PDO bilmiyorum normal mysql kodlarını biliyorum. Ona göre cevap verirseniz sevinirim.

sonuc.php

<?php
	$sec = @mysql_query("SELECT * FROM sorular");
	$yaz = @mysql_fetch_array($sec);
	// Veritabanındaki doğru cevap sütununun adı dogru_cevap
?>
<div class="Sonuclar">
	<?php
		if( $_POST ){

			foreach( $_POST as $anahtar => $deger ){
				$sorular = explode('-', $anahtar);
				$soruNo = $sorular[1];
				//echo"<ul><li><b>$soruNo.</b> Soruya verilen cevap : <b>$deger</b></li></ul>";

	            if($yaz["soru_no"] == $soruNo && $yaz["dogru_cevap"] == $deger){
					echo'<ul><li><b>'.$yaz["soru_no"].'.</b> Soruya verilen cevap : <b>'.$yaz["dogru_cevap"].'</b></li></ul>';
				}else{
					echo'<ul><li><b>'.$yaz["soru_no"].'.</b> Sorunun doğru cevabı : <b>'.$yaz["dogru_cevap"].'</b></li></ul><br>';
				    echo'<ul><li><b>'.$soruNo.'.</b> Üyenin verdiği cevap : <b>'.$deger.'</b></li></ul>';
				}

			}

		}
	?>
</div>

sorular.php
 

<form id="SoruFormu" action="index.php?git=sonuc" method="post">
<div class="Sorular">
  <ul class="SoruIcerik">
	<li class="Soru"><h3><?php echo $yaz["soru_no"].') '.$yaz["soru_metin"]; ?></h3></li>

	<li class="SecenekMetin">
		<div class="SecenekIsaret">
			<input type="checkbox" name="cevap-<?php echo $yaz["soru_no"]; ?>" id="<?php echo $yaz["soru_no"]."-"; ?>secenek-a" value="A">
			<label for="<?php echo $yaz["soru_no"]."-"; ?>secenek-a">A) <?php echo $yaz["soru_secenek_a"]; ?></label>
		</div>
	</li>
	
	<li class="SecenekMetin">
		<div class="SecenekIsaret">
			<input type="checkbox" name="cevap-<?php echo $yaz["soru_no"]; ?>" id="<?php echo $yaz["soru_no"]."-"; ?>secenek-b" value="B">
			<label for="<?php echo $yaz["soru_no"]."-"; ?>secenek-b">B) <?php echo $yaz["soru_secenek_b"]; ?></label>
		</div>
	</li>
	
	<li class="SecenekMetin">
		<div class="SecenekIsaret">
			<input type="checkbox" name="cevap-<?php echo $yaz["soru_no"]; ?>" id="<?php echo $yaz["soru_no"]."-"; ?>secenek-c" value="C">
			<label for="<?php echo $yaz["soru_no"]."-"; ?>secenek-c">C) <?php echo $yaz["soru_secenek_c"]; ?></label>
		</div>
	</li>

	<li class="SecenekMetin">
		<div class="SecenekIsaret">
			<input type="checkbox" name="cevap-<?php echo $yaz["soru_no"]; ?>" id="<?php echo $yaz["soru_no"]."-"; ?>secenek-d" value="D">
			<label for="<?php echo $yaz["soru_no"]."-"; ?>secenek-d">D) <?php echo $yaz["soru_secenek_d"]; ?></label>
		</div>
	</li>
	
	<li class="SecenekMetin">
		<div class="SecenekIsaret">
			<input type="checkbox" name="cevap-<?php echo $yaz["soru_no"]; ?>" id="<?php echo $yaz["soru_no"]."-"; ?>secenek-e" value="E">
			<label for="<?php echo $yaz["soru_no"]."-"; ?>secenek-e">E) <?php echo $yaz["soru_secenek_e"]; ?></label>
		</div>
	</li>
  </ul>
</div>
<div class="TestBitir"><input class="TestBitirButon" type="submit" value="Testi Bitir" /></div>
</form>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Similar Content

    • By artae
      Blumentals Rapid PHP 2022 v17.2.0.242 Multilingual | 116.7 Mb

      Rapid PHP editor is a faster and more powerful PHP code editor for Windows combining features of a fully-packed PHP IDE with the speed of the Notepad.

      Rapid PHP is the most complete all-in-one software for coding PHP, HTML, CSS, javascript and other web development languages with tools for debugging, validating, reusing, navigating and formatting your code.
      The fastest PHP editor / IDE
      Loads much faster than any other PHP editor or PHP IDE with similar features
      Powerful syntax highlighting
      Supports HTML, CSS, javascript, PHP, Smarty, XML, SQL, Apache and more
      Code intelligence
      Tons of intelligent code completion, navigation and suggestion features for PHP, HTML, CSS, javascript, Smarty
      Powerful editor
      Unicode support, bracket-matching, code folding, auto-complete, auto-replace, multi-highlight and more
      HTML5 and CSS3 ready
      Coding features are up-to-date with modern standards
      Powerful CSS features
      Inspector, compatibility watch, prefixizer, code assistants, browser preview and much more
      Advanced search and replace
      Goto anything, quick search, detailed search, file search, regular expressions, detailed results and more
      Smarty & framework support
      Powerful support for Smarty PHP template ee and popular PHP frameworks
      Debugger & validators
      xDebug PHP debugger, real PHP checker, spelling checker, W3 HTML and CSS validator, JSLint javascript checker
      Direct FTP/SFTP/FTPS
      Edit directly on your web server or publish local development copy updates with a single click
      Efficient code re-use
      Code snippet library and code templates with assignable shortcuts
      Loads of tools
      Code beautifier, dynamic ToDo, color picker, XRay etc.
      Windows 7, 8, 10, 11
      -
      DOWNLOAD
      (Buy premium account for maximum speed and resuming ability)


      https://nitroflare.com/view/E09DDFFDA3F427E/5qyio.Blumentals.Rapid.PHP.2022.v17.2.0.242.Multilingual.rar



      https://rapidgator.net/file/256f2a2509d9805b93e30092b928665b/5qyio.Blumentals.Rapid.PHP.2022.v17.2.0.242.Multilingual.rar


    • By artae
      Blumentals Rapid PHP 2022 v17.0.0.240. Multilingual | 112.3 Mb
      Rapid PHP editor is a faster and more powerful PHP code editor for Windows combining features of a fully-packed PHP IDE with the speed of the Notepad. Rapid PHP is the most complete all-in-one software for coding PHP, HTML, CSS, javascript and other web development languages with tools for debugging, validating, reusing, navigating and formatting your code.

      The fastest PHP editor / IDE
      Loads much faster than any other PHP editor or PHP IDE with similar features
      Powerful syntax highlighting
      Supports HTML, CSS, javascript, PHP, Smarty, XML, SQL, Apache and more
      Code intelligence
      Tons of intelligent code completion, navigation and suggestion features for PHP, HTML, CSS, javascript, Smarty
      Powerful editor
      Unicode support, bracket-matching, code folding, auto-complete, auto-replace, multi-highlight and more
      HTML5 and CSS3 ready
      Coding features are up-to-date with modern standards
      Powerful CSS features
      Inspector, compatibility watch, prefixizer, code assistants, browser preview and much more
      Advanced search and replace
      Goto anything, quick search, detailed search, file search, regular expressions, detailed results and more
      Smarty & framework support
      Powerful support for Smarty PHP template engine and popular PHP frameworks
      Debugger & validators
      xDebug PHP debugger, realtime PHP checker, spelling checker, W3 HTML and CSS validator, JSLint javascript checker
      Direct FTP/SFTP/FTPS
      Edit directly on your web server or publish local development copy updates with a single click
      Efficient code re-use
      Code snippet library and code templates with assignable shortcuts
      Loads of tools
      Code beautifier, dynamic ToDo, color picker, XRay etc.
      Operating System:Windows 7, 8, 10
      Home Page -https://www.rapidphpeditor.com/
      DOWNLOAD
      (Buy premium account for maximum speed and resuming ability)


      https://nitroflare.com/view/B8818BDF4105D08/kz6qv.Blumentals.Rapid.PHP.2022.v17.0.0.240.Multilingual.rar



      https://rapidgator.net/file/3d9484b81940155cfd8646bc0f8a1a08/kz6qv.Blumentals.Rapid.PHP.2022.v17.0.0.240.Multilingual.rar


    • By prototype
      Merhaba arkadaşlar index.php sayfasında Session oluşturup, sayfa2.php'de listelettiriyorum. Ama ben session'ı oluşturduktan sonra otomatik olarak sayfa2.php'ye yönlendirme yapmasını istiyorum, nasıl yapabileceğim konusunda bana yardımcı olabilirseniz çok sevinirim. Teşekkürler.

      index.php
      <?php session_start(); ?> <!doctype html> <html> <head> <title>Session Oluştur</title> </head> <body> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Ürün Adı :<input type="text" name="urunadi"> Alış Fiyati :<input type="text" name="alisfiyati"> Müşteri Adı :<input type="text" name="musteriadi"> <input type="submit" name="submit" value="Submit"> </form> <br> <a href="sayfa2.php">2.Sayfaya Git </a><br> <a href="sayfa3.php">3.Sayfaya Git </a> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $_SESSION['uadi']=$_POST['urunadi']; $_SESSION['afiyati']=$_POST['alisfiyati']; $_SESSION['madi']=$_POST['musteriadi']; } ?> </body> </html>
      sayfa2.php
       
      <?php session_start(); ?> <!doctype html> <html> <head> <title>Session Listeleme</title> </head> <body> <?php if(isset($_SESSION["uadi"])&&isset($_SESSION["afiyati"])&&isset($_SESSION["madi"])) { ?> Ürün Adı : <?php echo $_SESSION['uadi']; ?><br> Alış Fiyatı : <?php echo $_SESSION['afiyati']; ?><br> Müşteri Adı : <?php echo $_SESSION['madi']; }?><br> <a href="index.php">1.Sayfaya Git </a> </body> </html>  
    • By Abdullah 37
      Merhaba arkadaşlar.
      Veritabanından timestamp (CURRENT_TIMESTAMP) yapılı bir kolondan gelen tarih verisini tarih ve saat şeklinde yazdırmak amacıyla explode ile parçaladım. Ama her yerde kullanabilmem için bir fonksiyon yazdım.
      Ancak fonksiyonu çalıştırma kısmını tam halledemedim eksikler var ama ne olduğunu bulamadım. Tarih ve Saat verisini ayrı ayrı nasıl yazdırabilirim?
      Nasıl bir ekleme yapmalıyız? Yardımcı olur musunuz?
      <?php function TarihSaat($par){ $zaman = $par; $zamanBol = explode(" ",$zaman); $tarih = $zamanBol[0]; $saat2 = $zamanBol[1]; $saat= substr($saat2, 0,5); echo $tarih; echo $saat; } //kayit_tarih sütunundaki tarih: 2017-08-26 01:30:37 $k_tarih = $kayit_tarih["tarih"]; TarihSaat($k_tarih); ?>  
    • By Abdullah 37
      Merhaba arkadaşlar.
      Php ile mysql işlemleri yaparken güvenlik kısmında tam olarak ne yapılması gerektiğini bilmiyorum. Bu konuda yardımlarınıza ihtiyacım var.
      - Üye kayıt ve giriş kısmını kodlarken gelen verileri hangi güvenlik fonksiyonlarından geçirmeliyim?
      - Konu ekleme ve düzenleme, yorum ekleme ve düzenleme kısımlarını hangi güvenlik fonksiyonlarından geçirmeliyim?
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...