Jump to content

[SOLVED] number to change on different page?


y2yang

Recommended Posts

How to make the number in red change on different page?

 

<?php

$page_id = "photo_23";

?>

 

This code is used on an iframe page.

 

I wanted the number in red to change on every page, as it defined the comment page to its article.

 

Parent page code:

<div id="viewComment" style="display: block;">
    <iframe style="height: 118px; width: 580px;" src="comment/news_1.php" name="ifrmComment" id="ifrmComment" scrolling="no" width="580" frameborder="0"></iframe>
</div>

 

Iframe page code (news_1.php):

<?php
$page_id = "photo_1";
?>

Link to comment
Share on other sites

If everypage is going to be numbered as above, so the second page would be news_2.php you can just use $_SERVER["SCRIPT_FILENAME"]

 

<?php
$page = (int) $_SERVER["SCRIPT_FILENAME"];
$page_id = "photo_$page";

Link to comment
Share on other sites

It will yes.

 

news.php should have this somewhere;

 

if(!isset($_GET['page'])) {
$page = 1;
} else {
$page = (int) $_GET['page'];
}

 

Then the html for next and previous would be something like this;

 

<a href="news.php?page=<?php echo $page+1 ?>">Next</a>

Link to comment
Share on other sites

Sorry I still a little confused, can you clarify a little for me.

 

Say my comment script is in comment.php and my main read page is page.php?id=#s

 

script:

<?php

$page_id = "ID1";

?>

 

is inside of comment.php, which i needed the ID to have change from page.php?id=1 to page.php?id=2.

 

say if page.php?id=1, then in comment.php, it should have ID1.

 

and in page.php?id=2, comment.php should have ID2, without me changing anything in comment.php.

 

and on page.php, i used :

 

<div id="viewComment" style="display: block;">

    <iframe style="height: 118px; width: 580px;" src="comment.php" name="ifrmComment" id="ifrmComment" scrolling="no" width="580" frameborder="0"></iframe>

</div>

 

to call upon comment.php

 

 

Link to comment
Share on other sites

It would be easier to do this if you inluce comment.php, not put it in an iframe. There are many benefits of doing it that way, one being the ability of the included file to use the variables already loaded

Link to comment
Share on other sites

The thing is that I have a code:

 

	<div class="tal">
	<img src="http://image.vickizhao.net/style_guide/txt/txt_starhome_comment.gif" alt="" />
	<img id="imgobj" src="http://image.vickizhao.net/style_guide/icn/icn_starhome_hidden.gif" onclick="openReply('http://image.vickizhao.net')" class="hand" alt="" />
</div>

<p style="margin:5px;"></p>

 

Which is used to hide and show the comment, but it must be in an iframe as the original coder make it that way and I think it would be a big mess trying to make it not iframe.

 

So is there a way?

 

or would i be better off creating a folder and put comment1.php comment2.php comment3.php and so on and use your first option, which to have the script to generate its ID by it page name?

Link to comment
Share on other sites

You can pass the get global from page.php when calling the iframe;

 

<?php
if(!isset($_GET['page'])) {
$page = 1;
} else {
$page = (int) $_GET['page'];
}
?>
<iframe style="height: 118px; width: 580px;" src="comment.php?page=<?php echo $page ?>" name="ifrmComment" id="ifrmComment" scrolling="no" width="580" frameborder="0"></iframe>

Link to comment
Share on other sites

In comment.php, there is a code:

 

<?php
$page_id = "UniqueID";
?>

 

and no two UniqueID may be the same. You probably say this earlier but what can I do to make sure no two UniqueID are the same in comment.php?

Link to comment
Share on other sites

sorry if i don't make sense, let me explain it in detailed.

 

There are 2 pages:

 

page.php?id=#s, which has many pages in it and it's the read page for my paragraph.

 

comment.php?id=#s, which thank to you, i solved the puzzle of not having to create many comment pages and just use ?id.

 

But inside of comment.php, off all the code in there, only one thing need to be changing from page to page so that no two id in in page_id are the same, and that is

 

<?php

$page_id = "THIS AND IT CAN BE ANYTHING, # OR LETTER";

?>

 

Link to comment
Share on other sites

nvm, i think i finally solved the puzzle thank to you.

 

Here is what i got:

 

so if comment.php has id=RANDOM ID, say comment.php?id=1029

 

,then i can use

 

<?php

if(!isset($_GET['page'])) {

$page = 1;

} else {

$page = (int) $_GET['page'];

}

?>

 

inside of comment.php

 

and

 

in comment.php:

 

<?php

$page_id = "<?php echo $page ?>";

?>

 

than no two id in $page_id can be the same.

 

Thank you soo much gevans

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.