Fallen_angel Posted November 3, 2006 Share Posted November 3, 2006 Firstly hi , :) I am currently learning php/mysql whilst at the same time writing a webapp fro my website ( I know that the first version will have allot to fix but thats how I find I learn the best )in the bellow script what I am tryign to do is , build the frame work for the actual articles , at the moment it ofcourse has no stylign or formatting so it's ugly however that is not very important to me untill I actually get it working I want the pages to be accessed by going to http://website/page_name.php?id=1 ( or whatever id I wish to put in ) this should then , use the id variable at the end of the url and search for that value in the s_id collum in my database and pull down the rest of the information tied into that row I belive I have it pretty close but am goign wrong somewhere ( i belive it is the $id variable thats not working ) however I am not sure how I should fix it any help you can give is greatly apreciated [code]<?php//Connect To databaseinclude "connect.php";//collects Data$data=mysql_query("SELECT * FROM strains where s_id='$id'")or die(mysql_error());Print "<table border=2px>" ;Print "<tr><td><b>Name</b></td><td><b>Breeder</b></td><td><b>Type</b></td><td><b>Yeild</b></td><td><b>Time</b></td></tr>";while ($info= mysql_fetch_array($data) ){Print "<tr><td width=150px> ".$info['s_name']. "</td><td width=150px> ".$info['s_breeder'] ."</td><td width=100px>".$info['s_type'] ."</td><td width=35px> ".$info['s_yeild'] ."</td><td width=25px> ".$info['f_time'] ." Days</td></tr>";}Print "</table>" ;?>[/code]thankyou again in advance regards,Fallen Angel Link to comment https://forums.phpfreaks.com/topic/26017-help-with-a-phpmysql-query-results/ Share on other sites More sharing options...
jasper182 Posted November 3, 2006 Share Posted November 3, 2006 You need to set the value of $id. To get the value from your address like you have listed, you would do something like this:$id = $_GET['id'];Also, I don't think you can capitalize Print...but I may be wrong on that.Hope this helps Link to comment https://forums.phpfreaks.com/topic/26017-help-with-a-phpmysql-query-results/#findComment-118941 Share on other sites More sharing options...
Fallen_angel Posted November 3, 2006 Author Share Posted November 3, 2006 Your a champion thankyou so much !! I knew it was the variable that was doign it to me , however i thought that buy havign it in the url it was getting assigned thankyou so so much again :) Link to comment https://forums.phpfreaks.com/topic/26017-help-with-a-phpmysql-query-results/#findComment-118942 Share on other sites More sharing options...
chriscloyd Posted November 3, 2006 Share Posted November 3, 2006 ya thats only when u post it from forms its already assigned like [CODE]<?php$id//but when its a get its assigned like $_GET['id']?>[/CODE] Link to comment https://forums.phpfreaks.com/topic/26017-help-with-a-phpmysql-query-results/#findComment-118948 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.