Jump to content


Photo

prev next 123... help cheers


  • Please log in to reply
6 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 June 2006 - 01:06 PM



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.

$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>";

}

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 June 2006 - 01:48 PM


<?
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>"; 

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 11 June 2006 - 02:00 PM

Well what exactley isn't working with it at the moment?

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

In this one it's over 10 though
z..z..z..z..z..z..z..z..

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 June 2006 - 02:06 PM

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



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>"; 

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 11 June 2006 - 02:08 PM

$max_results = 10;

change it to 1
z..z..z..z..z..z..z..z..

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 June 2006 - 02:22 PM

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

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>"; 

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 June 2006 - 03:36 PM

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

$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>";

}

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users