teng84 Posted December 6, 2007 Share Posted December 6, 2007 <? include "includes/functions.php"; include "includes/db_connect.php"; session_start(); logincheck(); $username=$_SESSION['username']; echo "<link rel=stylesheet href=includes/in.css type=text/css>"; ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .style19 { font-size: 11px; font-weight: bold; } .style20 { font-size: 10px; font-weight: bold; color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; } --> </style> </head> <body> <table width="80%" border="0" align="center" cellspacing="5"> <tr> <td colspan="4"><div align="center" class="style19">History </div><br> <table width="100%" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#000000" rules= class=thinline> </table></td> </tr> <tr> <td width="294" height=""> <?php $username=$_SESSION['username']; $limit = 10; $query_count = "SELECT count(*) FROM goldies WHERE Sender='$username'"; $result_count = mysql_query($query_count) or die("Error: " . mysql_error()); $totalrows = mysql_result ($result_count, 0, 0); $numofpages = ceil($totalrows/$limit); // $page = (empty($_GET['page']) || !is_int($_GET['page']))?1:abs($_GET['page']); // // $limitvalue = ($page-1) * $limit; $page = (empty($_GET['page']) || !is_int($_GET['page']))?1:$_GET['page']; $end = $page *$limit; $start = $end-$limit; $query = "SELECT * FROM goldies WHERE Sender='$username' LIMIT $start, $end "; $result = mysql_query($query) or die("Error: " . mysql_error()); //Exit if no records to display if(mysql_num_rows($result) == 0){ exit("Nothing to Display!"); } //Create the table of output data echo "<table>\n"; while($row = mysql_fetch_array($result)){ //Alternate the row background color $bgcolor = ($bgcolor == "#737373")?'#737373':'#737373'; //Display the row of data echo "<tr bgcolor=\"$bgcolor\">\n"; echo " <td>".$row["Receiver"]."</td>\n"; echo " <td>".$row["Amount"]."</td>\n"; echo " <td>".$row["Date"]."</td>\n"; echo "</tr>"; } echo "</table>\n"; //Enable the Prev link if not first page if($page > 1){ echo("<a href=\"creditshistory.php?page=".($page-1)."\">PREV</a> "); }else{ echo("PREV "); } //Create links for each page in report for($i=1; $i<=$numofpages; $i++){ if($i == $page){ echo "$i "; }else{ echo "<a href=\"creditshistory.php?page=$i\">$i</a> "; } } //Enable the Next link if not last page if($page < $numofpages){ echo("<a href=\"creditshistory.php?page=".($page+1)."\">NEXT</a>"); }else{ echo("NEXT"); } mysql_free_result($result); ?> </td> <td width="17"> </td> <td width="273"> </td> </tr> </table> </body> </html> try and tell me what happen Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 6, 2007 Share Posted December 6, 2007 Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\xampp\htdocs\game\creditshistory.php on line 101 sorry, i miss a dot try echo "page number : ". $page . "<br>"; Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 teng still the same prob Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 6, 2007 Share Posted December 6, 2007 teng still the same prob What did my script echo out for you? And I am sorry, is your problem still the NEXT link thing? Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\xampp\htdocs\game\creditshistory.php on line 101 sorry, i miss a dot try echo "page number : ". $page . "<br>"; Sensei following results for ur modification: table shows and below it is this : PREV 1 2 3 page number : 1 number of pages : 3NEXT The problem still is that links have correct URLS but when i click them they only reload page to page '1' Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 6, 2007 Share Posted December 6, 2007 Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\xampp\htdocs\game\creditshistory.php on line 101 sorry, i miss a dot try echo "page number : ". $page . "<br>"; Sensei following results for ur modification: table shows and below it is this : PREV 1 2 3 page number : 1 number of pages : 3NEXT The problem still is that links have correct URLS but when i click them they only reload page to page '1' Alright do one more thing for me, change page=1 to page=2 in your URL, and see if it prints out page number: 2. Then change $page to $_GET['page'] in your IF statement. Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 going to page 2 url it still says page:1 in the echo statement i changed $page to $_GET['page'] in all If statements, still the same results this time the NEXT link is no longer a link and PREV link says there is a page 0 my head hurts from this Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 6, 2007 Share Posted December 6, 2007 try if($_GET['page'] !=< $numofpages){ echo("<a href=\"creditshistory.php?page=".($page+1)."\">NEXT</a>"); }else{ echo("NEXT"); } mysql_free_result($result); ?> Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 interestingly enough when i put the page one URL in the address bar and load page 1, when i click page 2 link the page reloads to show page 1 but the url changes to page 2 url. when i click page 3 the url changes to page 3 url, but the table shows page 1 data all the time Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 Sensei i get error: Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\game\creditshistory.php on line 105 Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 6, 2007 Share Posted December 6, 2007 Sensei i get error: Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\game\creditshistory.php on line 105 Well sorry, but you should know there is no such thing as !=< lol, sorry my bad, change it != I am really stressed out right now, I can't type well. Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 The url changes when i go to different pages, the table data always shows page 1 data and the 'page number' variable always echos '1' despite the url change all i wanted was to give users of my site a better experience, easier navigation, a simple paging system, but NOOOOOOOOOOOOOO something had to go wrong! lol Quote Link to comment Share on other sites More sharing options...
teng84 Posted December 6, 2007 Share Posted December 6, 2007 if you said the url changes then you sould be fine! again echo your query in both pages and see the diff Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 6, 2007 Share Posted December 6, 2007 The url changes when i go to different pages, the table data always shows page 1 data and the 'page number' variable always echos '1' despite the url change all i wanted was to give users of my site a better experience, easier navigation, a simple paging system, but NOOOOOOOOOOOOOO something had to go wrong! lol Can you please link us to your site, there is something seriously wrong with this. And a screenshot of your database table DATA. The script is fine. Also, do what Teng said, and tell us the results. Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 the echo statement which says what page number it is? that one always says '1' despite url change i cant link you to my site as it is hosted using xampp on my pc i can get u a screenie of my db, hold on Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 6, 2007 Share Posted December 6, 2007 the echo statement which says what page number it is? that one always says '1' despite url change i cant link you to my site as it is hosted using xampp on my pc i can get u a screenie of my db, hold on So your saying that "?page=2" comes out "1" even when you put echo $_GET['page']; ? Thankyou, screenshot would help. Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 The url changes to ?page=2 when i click page 2 link and same with when i click page three or one. But the data in the table stays dat from page 1 and the "page number :" variable says "1" all the time uploading screenie for db, i will upload screenie of site after this: Database image Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 Actual page screenshot: Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 6, 2007 Share Posted December 6, 2007 I am currently writing the script for it, need to use the bathroom be right back. Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 ok, i'll wait this will work won't it? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 6, 2007 Share Posted December 6, 2007 Alright, um... do me a favor. I want you to print out $page after each time it is being change. I.E. $page = (empty($_GET['page']) || !is_int($_GET['page']))?1:abs($_GET['page']); $limitvalue = ($page-1) * $limit; $limitrange = $limitvalue+$limit; between the $page and $limitvalue, add a echo $page, to see where the data is being changed during the process. try this for each line the $page is being used in, or changed. But a $page . "< br >"; and tell me what you get. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 6, 2007 Share Posted December 6, 2007 I've almost got it working for you on my server. I will post the code as soon as I finish. Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 thank poco, and sensei you want me to echo the following: echo "". $page . ""; Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 6, 2007 Share Posted December 6, 2007 Yes, please add the $page echo right after the $page = (empty....etc I just know its the $page = (empty... thing that is being used the wrong way. Quote Link to comment Share on other sites More sharing options...
RealDrift Posted December 6, 2007 Author Share Posted December 6, 2007 i understand what u want me to do but i dnt think me and u r looking at the same script. The script i have now after changing it on urs and teng's command: <?php $username=$_SESSION['username']; $limit = 10; $query_count = "SELECT count(*) FROM goldies WHERE Sender='$username'"; $result_count = mysql_query($query_count) or die("Error: " . mysql_error()); $totalrows = mysql_result ($result_count, 0, 0); $numofpages = ceil($totalrows/$limit); // $page = (empty($_GET['page']) || !is_int($_GET['page']))?1:abs($_GET['page']); // // $limitvalue = ($page-1) * $limit; $page = (empty($_GET['page']) || !is_int($_GET['page']))?1:$_GET['page']; $end = $page *$limit; $start = $end-$limit; $query = "SELECT * FROM goldies WHERE Sender='$username' LIMIT $start, $end "; $result = mysql_query($query) or die("Error: " . mysql_error()); //Exit if no records to display if(mysql_num_rows($result) == 0){ exit("Nothing to Display!"); } //Create the table of output data echo "<table>\n"; while($row = mysql_fetch_array($result)){ //Alternate the row background color $bgcolor = ($bgcolor == "#737373")?'#737373':'#737373'; //Display the row of data echo "<tr bgcolor=\"$bgcolor\">\n"; echo " <td>".$row["Receiver"]."</td>\n"; echo " <td>".$row["Amount"]."</td>\n"; echo " <td>".$row["Date"]."</td>\n"; echo "</tr>"; } echo "</table>\n"; //Enable the Prev link if not first page if($_GET['page'] > 1){ echo("<a href=\"creditshistory.php?page=".($page-1)."\">PREV</a> "); }else{ echo("PREV "); } //Create links for each page in report for($i=1; $i<=$numofpages; $i++){ if($i == $_GET['page']){ echo "$i "; }else{ echo "<a href=\"creditshistory.php?page=$i\">$i</a> "; } } //Enable the Next link if not last page echo "page number : ". $page . " "; echo "number of pages : ". $numofpages; if($_GET['page'] != $numofpages){ echo("<a href=\"creditshistory.php?page=".($page+1)."\">NEXT</a>"); }else{ echo("NEXT"); } mysql_free_result($result); ?> its got some bits commented out, i am confused as hell Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.