Jump to content

Recommended Posts



Can some one help me i need to add a prev and next with numbers but i tried but failed cheers.

If the user has more then 1 message the user can press prev next and number.

[code]
$query="select * from member_messages where id='$id'";
$result=mysql_query($query);
while($record=mysql_fetch_assoc($result)){
echo"<table width='200'border='4' bordercolor='black'><td align='center'><b>Members

Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font

color='red'><br>".$record["members_name"]."</font><br>
Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font

color='red'><br>".$record["date"]."</font> </b></td><table>";
echo "<table width='200'border='4' bordercolor='black'><td align='center'><b>Read Message:

<font color='red'>Read</b></font></td></table><br><br>";

}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/11707-prev-next-123-help-cheers/
Share on other sites

[code]

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


$max_results = 10;


$from = (($page * $max_results) - $max_results);



$query="select * from member_messages where id='$id' LIMIT $from, $max_results";
$result=mysql_query($query);


while($record=mysql_fetch_assoc($result)){
echo"<table width='200'border='4' bordercolor='black'><td align='center'><b>Members

Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font

color='red'><br>".$record["members_name"]."</font><br>
Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font

color='red'><br>".$record["date"]."</font> </b></td><table>";
echo "<table width='200'border='4' bordercolor='black'><td align='center'><b>Read Message:

<font color='red'>Read</b></font></td></table><br><br>";

}



$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM

member_messages"),0);


echo "<center>Select a Page<br />";


if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
    }
}


if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
echo "</center>";

?>
[/code]
This is the code so far as the above was wrong know the message is showwing the two messages when the second should be on the page number 2 but issint lol cheers


[code]

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

$max_results = 10;


$from = (($page * $max_results) - $max_results);


$query="select * from member_messages where id='$id' LIMIT $from, $max_results";
$result=mysql_query($query);
while($record=mysql_fetch_assoc($result)){
echo"<table width='200'border='4' bordercolor='black'><td align='center'><b>Members

Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font

color='red'><br>".$record["members_name"]."</font><br>
Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font

color='red'><br>".$record["date"]."</font> </b></td><table>";
echo "<table width='200'border='4' bordercolor='black'><td align='center'><b>Read Message:

<font color='red'>Read</b></font></td></table><br><br>";

}



$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM

member_messages"),0);


$total_pages = ceil($total_results / $max_results);


echo "<center>Select a Page<br />";


if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
    }
}


if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
echo "</center>";

?>
[/code]
[!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]solved[!--sizec--][/span][!--/sizec--]

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

$max_results = 1;


$from = (($page * $max_results) - $max_results);


$query="select * from member_messages where id='$id' LIMIT $from, $max_results";
$result=mysql_query($query);
while($record=mysql_fetch_assoc($result)){
echo"<table width='200'border='4' bordercolor='black'><td align='center'><b>Members

Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font

color='red'><br>".$record["members_name"]."</font><br>
Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font

color='red'><br>".$record["date"]."</font> </b></td><table>";
echo "<table width='200'border='4' bordercolor='black'><td align='center'><b>Read Message:

<font color='red'>Read</b></font></td></table><br>";

}



$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM member_messages

where id='$id'"),0);


$total_pages = ceil($total_results / $max_results);


echo "<center><b>Select A Message!</b><br>";


if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\">Previous>></a>";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
    }
}


if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
echo "</center>";

?>
[/code]
i got a slight problam

as you can see from the above code i am using it for users to look at who sent a message.

but when i want to go to to a read page to read that message i get all the messages in the database
with a while loop.

example

if i press 1 i get the two messages in the database i did try limit 1 but if you then goto page 2 you only get message 1 on the read page.

From the code above how do you get a link to corerspond to the data in the database so if link 2 had message from god then you see message from god on the read page.

i tried page=$page&id='$id' // dont work

also the otherway around.

so the quiestion is how do you get the data in a database to be seen from a pagatinton to another page.

or otherwise i have to show all messages and theat defeats the code get me

heres the read.php page example
[code]

$db=mysql_connect("localhost","root","admin");
mysql_select_db("promotor",$db);



$query="select * from member_messages where id='$id'";
$result=mysql_query($query);
while($record=mysql_fetch_assoc($result)){


echo"<table align='center' width='300'border='4' bordercolor='black'><td

align='left'><b>Members Id:<font color='red'><br>".$record["sent_id"]."</font><br> User

Name: <font color='red'><br>".$record["members_name"]."</font><br>
Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font

color='red'><br>".$record["date"]."</font> </b></td><td align='center'

valign='top'><b>Members Message<b>
<br><br><b><div align='left'><textarea col='7' rows='7'style='color: white;

background-color: #A0C0F0'>".$record["message"]."</textarea></td></b></div><table>";






echo "<table align='center' width='300'border='4' bordercolor='black'><td

align='center'><b>Send A Reply    <font color='red'><a

href='send_message.php?&id=$id'>reply</a></b></font></td></table><br>";

}
[/code]
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.