Alfraganus Posted December 24, 2015 Share Posted December 24, 2015 I was creating small CMS website, I have posted all the posts succesfully, but when I am clicking to any post's title or read more, it is not opening it:, web page just opening blank page, however, localhost is not alerning any error, public function fullpost() { if(isset($_GET['id'])) { $post_id=$_GET['id']; $q="SELECT * FROM tables where body_id=$post_id"; (I think here is my mistake, but I dont know what is it exactly) $r=mysql_query ($q); if ($r !==false &&mysql_num_rows($r)>0) { while ($a=mysql_fetch_assoc($r)) { $body_id=($a['id']); $title=stripcslashes($a['title']); $body=($a['body']); $image=($a['image']); echo " <h1><a href='pages.php?id=<?php echo $body_id';?> $title </h1></a> <img src='images1/$image' /> <p>$body</p><br><br><br> "; } } } } } Link to comment Share on other sites More sharing options...
dsonesuk Posted December 24, 2015 Share Posted December 24, 2015 You will get a unreadable invalid link, just look at source code! is that what you expected to see? a echo $body_id within the querystring, No! you can't have echo within a echo, you have to separate html text from php, plus your html structure for anchor and header is wrong, look at first opening tag, and compare with last closing tag of header and anchor, any child tag opening within opening tag of parent MUST close within that parent, before the closing tag of that parent. 1 Link to comment Share on other sites More sharing options...
Alfraganus Posted December 25, 2015 Author Share Posted December 25, 2015 (edited) bro those anchors are working at least, my biggest issue is opening the page where its id equal to page id, my requested page in not coming from database, instead, i am having a blank page, can you check my sql query to select data from database please, I believe there is my mistake Edited December 25, 2015 by Alfraganus Link to comment Share on other sites More sharing options...
dsonesuk Posted December 25, 2015 Share Posted December 25, 2015 I know for a fact the achor querystring IS a problem, if it cannot retrieve the id from that unreadable querystring, how do you expect it to tie in with any database id with that unreadable querystring, it WON'T and that is why you get A BLANK PAGE. 1 Link to comment Share on other sites More sharing options...
Alfraganus Posted December 25, 2015 Author Share Posted December 25, 2015 bro please can you type the correct code, can you correct it for me please, I've been trying a lot, but no works( Link to comment Share on other sites More sharing options...
dsonesuk Posted December 25, 2015 Share Posted December 25, 2015 echo '<h1><a href="pages.php?id='.$body_id.'">'.$title.'</a></h1><img src="images1/'.$image.'" /> <p>'.$body.'</p><br><br><br>'; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now