Jump to content

Search the Community

Showing results for tags 'limit'.

  • 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 (Dreamweaver, Zend, 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

Found 10 results

  1. I have a query below where I want to search a table to find the top row with 1 or 2 empty positions. But it never returns the correct "referral_id". If I remove the "ref_user_1" and "ref_user_2" conditions from the query, then of course it will return the correct referral id. But those conditions are important for me to have. Is having "AND" and "OR" conditions in the same query against the rules? If so what's the solution for this problem? $find_sponsor = $db->prepare("SELECT * FROM referrals WHERE referred_by = :referred_by AND ref_user_1 = :ref_user_1 OR ref_user_2 = :ref_user_2 ORDER BY referral_id ASC LIMIT 1"); $find_sponsor->bindValue(':referred_by', 2); $find_sponsor->bindValue(':ref_user_1', 0); $find_sponsor->bindValue(':ref_user_2', 0); $find_sponsor->execute(); $result_sponsor = $find_sponsor->fetchAll(PDO::FETCH_ASSOC); if(count($result_sponsor) > 0) { foreach($result_sponsor as $row) { $get_referral_id = $row['referral_id']; $get_ref_1 = $row['ref_user_1']; $get_ref_2 = $row['ref_user_2']; } echo $get_referral_id; // this always returns the wrong referral id } // Table referral_id referred_by ref_user_1 ref_user_2 1 2 20 21 2 2 23 24 3 2 25 0 4 2 0 0 As per my table above, what would my new query look like if I want to retrieve #3 as my referral id?
  2. i am creating a responsive website. I'll give you an example. I am retriving 100 items from mysql database using php. I am only showing 20 items per page using simple pagination with arrows. I keep this format on desktop and tablets. However, I would like to show less items when I am viewing the page on a smartphone. So instead of 20 items per page, it'll show 5 items per page along with the pagination arrows. I was wondering if this is possible with PHP or would I have to use javascript?
  3. Hi All, I'm looking to update a mysql column weekly, where by 5 randomly selected rows are given a new random number, from between 1 and the num_rows / 5. This cycle is looped again until all the entries have a new random group for the week. It is to help mix up the players for teams for 5 aside. It needs to be able to accomodate the posibillity of the num_rows not dividing exactly by 5, using ceil perhaps? As an example Name Group a 1 b 2 c 1 d 1 e 1 f 3 g 2 h 1 i 2 j 2 k 2 Then Next week Name Group a 2 b 1 c 2 d 2 e 1 f 2 g 3 h 1 i 2 j 1 k 1 I hope that makes sense. It'll be automated via cron job. I've been really struggling with it, this is as far as I have got. $totalgroupsraw = $num_rows /5; $totalgroups = ceil ($totalgroupsraw); $i = 1; while ($i<$totalgroups) { $pie = mysql_query("UPDATE table SET columnname=5 order by rand() LIMIT 5"); $i++; }; But as you will no doubt be able to see, this doesn't work well at all. I think I am close, but I just can't seem to sort out a good way to do it. Any help much appreciated. Thanks, Matt
  4. Hey guys, I'm trying to limit my query to 5 results, but TOP is not working and LIMIT obviously does not work (I usually work with MySQL). Here is my query: $query = "SELECT PERSON.PERSON_ID, PERSON.LAST_NAME, PERSON.FIRST_NAME FROM PERSON where PERSON.LAST_NAME like '%$q%' or PERSON.FIRST_NAME like '%$q%' order by PERSON.LAST_NAME"; Can someone please point me in the right direction for limiting the query to 5 results? Thank you! ~ Sarah
  5. I have my website paginating files that are shown onscreen. How can I make it so the page only loads the first page's files and then when going on to the next page, it loads the files on that page? Basically what I am trying to do is reduce load time by not loading the files on the pages after page one until the user actually goes to a page after page one. index.php <?php $current_page = isset($_GET['page']) ? intval($_GET['page']) : 1; $items_per_page = 10; $offset = ($current_page - 1) * $items_per_page; $items = glob("entries/*.php"); $total_items = count($items); $total_pages = ceil($total_items / $items_per_page); foreach (array_slice($items, $offset, $items_per_page) as $entry) { include $entry; } echo "<table summary=\"\" cellpadding=\"10\" cellspacing=\"0\" border=\"0\" class=\"global-links-menu\"><tr>"; if($current_page != 1) { $back_page = $current_page - 1; echo "<td ><p><a href='?page=$back_page'>Back</a></p></td>"; } else { $back_page = $current_page - 1; echo "<td ><p></p></td>"; } for($j=1;$j<=$total_pages;$j++) { if($j==$current_page) { echo "<td ><p>$current_page</p></td>"; } else { echo "<td ><p><a href='?page=$j' title='Page $j'>$j</a></p></td>"; } } if($current_page <= $total_pages - 1){ $next_page=$current_page+1; echo "<td ><p><a href='?page=$next_page'>Next Page</a></p></td>"; } else { echo "<td ><p></p></td>"; } /* foreach (glob("entries/*.php") as $filename) { include $filename; } */ ?> </table>
  6. My website is on a free host that not only limit the storage space, like many do, but also limit the processing. It happened to me a few times in the past that my website was temporarily replaced by a parking space for a day or less. Luckily it's just a homepage and most (all?) things on it are not urgently needed. The CMS my site use has a throttling function but I have some directories not covered by the CMS. In one of those there's a ¨H¨which process just fine. The issue is if it was accessed too often, the processing it take might very well shutdown my homepage. Something on my favor: the script only need to be interpreted once in a little while ; once a day should do. A;so if the PHP is not accessed, there's no need to run it anyway ; it's not like some external process (ie: feed aggregator) would fetch content it generated è if the page is not directly accessed, there's no need to interpret it, be it months. Is there a way to limit the processing used by a PHP? Perhaps limiting the number of daily uses. Thank you kindly for your help
  7. another beginners question from yours truly but i was just wondering how i would code a character limit on one of my fields iv been around the internet but i cant find what i need cause i usually come up with the same error code each time. if anyone knows what to do that would be great, hears the code iv been using. <?php $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // define variables and set to empty values $companyname = $firstname = $address1 = $address2 = $area = $city = $postcode = $email = $website = $clubphone = $homephone = $mobilephone = $typeofbusiness = $renewaldate = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $errors = array(); if (empty($_POST["companyname"])) { $errors['companyname'] = "Please Enter Your companyname"; } <input type='text' name='keywords' size='60' value='companyname' maxlength='10' /> elseif(strpos($_POST['companyname'], '/') !== false) { $errors['companyname'] = 'Cannot use /'; } elseif(strpos($_POST['companyname'], 'The') !== false) { $errors['companyname'] = 'Company Names cant start with The'; } elseif(strpos($_POST['companyname'], 'the') !== false) { $errors['companyname'] = 'Company Names cant start with the'; } elseif(strpos($_POST['companyname'], 'THE') !== false) { $errors['companyname'] = 'Company Names cant start with THE'; } else { $companyname = test_input($_POST["companyname"]); } and heres the error code ive been getting. ( ! ) Parse error: syntax error, unexpected '<' in C:\wamp\www\AddLeads\addeadstemplate.php on line 29 aswell as this if i remove this symbol i get one to do with the else if statement witch i kinda need. again if anyone has a solution please get back to me soon as
  8. Can anyone see why my results would return more than 20 rows? $query = "SELECT * FROM mailer "; $limit = "ORDER BY id LIMIT 20 "; $result = mysql_query($query.$limit); if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } $address = 0; while ($row = mysql_fetch_assoc($result)) { $id=$row["id"]; $email=$row["email"]; $companyID=$row["companyID"]; }
  9. Im creating an online ordering form for a large selection of items, about 1700. Displaying my form works perfect, but when I receive the information and try and get the post variables It stops after 330. If I start my counter at 300, it stop at 630, so there must be a limit of 330 post variables, anyone ever run into this? I'll try and post some code snippets // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } //This query will return about 1700 results $result = mysqli_query($con,"SELECT * FROM formatted"); $a = 0; $currentCategory = ""; $status = "begin"; while($row = mysqli_fetch_array($result)) { echo $_POST['qty' . $a]; if(isset($_POST['qty' . $a]) && ($_POST['qty' . $a] != 0)) { $qty = $_POST['qty' . $a]; $ttl = $qty * substr($row['price'],1); if($currentCategory != $row['subcategory']) { $customerInfo .= '<tr><th colspan = "7" style="background-color: #104E8B; color: #FFF;">' . $row['subcategory'] . '</th></tr>'; $currentCategory = $row['subcategory']; } $customerInfo .= '<tr> <td>' . $row['size'] . '</td> <td>' . $row['description'] . '</td> <td>' . $row['upc'] . '</td> <td>' . $qty . '</td> <td>' . $row['price'] . '</td> <td>' . $ttl . '</td> <td>' . $_POST['notes'] .'</td> </tr>'; $currentCategory = $row['subcategory']; } $a++; } echo '</table>'; mysqli_close($con);
  10. Hi, I can't figure out how to limit the word count fetched from the database. I simply want to show 10 words from the 'body' column. I'm using the below echo code to display the information. echo '<div class="menu"><div class="item">'; echo '<h1><a href="news/display/'.$row['id'].'">'.$row['title'].'</a></h1>'; echo '<img src="../'.$row['image'].'"/>'; echo '<p>'.$row['body'].'</p>'; echo '</div></div>'; Any help is appreciated. Thanks.
×
×
  • 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.