Jump to content

pages.php


Alfraganus

Recommended Posts

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

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.

  • Like 1
Link to comment
Share on other sites

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 by Alfraganus
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...