connect.php HTML: <?php { $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("derslerioku", $con); $result = mysql_query("SELECT * FROM dersler where id='".$_GET['id']."'"); echo $result['id']; mysql_close($con); } ?> Code (markup): The codes located in above, I add to index.php. Menu of my website: Lesson1 Lesson2 Lesson3 . . . And I have given a link that like:<a href="index.php?id=1">Lesson1</a> But it doesnt work. Please help me!
Try adding this after the $result bit.. while($r=mysql_fetch_array($result)){ echo $r['id']; } Code (markup): Also check that in your database its called 'id' and not 'ID'.
what error do you get ? FYI : mysql_connect("localhost","root"); // is same as mysql_connect("localhost","root",""); PHP:
mysql_connect(); is the same as mysql_connect('localhost', 'root', ''); I think Also, its because $result is a resource, not an array. Use mysql_fetch_assoc or something similar to get it into an array first
<?php { $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("derslerioku", $con); $sorgu= mysql_query("SELECT * FROM dersler"); $id = $_GET['id']; $alan1 = mysql_result($sorgu,$id,"dersicerik"); echo "$alan1"; mysql_close($con); } ?> Code (markup): I solved the problem. Thanks for help!