Jump to content

Recommended Posts

Hi friends, i want to ask a question. i have two page: "slider.php" and "mansethaberler.php"  i extract two data from the database, named "addnews_headline" and "addnews_image" in slider.php. i create link to extracted "headline" from the database. See i added first image. when i clicked the link, link is heading to the second page "mansethaberler.php"  and in "mansethaberler.php" with "SELECT" i extract from database "headline" and "image". Now i want to do that. When i clicked the link in "slider.php"  i want to listing the image and headline in "mansethaberler.php".

"mansethaberler.php"

<?php
	$veri = $db->query("SELECT * FROM haberlerekle ORDER BY haberekle_id",PDO::FETCH_ASSOC)->fetchAll();
	?>
	
	<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
	
	<?php foreach ($veri as $haber) { ?>
	
	<div style="border:1px solid black; height:50px; background-color:#17a2b8; color:white; line-height:50px; text-align:center;"><?php echo $haber["habereklesayfasi_baslik"]; ?></div>
	<div class="row no-gutters">
	<img class="col-lg-12 mt-2" src="upload/images/<?php echo $haber["haberekle_resim"]; ?>" style="max-height:444px;">
	
	</div>
	</div>
	
	<div class="col-lg-12 ml-auto mt-1 mb-1" style="padding-left:7px;"><?php echo $haber["haberekle_konu"]; } ?></div>

"slider.php"

<img src="upload/images/<?php echo $row["haberekle_resim"]; ?>" width="832" height="502"> <!-- upload/images/ ile <?php ?> tag'leri arasında boşluk olursa link kırılıyor. Resim çıkmıyor.  -->
      <div class="carousel-caption">
      <p><a href="mansethaberler.php"><?php echo $row['haberekle_baslik']; ?></a></p>
      </div> 

tM8chL.jpg

yIAgPb.jpg

 

Edited by CodingStudent
i forgot to put the most important codes
Link to comment
https://forums.phpfreaks.com/topic/311349-how-can-i-listing-by-link/
Share on other sites

11 minutes ago, CodingStudent said:

When i clicked the link in "slider.php"  i want to listing the image and headline in "mansethaberler.php".

What problem are you having trying to do that? Isn't that the same thing that slider.php is already doing? Just copy that.

Sorry, i forgot to writing that. i can extract "image" and "headline" to the database, but it extract all "images" and "headlines". I did that.

"SELECT * FROM haberlerekle ORDER BY haberekle_id LIMIT 1"

this time, it is getting one data, but i saved data first. it doesn't i clicked.

"slider.php" all page

<?php
	$veriler = $db->query("SELECT * FROM haberlerekle ORDER BY haberekle_id DESC LIMIT 12",PDO::FETCH_ASSOC)->fetchAll();
	?>
	
	<div id="demo" class="carousel slide" data-ride="carousel">
	<ul class="carousel-indicators">
    <?php
	$i = 0;
	foreach ($veriler as $row) {
		$actives = '';
		if($i == 0) {
			$actives = 'active';
		}
	?>
	<li data-target="#demo" data-slide-to="<?php echo $i; ?>" class="<?php echo $actives; ?>"></li>
	<?php $i++; } ?>
	</ul>
	<div class="carousel-inner">
  
      <?php
		$i = 0;
		foreach ($veriler as $row) {
		$actives = '';
			if($i == 0) {
			$actives = 'active';
			}
	  ?>
  
	  <div class="carousel-item <?php echo $actives; ?>">
      <img src="upload/images/<?php echo $row["haberekle_resim"]; ?>" width="832" height="502"> <!-- upload/images/ ile <?php ?> tag'leri arasında boşluk olursa link kırılıyor. Resim çıkmıyor.  -->
      <div class="carousel-caption">
      <p><a href="mansethaberler.php"><?php echo $row['haberekle_baslik']; ?></a></p>
      </div> 
	  </div>
    
	  <?php $i++; } ?>
    
	  </div>
	  <a class="carousel-control-prev" href="#demo" data-slide="prev">
	  <span class="carousel-control-prev-icon"></span>
	  </a>
	  <a class="carousel-control-next" href="#demo" data-slide="next">
	  <span class="carousel-control-next-icon"></span>
	  </a>
	  </div>

"mansethaberler.php" all page

<?php include "header.php"; ?>
<?php $db = new PDO("mysql:host=localhost; dbname=boz_der; charset=utf8", "user", "ltmD38wbx"); ?>
	<div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 telefon-margin-top-slide">
	<?php include "solmenu.php"; ?>
	</div>
	
	<?php
	$veri = $db->query("SELECT * FROM haberlerekle ORDER BY haberekle_id",PDO::FETCH_ASSOC)->fetchAll();
	?>
	
	<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
	
	<?php foreach ($veri as $haber) { ?>
	
	<div style="border:1px solid black; height:50px; background-color:#17a2b8; color:white; line-height:50px; text-align:center;"><?php echo $haber["habereklesayfasi_baslik"]; ?></div>
	<div class="row no-gutters">
	<img class="col-lg-12 mt-2" src="upload/images/<?php echo $haber["haberekle_resim"]; ?>" style="max-height:444px;">
	
	</div>
	</div>
	
	<div class="col-lg-12 ml-auto mt-1 mb-1" style="padding-left:7px;"><?php echo $haber["haberekle_konu"]; } ?></div>
	<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 mt-2 mb-1">
	<?php include "footer.php"; ?>
	</div>

Before i post from admin.php, first image

8EZOjM.jpg

and i extract from database in "slider.php", second image

qWgCJ7.jpg

and i want to getting page "mansethaberler.php", third page

IxrrbQ.jpg

 

I don't yet understand what you want mansethaberler.php to do. You need to describe what the page is supposed show. I know that slider.php has a link and that you are clicking the link to go to mansethaberler.php, but I don't know what you want that page to do.

eventually, i did it.

mansethaberler.php


	<?php include "header.php"; ?>
	<?php $db = new PDO("mysql:host=localhost; dbname=boz_der; charset=utf8", "user", "ltmD38wbx"); ?>
	<div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 telefon-margin-top-slide">
	<?php include "solmenu.php"; ?>
	</div>
	
	<?php if($_GET) { 
	$verial = $_GET["git"];
	?>
	
	<?php
	$veri = $db->query("SELECT * FROM haberlerekle WHERE haberekle_id='$verial'");
	?>

	<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">

	<?php foreach ($veri as $haber) { ?>

	<div style="border:1px solid black; height:50px; background-color:#17a2b8; color:white; line-height:50px; text-align:center;"><?php echo $haber["habereklesayfasi_baslik"]; ?></div>
	<div class="row no-gutters">
	<img class="col-lg-12 mt-2" src="upload/images/<?php echo $haber["haberekle_resim"]; ?>" style="max-height:444px;">

	</div>
	</div>

	<div class="col-lg-12 ml-auto mt-1 mb-1" style="padding-left:7px;"><?php echo $haber["haberekle_konu"]; } ?></div>
	
	<?php } ?>

slider.php

<?php
	$veriler = $db->query("SELECT * FROM haberlerekle ORDER BY haberekle_id DESC LIMIT 12",PDO::FETCH_ASSOC)->fetchAll();
	?>
	
	<div id="demo" class="carousel slide" data-ride="carousel">
	<ul class="carousel-indicators">
    <?php
	$i = 0;
	foreach ($veriler as $row) {
		$actives = '';
		if($i == 0) {
			$actives = 'active';
		}
	?>
	<li data-target="#demo" data-slide-to="<?php echo $i; ?>" class="<?php echo $actives; ?>"></li>
	<?php $i++; } ?>
	</ul>
	<div class="carousel-inner">
  
      <?php
		$i = 0;
		foreach ($veriler as $row) {
		$actives = '';
			if($i == 0) {
			$actives = 'active';
			}
	  ?>
	
	  <?php $idcek = $row["haberekle_id"]; ?>
	  
	  <div class="carousel-item <?php echo $actives; ?>">
      <img src="upload/images/<?php echo $row["haberekle_resim"]; ?>" width="832" height="502"> <!-- upload/images/ ile <?php ?> tag'leri arasında boşluk olursa link kırılıyor. Resim çıkmıyor.  -->
      <div class="carousel-caption">
      <p><a href="mansethaberler.php?git=<?php echo $idcek; ?>"><?php echo $row['haberekle_baslik']; ?></a></p>
      </div> 
	  </div>
    
	  <?php $i++; } ?>
    
	  </div>
	  <a class="carousel-control-prev" href="#demo" data-slide="prev">
	  <span class="carousel-control-prev-icon"></span>
	  </a>
	  <a class="carousel-control-next" href="#demo" data-slide="next">
	  <span class="carousel-control-next-icon"></span>
	  </a>
	  </div>

i added that codes in mansethaberler.php

<?php if($_GET) { 
	$verial = $_GET["git"];
	?>

and if this part

<?php
	$veri = $db->query("SELECT * FROM haberlerekle WHERE haberekle_id='$verial'");
	?>

='$verial'

i added that codes in slider.php

<?php $idcek = $row["haberekle_id"]; ?>

and if this part

<p><a href="mansethaberler.php?git=<?php echo $idcek; ?>"><?php echo $row['haberekle_baslik']; ?></a></p>

<a href="mansethaberler.php?git=<?php echo $idcek; ?>">

and anymore if i click which link, it is showing the other page.

Thank you everything.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.