Jump to content

Search the Community

Showing results for tags 'loop'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi guys, Having trouble trying to show values from my $friend array. Only the first friend code is being displayed in my output. There are several fields in my mysql associated with the $sql. Any ideas? Thanks $sql = "SELECT * FROM friends WHERE Code = '$code' OR FriendCode = '$code' AND Status ='A'"; $result = mysqli_query($cxn,$sql) or die ("Can't get friends."); $friend = array(); while($row=mysqli_fetch_array($result)) { if($code == $row['FriendCode']) { $friend[] = $row['Code']; } elseif($code == $row['Code']) { $friend[] = $row['FriendCode']; } foreach($friend as $key => $value) { echo $value.'<br />'; }
  2. I need my user to log in to use their "admin panel" functions. I have this bit of html for them to enter their username/password: <form id="form1" name="form1" method="post" action="functions/loginprocess.php"> <table> <tr> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" id="username" /></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" id="password" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="button" id="button" value="Login" /></td> </tr> </table> </form> This bit of code at the top of the html to start the session: <?php session_start(); $err = $_GET['e']; ?> This bit of code at the top of the index page to redirect to the login screen <?php session_start(); $l=6; $a="out"; if(isset($_SESSION['username'])) { $l=$_SESSION['username']; $a="in"; } else { header('Location: login.php?e=Login to use the administration functions'); } $err = $_GET['e']; ?> And this code to perform the log in functions: <?php session_start(); $username = $_POST['username']; $password = $_POST['password']; $conn = mysqli_connect("Connection String"); $username = mysqli_real_escape_string($conn, $username); $query="SELECT * FROM users WHERE username='$username' AND userpassword='$password'"; $result = mysqli_query($conn, $query); if(mysqli_num_rows($result) == 0) // User not found. So, redirect to login_form again. { $conn->close(); header('Location: ../login.php?e=User not found'); exit(); } $userData = mysqli_fetch_array($result); $hash = hash('sha256', $userData['cmspassword']."$password"); //echo "$hash"; if($hash != $userData['userpassword']) // Incorrect password. So, redirect to login_form again. { $conn->close(); header('Location: ../login.php?e=Incorrect login details'); exit(); } else{ // Redirect to home page after successful login. $_SESSION['username'] = $username; $_SESSION['user'] = $userData['userid']; $_SESSION['sp'] = $userData['cmspassword']; $conn->close(); header('Location: ../index.php'); exit(); } ?> And the database table is called 'users' with the following columns: userid username useremail userpassword cmspassword However, as stated in the title of this post, I appear to be stuck in a loop where whenever I enter the user credentials it just keeps looping round the "user not found" message on line 16. Can anyone help me, I am well and truly stuck on how to get out of this loop? I know I've gone wrong somewhere, just can't see where
  3. Greetings all, I have been developing a comment box for my site and I ran into an issue I can't seem to figure out. In my comment box when I am logged in as an admin I want to be able to delete comments by simply clicking a button. The comments are printed out from a database using a while loop: <?php echo '<div id="commentMainTitle"><h3>Video Comments</h3></div>'; while($row = mysqli_fetch_array($results, MYSQLI_ASSOC)){ echo '<div id="commentUniqueWrap"> <div id="commentUniqueTitleMessageWrap"> <div id="commentUniqueTitle"> <h4>'. stripslashes($row['name']) .'</h4>';?> <?php if (isset($_SESSION['admin'])){?> <!--If admin add form for delete comment.--> <form enctype="multipart/form-data" action="includes/function/deletecomment.php" method="post"> <input type="hidden" name="cursect" value="<?php echo $sect1;?>" /> <input type="hidden" name="curvideored" value="<?php echo $_GET['curvideo'];?>" /> <input type="hidden" name="postID" value="<?php echo $row['id'];?>" /> <input type="submit" name="submit" value="Delete" /> <?php echo $row['id']; } echo '</div> <div id="commentUniqueMess"> <p>' . stripslashes($row['comment']). '</p> <p class="datealign">' . $row['date'] . '</p> </div> </div> </div>'; } ?> When the comments are listed out a Delete button is listed next to the commentors name. A comment is deleted however it is not the comment that is selected for deletion. Instead the last comment that was echo'd out from the while loop is deleted. Here is the script that deletes the comment: <?php if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['postID'])){ //Requires the database connection script. require $_SERVER['DOCUMENT_ROOT'] . '/mywebsite/masters/connect.php'; $qdelete = "DELETE FROM comment WHERE id ='".$_POST['postID']."' LIMIT 1"; if (!mysqli_query($connect,$qdelete)){ die('Error: ' . mysqli_error($connect)); } // Close database connection. mysqli_close($connect); // Set path for redirect. $redirect = 'http://www.mywebsite.com/myvideos.php?sect=' . $_POST['cursect'] . '&curvideo=' . $_POST['curvideored']; // Redirect to previous page. echo '<script type="text/javascript"> setTimeout(redirect, 0000); function redirect() { location.href="'.$redirect.'" } </script>'; } ?> I'm not sure what the issue is or how to go about solving it. I feel like the answer is staring me in the face but I've been looking at the code for too long and it has me at a loss. Any help would be greatly appreciated. Thank you for your time. Best Regards, Nightasy
  4. If anyone could give me some advice on this problem that would be great! Rewrite the code below so it would contain only one loop and only one itterational variable would be used. $result = Array(); for ($x = 0; $x < 6; $x++) { for ($y = 0; $y < 6; $y++) { for ($z = 0; $z < 6; $z++) { $result[$x][$y][$z] = $x * $y * $z; } } } Thank you so much
  5. Ok, so I have a main page that grabs data from a MySQL db and posts it into a dropdown menu see here: $sql = "SELECT * FROM 4000Series"; $result = $con->query($sql); print "Select your GPU: <select name='gpuId'>"; while ($row = $result->fetch_assoc()) { print "<option value='" .$row["id"] . "'>" . $row["gpu"] . "</option>"; } print "</select> </br>\n"; This works fine, from here I'm passing the POST data from the option values to a new page (basically the option values correspond directly to the "id" value in my SQL db). The values are passed onto the new page fine, but when I try to setup an SQL select statement to grab the row with the corresponding "id" value and print it out with a while loop I'm shooting a blank. Here's the code for the second page $id = $_POST['gpuId']; **Connect to sql db here** $sql = "SELECT * FROM 4000Series WHERE $id ='id'"; $result = $con->query($sql); echo "<table>"; while ($row = $result->fetch_assoc()){ echo "<tr><td>" . $row['id'] . "</td><td>" . $row['gpu'] . "</td></tr>"; } echo "</table>"; When I view the source it prints out the table tags but nothing in the while loop, any ideas?
  6. Ok, so I created a test database on my server, created 1 table with 1 row in it and the row is populated with values. I can connect to the database without error, but when I try to put in a while loop to print the results I get nothing but a blank screen. I tried placing some debug code in the while loop to see where its getting hung up but the while loop doesn't want to run at all. I placed an echo directly outside of the loop and the debug text is displayed fine but anything I put in the loop doesn't work. Can anyone help me out? Here is my code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php $dbuser = "webestat_testdb"; $dbpass = "password"; $dbname = "webestat_testdb"; $server = "localhost"; $conn = mysql_connect($server, $dbuser, $dbpass); if (!$conn) { echo "Failed to connect to db" . mysql_error(); } $selectdb = mysql_select_db('webestat_testdb', $conn); $sql = "SELECT * FROM 4000Series"; $results = mysql_query($conn, $sql); while($row = mysql_fetch_assoc($results)) { echo "test"; echo $row['gpu']. " " .$row['khs']. " " .$row['usd']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
  7. Dear all, I have a script on my website's front page. Quickly summarized: - I have two main categories ("Made by me" and "Made by others") - I have five subcategories I want to have on my frontpage two columns (one for main category #1, two for main category #2) containing each two postings. I use two loops: <!-- Start the Loop. --> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php static $count = 0; if ($count == "2") { break; } else { ?> <?php if ( in_category('5') && !is_single() ) continue; ?> <!--Start Post--> <div align="justify" style='float:left; width: 276px; margin: 0 0 0 20px;'> <h6><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><div style="color: #000000;"><?php the_title(); ?></div></a></h6> <div style="font-size: 80%; color: #999999; font-style: italic; font-weight: bold;">In: <?php //exclude these from displaying $exclude = array("4"); //set up an empty categorystring $catagorystring = ''; //loop through the categories for this post foreach((get_the_category()) as $category) { //if not in the exclude array if (!in_array($category->cat_ID, $exclude)) { //add category with link to categorystring $catagorystring .= ''.$category->name.', '; } } //strip off last comma (and space) and display echo substr($catagorystring, 0, strrpos($catagorystring, ',')); ?></div> <?php $my_excerpt = get_the_excerpt(); echo "<div style=\"color: #000000;\">"; echo $my_excerpt; echo "</div>"; ?> <?php wp_link_pages(array('before' => '' . __('Pages:', 'cloriato'), 'after' => '')); ?> <div class="frontpage_olav"> <a class="read_more" href="<?php the_permalink(); ?>"></a></div> </div> <!--End Post--> <?php $count++; } ?> <?php endwhile; ?> <!--End Loop--> <?php endif; ?> </div> And for the second column: <!-- Start the Loop. --> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php static $count2 = 0; if ($count2 == "2") { break; } else { ?> <?php if ( in_category('4') && !is_single() ) continue; ?> <!--Start Post--> <div align="justify" style='float:left; width: 276px; margin: 0 0 0 17px;'> <h6><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><div style="color: #000000;"><?php the_title(); ?></div></a></h6> <div style="font-size: 80%; color: #999999; font-style: italic; font-weight: bold;">In: <?php //exclude these from displaying $exclude2 = array("5"); //set up an empty categorystring $catagorystring2 = ''; //loop through the categories for this post foreach((get_the_category()) as $category2) { //if not in the exclude array if (!in_array($category2->cat_ID, $exclude2)) { //add category with link to categorystring $catagorystring2 .= ''.$category2->name.', '; } } //strip off last comma (and space) and display echo substr($catagorystring2, 0, strrpos($catagorystring2, ',')); ?></div> <?php $my_excerpt2 = get_the_excerpt(); echo "<div style=\"color: #000000;\">"; echo $my_excerpt2; echo "</div>"; ?> <?php wp_link_pages(array('before' => '' . __('Pages:', 'cloriato'), 'after' => '')); ?> <div class="frontpage_olav"> <a class="read_more" href="<?php the_permalink(); ?>"></a></div> </div> <!--End Post--> <?php $count2++; } ?> <?php endwhile; ?> <!--End Loop--> <?php endif; ?> The whole problem is now that often the first column only shows one posting instead of two. Sometimes, however, it does show two postings. What am I doing wrong? Why doesn't it show two postings as it's supposed to do? How come my first column doesn't function properly? Thanks a lot for all your help! Olav
  8. Hey guys, I'm having the hardest time trying to access data within my foreach loop. Here is the var_dump right before the foreach. array(19) { [0]=> string( "Thursday" [1]=> string( "Saturday" [2]=> string(6) "Monday" [3]=> string(6) "Friday" [4]=> string(6) "Monday" [5]=> string(9) "Wednesday" [6]=> string(7) "Tuesday" [7]=> string(7) "Tuesday" [8]=> string( "Thursday" [9]=> string(6) "Sunday" [10]=> string(7) "Tuesday" [11]=> string(7) "Tuesday" [12]=> string(6) "Monday" [13]=> string(6) "Friday" [14]=> string(9) "Wednesday" [15]=> string(6) "Monday" [16]=> string(9) "Wednesday" [17]=> string(6) "Sunday" [18]=> string(6) "Monday" } array(19) { [0]=> string(90) "http://www.mylink.com/1" [1]=> string(90) "http://www.mylink.com/2" [2]=> string(90) "http://www.mylink.com/3" [3]=> string(90) "http://www.mylink.com/4" [4]=> string(90) "http://www.mylink.com/5" [5]=> string(90) "http://www.mylink.com/6" [6]=> string(90) "http://www.mylink.com/7" [7]=> string(90) "http://www.mylink.com/8" [8]=> string(90) "http://www.mylink.com/9" [9]=> string(90) "http://www.mylink.com/10" [10]=> string(90) "http://www.mylink.com/11" [11]=> string(90) "http://www.mylink.com/12" [12]=> string(90) "http://www.mylink.com/13" [13]=> string(90) "http://www.mylink.com/14" [14]=> string(90) "http://www.mylink.com/15" [15]=> string(90) "http://www.mylink.com/16" [16]=> string(90) "http://www.mylink.com/17" [17]=> string(0) "" [18]=> string(0) "" } array(19) { [0]=> string(6) "715.00" [1]=> string(6) "912.00" [2]=> string(6) "715.00" [3]=> string(6) "715.00" [4]=> string(6) "715.00" [5]=> string(6) "715.00" [6]=> string(6) "715.00" [7]=> string(6) "912.00" [8]=> string(6) "715.00" [9]=> string(6) "715.00" [10]=> string(6) "715.00" [11]=> string(6) "715.00" [12]=> string(6) "715.00" [13]=> string(6) "912.00" [14]=> string(6) "912.00" [15]=> string(6) "715.00" [16]=> string(6) "715.00" [17]=> string(6) "715.00" [18]=> string(6) "912.00" } array(19) { [0]=> string(6) "330.00" [1]=> string(6) "400.00" [2]=> string(6) "330.00" [3]=> string(6) "330.00" [4]=> string(6) "330.00" [5]=> string(6) "330.00" [6]=> string(6) "330.00" [7]=> string(6) "400.00" [8]=> string(6) "330.00" [9]=> string(6) "330.00" [10]=> string(6) "330.00" [11]=> string(6) "330.00" [12]=> string(6) "330.00" [13]=> string(6) "400.00" [14]=> string(6) "400.00" [15]=> string(6) "330.00" [16]=> string(6) "330.00" [17]=> string(6) "330.00" [18]=> string(6) "400.00" } array(19) { [0]=> string(6) "220.00" [1]=> string(6) "275.00" [2]=> string(6) "220.00" [3]=> string(6) "220.00" [4]=> string(6) "220.00" [5]=> string(6) "220.00" [6]=> string(6) "220.00" [7]=> string(6) "275.00" [8]=> string(6) "220.00" [9]=> string(6) "220.00" [10]=> string(6) "220.00" [11]=> string(6) "220.00" [12]=> string(6) "220.00" [13]=> string(6) "275.00" [14]=> string(6) "275.00" [15]=> string(6) "220.00" [16]=> string(6) "220.00" [17]=> string(6) "220.00" [18]=> string(6) "275.00" } array(19) { [0]=> string(6) "187.00" [1]=> string(6) "225.00" [2]=> string(6) "187.00" [3]=> string(6) "187.00" [4]=> string(6) "187.00" [5]=> string(6) "187.00" [6]=> string(6) "187.00" [7]=> string(6) "225.00" [8]=> string(6) "187.00" [9]=> string(6) "187.00" [10]=> string(6) "187.00" [11]=> string(6) "187.00" [12]=> string(6) "187.00" [13]=> string(6) "225.00" [14]=> string(6) "225.00" [15]=> string(6) "187.00" [16]=> string(6) "187.00" [17]=> string(6) "187.00" [18]=> string(6) "225.00" } array(19) { [0]=> string(6) "157.00" [1]=> string(6) "192.00" [2]=> string(6) "157.00" [3]=> string(6) "157.00" [4]=> string(6) "157.00" [5]=> string(6) "157.00" [6]=> string(6) "157.00" [7]=> string(6) "192.00" [8]=> string(6) "157.00" [9]=> string(6) "157.00" [10]=> string(6) "157.00" [11]=> string(6) "157.00" [12]=> string(6) "157.00" [13]=> string(6) "192.00" [14]=> string(6) "192.00" [15]=> string(6) "157.00" [16]=> string(6) "157.00" [17]=> string(6) "157.00" [18]=> string(6) "192.00" } array(19) { [0]=> string(6) "138.00" [1]=> string(6) "165.00" [2]=> string(6) "138.00" [3]=> string(6) "138.00" [4]=> string(6) "138.00" [5]=> string(6) "138.00" [6]=> string(6) "138.00" [7]=> string(6) "165.00" [8]=> string(6) "138.00" [9]=> string(6) "138.00" [10]=> string(6) "138.00" [11]=> string(6) "138.00" [12]=> string(6) "138.00" [13]=> string(6) "165.00" [14]=> string(6) "165.00" [15]=> string(6) "138.00" [16]=> string(6) "138.00" [17]=> string(6) "138.00" [18]=> string(6) "165.00" } array(19) { [0]=> string(5) "89.00" [1]=> string(6) "125.00" [2]=> string(5) "75.00" [3]=> string(5) "95.00" [4]=> string(5) "86.00" [5]=> string(5) "86.00" [6]=> string(5) "75.00" [7]=> string(6) "150.00" [8]=> string(5) "79.00" [9]=> string(5) "77.00" [10]=> string(6) "103.00" [11]=> string(6) "103.00" [12]=> string(5) "75.00" [13]=> string(6) "118.00" [14]=> string(6) "125.00" [15]=> string(5) "89.00" [16]=> string(5) "75.00" [17]=> string(5) "86.00" [18]=> string(6) "135.00" } array(19) { [0]=> string(5) "97.00" [1]=> string(6) "115.00" [2]=> string(5) "97.00" [3]=> string(5) "97.00" [4]=> string(5) "97.00" [5]=> string(5) "97.00" [6]=> string(5) "97.00" [7]=> string(6) "115.00" [8]=> string(5) "97.00" [9]=> string(5) "97.00" [10]=> string(5) "97.00" [11]=> string(5) "97.00" [12]=> string(5) "97.00" [13]=> string(6) "115.00" [14]=> string(6) "115.00" [15]=> string(5) "97.00" [16]=> string(5) "97.00" [17]=> string(5) "97.00" [18]=> string(6) "115.00" } array(19) { [0]=> string(5) "81.00" [1]=> string(6) "105.00" [2]=> string(5) "60.00" [3]=> string(5) "81.00" [4]=> string(5) "71.00" [5]=> string(5) "71.00" [6]=> string(5) "61.00" [7]=> string(6) "125.00" [8]=> string(5) "69.00" [9]=> string(5) "69.00" [10]=> string(5) "81.00" [11]=> string(5) "81.00" [12]=> string(5) "60.00" [13]=> string(5) "96.00" [14]=> string(6) "105.00" [15]=> string(5) "75.00" [16]=> string(5) "60.00" [17]=> string(5) "71.00" [18]=> string(6) "115.00" } array(19) { [0]=> string(5) "78.00" [1]=> string(5) "90.00" [2]=> string(5) "78.00" [3]=> string(5) "78.00" [4]=> string(5) "78.00" [5]=> string(5) "78.00" [6]=> string(5) "78.00" [7]=> string(5) "90.00" [8]=> string(5) "78.00" [9]=> string(5) "78.00" [10]=> string(5) "78.00" [11]=> string(5) "78.00" [12]=> string(5) "78.00" [13]=> string(5) "90.00" [14]=> string(5) "90.00" [15]=> string(5) "78.00" [16]=> string(5) "78.00" [17]=> string(5) "78.00" [18]=> string(5) "90.00" } array(19) { [0]=> string(5) "50.00" [1]=> string(5) "60.00" [2]=> string(5) "50.00" [3]=> string(5) "50.00" [4]=> string(5) "50.00" [5]=> string(5) "50.00" [6]=> string(5) "50.00" [7]=> string(5) "60.00" [8]=> string(5) "50.00" [9]=> string(5) "50.00" [10]=> string(5) "50.00" [11]=> string(5) "50.00" [12]=> string(5) "50.00" [13]=> string(5) "60.00" [14]=> string(5) "60.00" [15]=> string(5) "50.00" [16]=> string(5) "50.00" [17]=> string(5) "50.00" [18]=> string(5) "60.00" } array(19) { [0]=> string(5) "28.00" [1]=> string(5) "35.00" [2]=> string(5) "28.00" [3]=> string(5) "28.00" [4]=> string(5) "28.00" [5]=> string(5) "28.00" [6]=> string(5) "28.00" [7]=> string(5) "35.00" [8]=> string(5) "28.00" [9]=> string(5) "28.00" [10]=> string(5) "28.00" [11]=> string(5) "28.00" [12]=> string(5) "28.00" [13]=> string(5) "35.00" [14]=> string(5) "35.00" [15]=> string(5) "28.00" [16]=> string(5) "28.00" [17]=> string(5) "28.00" [18]=> string(5) "35.00" } array(19) { [0]=> string(5) "13.00" [1]=> string(5) "25.00" [2]=> string(5) "13.00" [3]=> string(5) "13.00" [4]=> string(5) "13.00" [5]=> string(5) "13.00" [6]=> string(5) "13.00" [7]=> string(5) "25.00" [8]=> string(5) "13.00" [9]=> string(5) "13.00" [10]=> string(5) "13.00" [11]=> string(5) "13.00" [12]=> string(5) "13.00" [13]=> string(5) "25.00" [14]=> string(5) "25.00" [15]=> string(5) "13.00" [16]=> string(5) "13.00" [17]=> string(5) "13.00" [18]=> string(5) "25.00" } Here is the foreach: foreach ($values as $cell) { echo "<a href=\"".$link."\" class=\"".$class."\">" . $cell . "</a>"; } $class is supposed to be the first iteration of the array: Thursday, Saturday, Monday, etc. $link is supposed the be the second iteration of the array: http://www.mylink.com/... I can get the $cell data, but I cannot access the $link or $class values. Thank you so much for any help you can provide. ~SarahB
  9. Hi there, I've posted this at stackoverflow but did not receive any replies so far so I'd like to try here as well. ------ I have an array of variable dimensions and namings. Sometimes associative, sometimes partially. Sometimes just a single array, sometimes multiple dimensions. An example array is this: array(4) { ["name"]=> string(9) "Some Name" ["user"]=> array(2) { ["id"]=> int(1) ["msgs"]=> array(3) { [0]=> string(16) "My first message" [1]=> string(17) "My second message" ["folder"]=> array(2) { ["first"]=> string(13) "Some folder.." [1]=> string(17) "some other stuf.." } } } [0]=> string(17) "More random stuff" ["foo"]=> array(2) { [0]=> string(10) "more stuff" ["bar"]=> string(7) "The end" } } I would like to have a function that goes through every key and value pair and performs a function, without altering the structure of the array. In this case, I want to apply htmlspecialchars() with ENT_QUOTES on every key and value pair in the array while keeping the array itself intact structure wise. I have tried with array_walk_recursive and array_map, neither seem to do the trick. I'm pretty new to PHP but I tried the following function by messing about with how I think it should be done but it's obviously not working private function CreateErrorArray($array, $knownKeys=NULL) { if (is_array($array)) { foreach ($array as $key => $value) { if (is_array($value)) { if (is_null($knownKeys)) { $keys = array($key); $this->response['ERRORARRAY'][$key] = $this->CreateErrorArray($this->RequestClass->error[$key], $keys); } else { $keys = array_push($knownKeys, $key); $this->response['ERRORARRAY'][$key] = $this->CreateErrorArray($this->RequestClass->error[$knownKeys][$key], $keys); } } else { $this->response['ERRORARRAY'][$key] = $value; } } } }
  10. I need some help with a looping problem. In my example code below, I have two Mysql tables: tblDepRatesCats: ID | header | left_text | center_text | right_text | header_order tblRates_balance: id | depratecat | MinBalance | InterestRate | APY | suborder tblDepRatesCats.ID = tblRatesBalance.depratecat. For each row in tblDepRatesCats, there may be 0 or 1 or more rows in tblRates_balance. I'm trying to display the results of querying these tablesso that it shows each tblDepRatesCats data with the corresponding tblRates_balance data, but instead it is showing tblDepRatesCats so that if tblDepRatesCats row has 3 tblDepRatesCats rows associted with it, the tblDepRatesCats row is repeated 3 times with one row of tblDepRatesCats, It displays incorrectly like this: NOW Checking Accounts Minimum Daily Balance to Earn APY $1000 Super NOW Checking Account Minimum Daily Balance to Earn APY $2222 Super NOW Checking Account Minimum Daily Balance to Earn APY $2100 Super NOW Checking Account Minimum Daily Balance to Earn APY $2000 Below is my code. Extra echos included for clarity. I can't figure it out. Any help is appreciated. Thanks. <?php include ('connect.php'); error_reporting(E_ALL); $qry = mysql_query('SELECT DISTINCT tblDepRatesCats.*, tblRates_balance.* FROM tblDepRatesCats INNER JOIN tblRates_balance ON tblDepRatesCats.ID = tblRates_balance.depratecat ORDER BY tblDepRatesCats.header_order, tblRates_balance.suborder;'); $result = $qry or die ("Error:" . mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo ("<table width=\"98%\" border=\"0\" bgcolor:\"#ffffff\"><tr><td>"); echo ("" . $row["header"] . " <br><br>"); echo ("" . $row["left_text"] . " <br><br>"); echo ("</tr></td>"); echo ("<tr><td>"); echo ("" . $row["MinBalance"] . " <br><br>"); echo (" </tr></td>"); } ?>
  11. I've been away from PHP for awhile and need some help with a looping problem. In my example code below, I have two Mysql tables: tblDepRatesCats: ID | header | left_text | center_text | right_text | header_order tblRates_balance: id | depratecat | MinBalance | InterestRate | APY | suborder tblDepRatesCats.ID = tblRatesBalance.depratecat. For each row in tblDepRatesCats, there may be 0 or 1 or more rows in tblRates_balance. When results displayed, it should show each tblDepRatesCats row data followed by the related tblRatesBalance data (and the ability to add/edit more rates). My problem is that I can only get the first row of tblDepRatesCats and its relative tblRates_balance rows to appear. I can't figure out why it won't loop and show the other. You can view my test page here: http://www.bentleg.com/vieweditratecats7.php. My relevant test code is below. Thanks for any assistance. <form action="<? echo htmlentities($_SERVER['PHP_SELF']); ?>" name="Edit" method="POST"> <?php $sql = "select * from tblDepRatesCats order by header_order"; $result = $link->query($sql); while($row = mysqli_fetch_assoc($result)){ $ID[] = $row["ID"]; // for testing if(is_array($cattedid)){ echo "IS ARRAY"; }else{ echo"not array"; } echo implode(',',$ID); // end arrray test echo("<hr><input type=\"text\" name=\"ID[]\" value=\"" . $row["ID"] . "\"><p><tr><td>Category name/header text: <input type=\"text\" name=\"header$ID\" value=\"" . $row["header"] . " \" size=\"40\"> Order: <input type=\"text\" name=\"header_order$ID\" value=\"" . $row["header_order"] . "\" size=\"2\"><br> Left sub-text:<input type=\"text\" name=\"left_text$ID\" value=\"" . $row["left_text"] . "\" size=\"25\"> Center sub-text:<input type=\"text\" name=\"center_text$ID\" value=\"" . $row["center_text"] . "\" size=\"25\"> Right sub-text<input type=\"text\" name=\"right_text$ID\" value=\"" . $row["right_text"] . "\" size=\"25\"> <input type=\"checkbox\" name=\"delete_ids[]\" value=\"" . $row["ID"] . "\"> Mark to delete </p> <input type=\"submit\" name=\"editcat\" value=\"EDIT\"> </form> "); foreach ($ID as $new_depratecat) { $sql2="SELECT * FROM tblRates_balance where depratecat='$new_depratecat' ORDER BY suborder"; $result = $link->query($sql2); ?> <div style="width:90%;margin:auto;"> <form method="POST" id="new_depratecat"> <div id="itemRows"> Minimum Balance: <input type="text" name="add_MinBalance" size="30" /> Interest Rate: <input type="text" name="add_InterestRate" /> APY: <input type="text" name="add_APY" /> Order: <input type="text" name="add_suborder" size="2"/> << Add data and click on "Save Changes" to insert into db. <br> You can add a new row and make changes to existing rows all at one time and click on "Save Changes." New entry row will appear above after saving. <?php while($rates = mysqli_fetch_array($result)): ?> <p id="oldRow<?=$rates['id']?>"> Minimum Balance: <input type="text" name="MinBalance<?=$rates['id']?>" value="<?=$rates['MinBalance']?>" /> Interest Rate: <input type="text" name="InterestRate<?=$rates['id']?>" value="<?=$rates['InterestRate']?>" /> APY: <input type="text" name="APY<?=$rates['id']?>" value="<?=$rates['APY']?>" /> Order: <input type="text" name="suborder<?=$rates['id']?>" value="<?=$rates['suborder']?>" /> <input type="checkbox" name="delete_ids[]" value="<?=$rates['id']?>"> Mark to delete</p> <?php endwhile;?> </div> <p><input type="submit" name="ok" value="Save Changes"></p> </form>
  12. Hello, I have yet another problem I am trying to understand. The thing I don't get is the foreach loop. Here's my code. I have a function to get the posts from the db as follows: function get_posts($connection) { $posts = array(); $sql = "SELECT * FROM posts ORDER BY stamp DESC"; $result = mysqli_query($connection, $sql); while ($post = mysqli_fetch_object($result)) { $posts = array('body' => $post->body, 'stamp' => $post->stamp, 'post_id' => $post->id, 'user_id' => $post->user_id); } return $posts; } And I'm (incorrectly) using a foreach loop to display the results like this: $posts = get_posts($connection); foreach ($posts as $key => $value) { echo $posts['body'] . "<hr>"; } If I echo $posts['body'] I get the first record showing up 4 times. I've used var_dump($posts) to make sure it's an array, and it is, and it shows the same first record 4 times. Any idea? I'm currently re-reading http://www.php.net/manual/en/control-structures.foreach.php to try and understand this. Thanks, Andrei
  13. Hello, I have been starded using redbean. I have a really big table and want to select 5000 rows at time using redbean! I want only the rows where the field "status" IS NULL This is my code: $min = R::$c->begin()->addSQL('SELECT MIN(id)')->from('emailtable')->get('cell'); $max = R::$c->begin()->addSQL('SELECT MAX(id)')->from('emailtable')->get('cell'); for ($i = $min; $i < $max; $i = $i + 5000) { $x = $i; $y = $i + 5000; $select = R::$c->begin() ->addSQL(' SELECT * ') ->from('emailtable') ->where(" id >= ? AND id < ? AND status IS NULL ") ->put($x) ->put($y) ->get(); } Anyone know if this is the right way to go! Should i use: id >= ? AND id < ? AND status IS NULL or maybe i should use BETWEEN but not sure. My problem is The code above is sometimes selecting same id twice and that is what i do not expect! there for i ask if there is a other solution four the code above! All ides are welcome. It is really hard to find information about redbean/chunk/select/ example
  14. When using the following code: $yaxis=array(); $xaxis=array(); for ($i = 1; $i <= $number_of_entries; $i++) { $channel = $xml->xpath("//ns:BulkData[ns:Name='InternetGatewayDevice.LANDevice.1.WLANConfiguration.X_181BEB_ChannelDiagnostics.Result.{$i}.Channel']/ns:Value"); $channel = $channel[0]; $xaxis[]=$channel[0]; $apcount = $xml->xpath("//ns:BulkData[ns:Name='InternetGatewayDevice.LANDevice.1.WLANConfiguration.X_181BEB_ChannelDiagnostics.Result.{$i}.APcount']/ns:Value"); $apcount = $apcount[0]; $yaxis[]=$apcount[0]; } I get the following results for $xaxis and $yaxis arrays: print_r($xaxis); Array ( [0] => SimpleXMLElement Object ( [0] => 1 ) [1] => SimpleXMLElement Object ( [0] => 6 ) [2] => SimpleXMLElement Object ( [0] => 11 ) ) print_r($yaxis); Array ( [0] => SimpleXMLElement Object ( [0] => 3 ) [1] => SimpleXMLElement Object ( [0] => 8 ) [2] => SimpleXMLElement Object ( [0] => 6 ) ) What I am looking for is only the value of the nested array. Like this: print_r($xaxis); Array ( [0] => 1 [1] => 6 [2] => 11 ) print_r($yaxis); Array ( [0] => 3 [1] => 8 [2] => 6 ) How can I achieve this? Thanks for any help / suggestions!
  15. I have my program working but it needs an very bad improvement. How it works, my program turns each line in a .txt file it grabs into an array every time it executes code it loops back to open the .txt file again and turns it into an array now grabbing the second line and so forth. It's a 4 MB file but I came to the conclusion that the reason I'm having such a high server transfer rate up to GB's is because the server has to use a lot more to turn into a new array every time the file() command is used. I came up with an idea after 3 days of thinking that I should use the program to open up the file only once turning it into an area and just use all the arrays without reopening the file and creating a new one. I was thinking of doing this but not sure it will work. <?php $fetch_data = file('http://somesite.com/text.txt'); $x=1; $i=0 while($x<=80) { $data = $fetch_data[$i]; Execute some code $i++ $x++ } ?> Would this work looping each line in the file without creating a new array each time?
  16. Hello guys, I'm having trouble making a loop to display the data in a table, I need the loop to display a table with the following data: example: 1 2 3 1 2 3 4 5 6 4 5 6 7 8 9 My code: <?php echo '<table width="100%" border="1" cellspacing="0" cellpadding="0">'; $contador = 1; while ($contador <= 10) { if($contador % 2){ for($x=0;$x<2;$x++){ echo "<tr><td>Registro $contador</td>"; } }else{ echo "<td>Registro $contador</td></tr>"; } ++$contador; } echo '</table>'; ?> Help me!
  17. Hi I working a script which will get the contents of html files from a remote server. Then will store part of the data in an array for future use. I plan to use a loop in order to get the contents for all the files i want, but i have a problem and i need some help. If I execute the script at once, i'm sure that my IP will get banned from the remote server. I plan to get contents from more than 600 web pages in the same server, so remote server will ban my IP for sure. The only solution i can think is add a delay between each loop step. In other words tell to the script get the data for web page 1, store them in the array, wait some seconds and the start all over again for web page 2 etc. etc. I try "sleep: function but without success. Any ideas? Thank you
  18. i have a php page that is opened by a form. when opened it displays 100's of rows of data from a database. what i need to do is have the user click on some rows, using either a link or a checkbox or something and then submit to the database that "that row" is now "checked" or "flagged" or something. i added a column to the database "flag" with value 0 or 1. also it is preferable to remain on same page after the database update. what would be the best way to do this? -i have tried putting a checkbox in each row, but then i dont know how to build the query at the end to submit multiple rows (how to access each row's name/value) -i then considered making each row a form itself...but seems bulky. (as i write this and wait for advice, im going to try this method it actually seems the easiest) -i considered making each row a link....but then how do i submit a query from a link(using javascript?!)
  19. Fairly new to PHP and this is my first post on the site. Just wondered if anyone could help with a piece of code I am trying to get working. It sits inside a Wordpress loop and pulls your 10 latest thumbnails except for the most recent one (as I set the current latest post in an extra large header at the top of the page). The code is doing the job but I am having difficulty sizing the thumbnails: <?php query_posts('posts_per_page=10&offset=1'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php echo $the_query->the_post_thumbnail; ?> <?php if ( has_post_thumbnail($post->ID) ) { // check if the post has a Post Thumbnail assigned to it. the_post_thumbnail($post->ID); } ?> I also have this in my functions.php if ( function_exists( 'add_image_size' ) ) { add_image_size( 'posts-thumb', 220, 170 ); } When I replace ($post->ID) at the bottom of the first script with ( 'posts-thumb' ) the code works as it should and the thumbnails are re-sized but I am losing the ID information attached to the image. Is there a way to put the ( 'posts-thumb' ) snippet in without deleting any of the original code? Thanks.
  20. Hi, I am converting an adjacency table to a xml with this code (coming from phpfreaks, thank you Barand!) <?php $data = array( 1 => 0, 2 => 1, 3 => 1, 4 => 2, 5 => 3, 6 => 5 ); echo "<?xml version='1.0' encoding='iso-8859-1'?>\n"; echo "<tree id='0'>\n"; tree(0); echo "</tree>\n"; function tree ($parent, $level=0) { global $data; $children = array_keys($data, $parent); if ($children) foreach ($children as $kid) { $indent = str_repeat("\t", $level+1); echo "$indent<item text='$kid' id='$kid'>\n"; tree($kid, $level+1); echo "$indent</item>\n"; } } ?> Returning <?xml version='1.0' encoding='iso-8859-1'?> <tree id='0'> <item text='1' id='1'> <item text='2' id='2'> <item text='4' id='4'> </item> </item> <item text='3' id='3'> <item text='5' id='5'> <item text='6' id='6'> </item> </item> </item> </item> </tree> Which is inappropriately formatted for my purpose. I would need: <?xml version='1.0' encoding='iso-8859-1'?> <tree id='0'> <item text='1' id='1'> <item text='2' id='2'> <item text='4' id='4'/> </item> <item text='3' id='3'> <item text='5' id='5'> <item text='6' id='6'/> </item> </item> </item> </tree> All nodes with children should end with </item>, leafs without end with />). I included an else-statement, after the foreach, but that obviously only doubles the leafs. else { $leaf = $parent; $indent = str_repeat("\t", $level+1); echo "$indent<item text='$leaf' id='$leaf'/>\n"; } Including further if-statements, left me with a completely screwed xml. Now I run out of ideas how to check for leafs/children and handle them appropriately. Any help ist appreciated!
  21. Hey, so to display an image from a database I was using $id = addslashes($_REQUEST['id']); $image = mysql_query("SELECT * FROM store_image WHERE id=$id"); $image = mysql_fetch_assoc($image); $image = $image['image']; header("Content-type: image/jpeg"); echo $image; That worked fine to return an image via matching the id. But I want to get ALL images from the table.. I tried this: $image = mysql_query("SELECT * FROM store_image"); while($image = mysql_fetch_array($image)){ $image = $image['image']; header("Content-type: image/jpeg"); echo $image; } But did not work.. what am I doing wrong?
  22. Hi, I am not very good at PHP however I am trying to edit a php function for Magento. $categoryID = $this->getCategoryId(); //the value is like 7,3,6,9 $cats = explode(',', $categoryID); $collection = Mage::getModel('catalog/product') ->getCollection() ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left') ->addAttributeToSelect('*') ->addAttributeToFilter('category_id', array( array('finset' => '7'), array('finset' => '3'), array('finset' => '6'), array('finset' => '9') ) ); I want to generate the below part automatically based on the value(s) of $cats array('finset' => '7'), array('finset' => '3'), array('finset' => '6'), array('finset' => '9') How can I do it, urgent help will be extremely appreciated. Thanks in advance
  23. I have a multidimensional array like so. Array ( [0] => Array ( [0] => Yolo County Sheriff's Home 2008faroo [1] => http://www.yolosheriffs.com/ [2] => 86 ) [1] => Array ( [0] => Fremont, Yolo County, California - Wikipedia, the free encyclopediafaroo [1] => http://en.wikipedia.org/wiki/Fremont,_Yo… [2] => 11 ) [2] => Array ( [0] => The Lonely Island - YOLO (feat. Adam Levine & Kendrick Lamar) - YouTubefaroo [1] => http://www.youtube.com/watch?feature=pla… [2] => 45 ) What i need to do is find duplicate urls in this array, merge them together and combine the score found at [2]. I have scoured the php manual but I can't seem to find a way to merge the duplicate urls and then add the scores to the remaining url. Would it make it any easier to have it in the format Array ( [0] => Array ( [0] => Yolo County Sheriff's Home 2008faroo, array([0] => http://www.yolosheriffs.com/ ,[1] => 0) ) ?? All suggestions appreciated.I have looked at the manual but i don't have the knowledge at this stage to use the array functions in conjunction with foreach loops to achieve what i need.I
  24. Notice: Undefined variable: bing_results in /home/msc2012/12254822/public_html/safe_dir/Almost_Gs.php on line 295 Basically, its the 'Interleaving' case that does not work as the echoed variables are not recognized when run on the server but the IDE does not highlight them as errors so it recognizes them. If you pay attention further down the switch statement under other cases I use the same variable $bing_results where it works and is recognized by the server. The scenario is the same with $Blekko and $Google case 'Interleaving': $irl =0; while($irl <= 90) { echo 'hellooo!!'; echo '<a href ='.$bing_results[$irl]['url'].'><h5>'.$bing_results[$irl]['url_title'].'</h5></a><br>'; echo '<p>'.$bing_results[$irl]['snippet'].'</p><br>'; echo '<p>'.$bing_results[$irl]['rank'].'<p><br>'; echo '<b>'.$bing_results[$irl]['engine'].'</b><br>'; echo '<hr>'; echo '<a href ='.$Blekko[$irl]['url'].'><h5>'.$Blekko[$irl]['url_title'].'</h5></a><br>'; echo '<p>'.$Blekko[$irl]['snippet'].'</p><br>'; echo '<p>'.$Blekko[$irl]['rank'].'<p><br>'; echo '<b>'.$Blekko[$irl]['engine'].'</b><br>'; echo '<hr>'; echo '<a href ='.$google[$irl]['url'].'><h5>'.$google[$irl]['url_title'].'</h5></a><br>'; echo '<p>'.$google[$irl]['snippet'].'</p><br>'; echo '<p>'.$google[$irl]['rank'].'<p><br>'; echo '<b>'.$google[$irl]['engine'].'</b><br>'; echo '<hr>'; $irl++; } break; case 'Non-Aggregated': $nag_c=0; // non aggregated count while ($nag_c <=$blekko_count) { echo '<a href='.$Blekko[$nag_c]['url'].'><h4>'.$Blekko[$nag_c]['url_title'].'</h4></a>'; echo '<p>'.$Blekko[$nag_c]['snippet'].'<p>'; echo '<b>'.$Blekko[$nag_c]['engine'].'</b>'; echo '<hr>'; $nag_c++; } $nag_c =0; while ($nag_c <= $google_count) { echo '<a href='.$google[$nag_c]['url'].'><h4>'.$google[$nag_c]['url_title'].'</h4></a>'; echo '<p>'.$google[$nag_c]['snippet'].'</p><br>'; echo '<b>'.$google[$nag_c]['engine'].'</b><br>'; echo '<hr>'; $nag_c++; } $nag_c=0; while ($nag_c<=$bing_count) { echo '<a href='.$bing_results[$nag_c]['url'].'>'.'<h4>'.$bing_results[$nag_c]['url_title'].'</h4></a>'; echo '<p>'.$bing_results[$nag_c]['snippet'].'</p>'; echo '<b>'.$bing_results[$nag_c]['engine'].'</b>'; echo '<hr>'; $nag_c++; } case 'Bing': $binger = 0; while ($binger<=$bing_count) { echo '<a href='.$bing_results[$binger]['url'].'>'.'<h4>'.$bing_results[$binger]['url_title'].'</h4></a>'; echo '<p>'.$bing_results[$binger]['snippet'].'</p><br>'; echo '<b>'.$bing_results[$binger]['engine'].'</b><br>'; echo '<hr>'; $binger++; } break; case 'Blekko': $blekr = 0; while ($blekr<=$blekko_count) { echo '<a href='.$Blekko[$blekr]['url'].'><h4>'.$Blekko[$blekr]['url_title'].'</h4></a>'; echo '<p>'.$Blekko[$blekr]['snippet'].'<p>'; echo '<b>'.$Blekko[$blekr]['engine'].'</b>'; echo '<hr>'; $blekr++; } break; case 'Google': $froo = 0; while ($froo <=$google_count) { echo '<a href='.$google[$froo]['url'].'><h4>'.$google[$froo]['url_title'].'</h4></a>'; echo '<p>'.$google[$froo]['snippet'].'</p>'; echo '<b>'.$google[$froo]['engine'].'</b>'; echo '<hr>'; $froo++; } break; } ?>
  25. I am currently using the plugin WP-CommentNavi for comments pagination but whenever a page is clicked it goes to the highest comments page (oldest comments). My comments are purposely displayed newest first and therefore I need the default pagination page to be 1 whenever a link is clicked. I notice there is the same default for other pagination plugins too whereby the highest pagination page (ie if there are 5 pages) page 5 is displayed. At the moment when I load page tellhi####.com/newcastle the page that will be loaded is tellhi####.com/newcastle/comment-page-2/ whereas I want tellhi####.com/newcastle/comment-page-1/ to be loaded I can't be sure this is the relevant code to what I am trying to achieve but I feel the answer might lie in here (below). If not, please tell me and disregard this code. ### Function: Comment Navigation: Boxed Style Paging function wp_commentnavi($before = '', $after = '') { global $wp_query; $comments_per_page = intval(get_query_var('comments_per_page')); $paged = intval(get_query_var('cpage')); $commentnavi_options = get_option('commentnavi_options'); $numcomments = intval($wp_query->comment_count); $max_page = intval($wp_query->max_num_comment_pages); if(empty($paged) || $paged == 0) { $paged = 1; } $pages_to_show = intval($commentnavi_options['num_pages']); $pages_to_show_minus_1 = $pages_to_show-1; $half_page_start = floor($pages_to_show_minus_1/2); $half_page_end = ceil($pages_to_show_minus_1/2); $start_page = $paged - $half_page_start; if($start_page <= 0) { $start_page = 1; } $end_page = $paged + $half_page_end; if(($end_page - $start_page) != $pages_to_show_minus_1) { $end_page = $start_page + $pages_to_show_minus_1; } if($end_page > $max_page) { $start_page = $max_page - $pages_to_show_minus_1; $end_page = $max_page; } if($start_page <= 0) { $start_page = 1; } if($max_page > 1 || intval($commentnavi_options['always_show']) == 1) { $pages_text = str_replace("%CURRENT_PAGE%", number_format_i18n($paged), $commentnavi_options['pages_text']); $pages_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pages_text); echo $before.'<div class="wp-commentnavi">'."\n"; switch(intval($commentnavi_options['style'])) { case 1: if(!empty($pages_text)) { echo '<span class="pages">'.$pages_text.'</span>'; } if ($start_page >= 2 && $pages_to_show < $max_page) { $first_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $commentnavi_options['first_text']); echo '<a href="'.clean_url(get_comments_pagenum_link()).'" class="first" title="'.$first_page_text.'">'.$first_page_text.'</a>'; if(!empty($commentnavi_options['dotleft_text'])) { echo '<span class="extend">'.$commentnavi_options['dotleft_text'].'</span>'; } } previous_comments_link($commentnavi_options['prev_text']); for($i = $start_page; $i <= $end_page; $i++) { if($i == $paged) { $current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $commentnavi_options['current_text']); echo '<span class="current">'.$current_page_text.'</span>'; } else { $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $commentnavi_options['page_text']); echo '<a href="'.clean_url(get_comments_pagenum_link($i)).'" class="page" title="'.$page_text.'">'.$page_text.'</a>'; } } next_comments_link($commentnavi_options['next_text'], $max_page); if ($end_page < $max_page) { if(!empty($commentnavi_options['dotright_text'])) { echo '<span class="extend">'.$commentnavi_options['dotright_text'].'</span>'; } $last_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $commentnavi_options['last_text']); echo '<a href="'.clean_url(get_comments_pagenum_link($max_page)).'" class="last" title="'.$last_page_text.'">'.$last_page_text.'</a>'; } break; case 2; echo '<form action="'.admin_url('admin.php?page='.plugin_basename(__FILE__)).'" method="get">'."\n"; echo '<select size="1" onchange="document.location.href = this.options[this.selectedIndex].value;">'."\n"; for($i = 1; $i <= $max_page; $i++) { $page_num = $i; if($page_num == 1) { $page_num = 0; } if($i == $paged) { $current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $commentnavi_options['current_text']); echo '<option value="'.clean_url(get_comments_pagenum_link($page_num)).'" selected="selected" class="current">'.$current_page_text."</option>\n"; } else { $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $commentnavi_options['page_text']); echo '<option value="'.clean_url(get_comments_pagenum_link($page_num)).'">'.$page_text."</option>\n"; } } echo "</select>\n"; echo "</form>\n"; break; } echo '</div>'.$after."\n"; } } In short I need, anytime a page is clicked, for the comments pagination to be on page 1, not the highest page available. Just so you know I have tried the discussion settings on the wordpress dashboard. Nothing on google either! Failing a full answer, does anyone know the actual php code that determines what pagination page is loaded by default? I received this response via an e-mail but due to my PHP knowledge am unable to implement it, any ideas? ... Just reverse the loop. That'll fix it. Here's the relevant part: http://pastie.org/8166399 You need to go back, i.e. use $i-- Hope I have been clear in my question! Thanks in advance, Paul
×
×
  • 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.