Jump to content

Details Problem


Vur

Recommended Posts

I am very new to php and learning how to use php and mysql recently. I am trying to constract a simple booksite which shows books which are published by my company. I desing it (or I tried to desing it) to show list of books at index (index.php) page and to show the details of selected book at another page (detay.php)

 

At the end of index page I used:

<td><div align='right'><a href='../detay.php?id=$ara_row[12]'>Detaylar</a></div><br><br><br></td>

 

because row 12 is the auto_increment, primary, id column (which is also named as id) and when I click on details it passas to another page which is addressed as ...detay.php?id?=1.

 

On details (detay) page I used

 

$ara = mysql_query("select * from Kitap where $id=id");

$ara_sayi = mysql_num_rows($ara);

if ($ara_sayi == 0)

  {

    echo '<br><br><br><br><br><br>';

    echo "<center><b>Aradığınız kriterlere uyan bir sonuç bulunamadı.</b></center>";

  }

 

to show the book if page id = id , but else show "there is no such thing"

but it allways shows "Aradığınız kriterlere uyan bir sonuç bulunamadı" which means "tehere is no such thing"

I couldn't find where is the problem, it seems "all right" to me,

 

I will be very glad if anybody gives me a small solution. Thank you

 

help?help? :'(

Link to comment
Share on other sites

You mixed up the column and variable in the query. =P

 

$ara = mysql_query("select * from Kitap where id=i$id") OR die(mysql_error());

 

Try that.

 

You had:

$ara = mysql_query("select * from Kitap where $id=id");  See how you have "$id = id"?

 

Dear friend,

 

I changed one of the variables to not to mix again like

 

<td><div align='right'><a href='../detay.php?kimlik=$ara_row[12]'>Detaylar[/url]</div>

 

and I made parameters as

 

$ara = mysql_query("select * from Kitap where $kimlik=id"); didnt work

$ara = mysql_query("select * from Kitap where id=$kimlik"); crashed

$ara = mysql_query("select * from Kitap where $id=kimlik"); didnt work

$ara = mysql_query("select * from Kitap where kimlik=$id"); crashed

 

:'( :'( :'(

Link to comment
Share on other sites

try this it should work,but first be sure that variable $id has content.

$ara = mysql_query("select * from Kitap where id=$id") OR die(mysql_error());

 

Sorry my friend it didn't work even with this way. id colum has a number content with auto_increment. it is olsa primary column

 

I made mistake somewhere but where?

Link to comment
Share on other sites

ah i think i know what you mean ^_^

$ara = mysql_query("select * from Kitap where id=$_GET['ID']") OR die(mysql_error());

 

try that

 

Nope, sorry, didn't work

Really thank you

but I think problem is somwhere else

 

Link to comment
Share on other sites

I have tried many things since morning and I think problem is at first code. Somehow,

 

<td><div align='right'><a href='../detay.php?id=$ara_row[12]'>Detaylar[/url]</div>

 

code is not sending to next page data of $id

 

so $id stays blank (or empty) so it never gets equal with id column

 

any idea?

Link to comment
Share on other sites

ok thanks guys.

so this is index page

 

<?php
					if ($k<>0)
						{
						}
						else
						{
						$k=0;
						}
					$ara = mysql_query("select * from Kitap where bolum=1 order by adi limit $k,6");
					$ara_sayi = mysql_num_rows($ara);//kaç satır kayıt var onu öğrenirsin, yazdırmak için gerek yok sadece bilgi
					if ($ara_sayi == 0)
						{
						echo '<br><br><br><br><br><br>';
						echo "<center><b>Aradığınız kriterlere uyan bir sonuç bulunamadı.</b></center>";
						} 
					while($ara_row = mysql_fetch_row($ara)){ 
						echo "<table width='498' border='0' cellspacing='0' cellpadding='0'>
  <tr>
    <td colspan='2' height='20' bgcolor='#F9F3DF'><b> $ara_row[0]</b></td>
  </tr>
  <tr>
    <td width='21%' height='120'><div align='center'><img height=107 
                  src='../images/kitap/$ara_row[7].jpg' 
                width=74></div></td>
    <td width='79%'><table width='96%' border='0' align='center' cellpadding='0' cellspacing='0'>
      
      <tr>
        <td><p align=justify>$ara_row[4]</p></td>
      </tr>
      <tr>
        <td><div align='right'><a href='/detay.php?id=$ara_row[12]'>Detaylar</a></div><br><br><br></td>
      </tr>
  
  <tr><br></tr>
    </table></td>
  </tr>
  <tr>
    <td height='20'> </td>
    <td height='20'> </td>
  </tr>
</table>";	
				}


	?>

 

 

 

and this is details page

 

 

 

<?php 		
						 $ara = mysql_query("select * from Kitap $id=id");
					$ara_sayi = mysql_num_rows($ara);
					if ($ara_sayi == 0)
						{
						echo '<br><br><br><br><br><br>';
						echo "<center><b>Aradığınız kriterlere uyan bir sonuç bulunamadı.</b></center>";
						} 

					while($ara_row = mysql_fetch_row($ara)){ 
									if ($ara_row[4]==0)
										{
											$ara_row[4]='-  ';
										}

									........
?>

Link to comment
Share on other sites

I found a new problem which is connected directly with first one. I tried to do so paging wich is limited with 6 books. somehow it doesnt go to next page. When I click on "next" it shows same page with same books not with next ones..

 

<?
						//echo $k;
						$sayfa = $k/6;
						$sayfa = $sayfa+1;
						$sayfa_sayisi = mysql_query("select * from Kitap where bolum=1");
						$sayfa_sayisi2 = mysql_num_rows($sayfa_sayisi);
						$toplam_sayfa = intval($sayfa_sayisi2/6);
						$toplam_sayfa = $toplam_sayfa + 1;
						echo "Sayfa ";
						echo $sayfa;
						echo " / ";
						echo $toplam_sayfa;
						?>
                                    |</div></td>
                            <td width="40%" height="20" valign="bottom">
						<? 
							$ileri = mysql_query("select * from Kitap where bolum=1");
							$ileri_sayi = mysql_num_rows($ileri);
							if ($ileri_sayi>6)
								{
									$z = $k + 6;
									if ($z > $ileri_sayi)
									{
									}
									else
									{
										echo "<a href='index.php?k=$z'>İleri</a>";
									}
								} 

						?>

 

 

I think both problem is related with this code

 

<a href='/detay.php?id=$ara_row[12]'>Detaylar
echo "<a href='index.php?k=$q'>Geri</a>"
echo "<a href='index.php?k=$z'>İleri</a>"

 

I th'nk they are not sending data to next page..... how can I sove it? Any idea?

 

Link to comment
Share on other sites

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.