Davidammit Posted August 18, 2008 Share Posted August 18, 2008 I've got a PHP file rigged up to return a certain number of responses off a MySQL Database. Here's the code: <?php /* $start=$_GET["start"]; $amount=$_GET["amount"]; */ $start=4; $amount=6; $con = mysql_connect('localhost', 'waotaku_search', 'abc123'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("waotaku_anime", $con); $sql="SELECT name, episode, title, added FROM animelist LIMIT " . $start . " , " . $amount; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $link="#"; if ( $row[title] != null ) { $title=$row[title]; } else { $title=$row[name] . " Episode " . $row[episode]; } echo '<a href="' . $link . '">'; echo " " . $title . "</a>"; echo "<br />"; } mysql_close($con); ?> That code displays this: http://weareotaku.x10hosting.com/recent_updates.php Rosario + Vampire Episode 4 Rosario + Vampire Episode 5 Rosario + Vampire Episode 6 Rosario + Vampire Episode 7 Rosario + Vampire Episode 8 Rosario + Vampire Episode 9 End of Updates Which is exactly what I want to display in the Recent Updates box of my site here: http://weareotaku.x10hosting.com/ But instead of just displaying the 6 responses like it is on the PHP page, It displays the whole damned list. And try as I might, I cannot stop it and I have no clue why it won't display just the results I wanted; The JavaScript I used is http://weareotaku.x10hosting.com/recent_updates.js var recentHttp; var start=0; var amount=6; function slideupdates(direction, number) { switch (direction) { case 0: if ( start-number<=0 ) { start=0; } else { start = start - number; } break; case 1: if ( end+number>100 ) { start=95; } else { start = start + number; } break; case 2: if (number>=0 && number <=95) { start=number; } else { start=0; } break; default: alert('Not a Valid Slide Direction'); return; break; } recentHttp=GetXmlHttpObject(); if (recentHttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="search.php"; url=url+"?start="; url=url+start; url=url+"&amount="; url=url+amount; url=url+"&sid="+Math.random(); recentHttp.onreadystatechange=recentStateChanged recentHttp.open("GET",url,true); recentHttp.send(null); } function recentStateChanged() { if (recentHttp.readyState==4 || recentHttp.readyState=="complete") { recentDoc=recentHttp.responseText; document.getElementById("recentupdates").innerHTML=recentDoc; } } function GetXmlHttpObject() { var objXMLHttp=null; if (window.XMLHttpRequest) { objXMLHttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP"); } return objXMLHttp; } My final goal is to have arrows on the left and right side of the 'Recent Updates' header so that it will skip to the next set of updates. I thought it would be a nice little user interactivity thing. Any help would be greatly appreciated. As I am kinda a beginner at this I just have no clue whats going wrong. It seems that I have done everything correctly, except it displays incorrectly. Quote Link to comment Share on other sites More sharing options...
FoolishOne Posted August 20, 2008 Share Posted August 20, 2008 Did you get it? As stupid as it sounds, start at the beginning. Make sure the PHP is getting the right numbers and verify that the GET is transferring the numbers as integers, not strings, etc. You never know... <?php $start=$_GET['start']; $amount=$_GET['amount']; echo "Start value:".$start." and Amount value:".$amount; ?> 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.