Vur Posted August 25, 2008 Share Posted August 25, 2008 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 https://forums.phpfreaks.com/topic/121247-details-problem/ Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 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"? Link to comment https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625070 Share on other sites More sharing options...
Minase Posted August 25, 2008 Share Posted August 25, 2008 this isnt going to work lol =)) $ara = mysql_query("select * from Kitap where id=i$id") OR die(mysql_error()); maybe $ara = mysql_query("select * from Kitap where id=$id") OR die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625076 Share on other sites More sharing options...
Vur Posted August 25, 2008 Author Share Posted August 25, 2008 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 https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625087 Share on other sites More sharing options...
Minase Posted August 25, 2008 Share Posted August 25, 2008 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()); Link to comment https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625089 Share on other sites More sharing options...
Vur Posted August 25, 2008 Author Share Posted August 25, 2008 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 https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625108 Share on other sites More sharing options...
Minase Posted August 25, 2008 Share Posted August 25, 2008 ah i think i know what you mean $ara = mysql_query("select * from Kitap where id=$_GET['ID']") OR die(mysql_error()); try that Link to comment https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625118 Share on other sites More sharing options...
Vur Posted August 25, 2008 Author Share Posted August 25, 2008 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 https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625353 Share on other sites More sharing options...
Ken2k7 Posted August 25, 2008 Share Posted August 25, 2008 Try this: $ara = mysql_query("select * from Kitap where id='%d'") OR die(mysql_error()); $ara = sprintf($ara, $_GET['id']); There is another way to do that, but I prefer this way. You just need to have the quote there. Link to comment https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625361 Share on other sites More sharing options...
Vur Posted August 25, 2008 Author Share Posted August 25, 2008 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 https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625407 Share on other sites More sharing options...
Ken2k7 Posted August 25, 2008 Share Posted August 25, 2008 From the code, I don't see the declaration or initiation of the variable $ara_row. Can you post the entire code? Link to comment https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625410 Share on other sites More sharing options...
revraz Posted August 25, 2008 Share Posted August 25, 2008 we would have to see the sql before that along with the rest of the code on that page. Link to comment https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625411 Share on other sites More sharing options...
Vur Posted August 25, 2008 Author Share Posted August 25, 2008 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 https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625438 Share on other sites More sharing options...
Ken2k7 Posted August 25, 2008 Share Posted August 25, 2008 Please at least or [php] your code. Link to comment https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625440 Share on other sites More sharing options...
Vur Posted August 26, 2008 Author Share Posted August 26, 2008 any idea? Link to comment https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-625848 Share on other sites More sharing options...
Vur Posted August 26, 2008 Author Share Posted August 26, 2008 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 https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-626130 Share on other sites More sharing options...
Vur Posted August 26, 2008 Author Share Posted August 26, 2008 pls? ??? :'( Link to comment https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-626284 Share on other sites More sharing options...
Ken2k7 Posted August 26, 2008 Share Posted August 26, 2008 echo "<a href='/detay.php?id={$ara_row[12]}'>Detaylar</a>"; echo "<a href='index.php?k=$q'>Geri</a>"; echo "<a href='index.php?k=$z'>İleri</a>"; Link to comment https://forums.phpfreaks.com/topic/121247-details-problem/#findComment-626301 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.