Jump to content

simcoweb

Members
  • Posts

    1,104
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.phpfreaks.com

Profile Information

  • Gender
    Not Telling
  • Location
    CA

simcoweb's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Greetings. I'm using a newsletter subscription plugin that doesn't have parameters for making fields required (don't ask why). The system is connected to Mailchimp but because the first and last names are not 'required' many of the submissions have been email address only. I found this JQuery snippet that validates that the 'first name' field is populated before submission. The problem is I need the 'last name' field validated as well. I played around with the code but my syntax knowledge is really rusty and the two ways I tried to add that field into the mix failed. Here's the code: <script type="application/javascript"> (function($) { $(document).ready(function() { $(" .et_bloom_submit_subscription").click(function(){ if ($('.et_bloom_submit_subscription').closest('.et_bloom_form_container').find('.et_bloom_subscribe_name input').attr('value') == '') { $('.et_bloom_submit_subscription').closest('.et_bloom_form_container').find('.et_bloom_subscribe_name input').addClass('et_bloom_warn_field'); return false; } else { $('.et_bloom_submit_subscription').closest('.et_bloom_form_container').find('.et_bloom_subscribe_name input').removeClass('et_bloom_warn_field'); } }); }); })(jQuery) </script> The last name field class is .et_bloom_subscribe_last which I tried splicing in a various ways but it didn't work. Can anyone provide the proper syntax to add this into the mix so that the 'warn_field' covers it as well? Thank you in advance.
  2. Greetings. I'm using the Divi theme from Elegant Themes for a new magazine style project. The theme does not display the caption for any of its image related modules and the featured image that displays in the posts as the thumbnail does not. We need the caption to display for legal reasons since it will attribute the source of the image. Here's the code they use for their theme display in the single.php file: } else if ( ! in_array( $post_format, array( 'gallery', 'link', 'quote' ) ) && 'on' === et_get_option( 'divi_thumbnails', 'on' ) && '' !== $thumb ) { print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height ); echo wp_kses_post(get_post(get_post_thumbnail_id())->post_excerpt); } else if ( 'gallery' === $post_format ) { et_pb_gallery_images(); } Basically this is a custom function instead of using the standard Wordpress function. I searched around the Wordpress plugin repository and found someone who posted this code as a possible fix: <div class="et_post_meta_wrapper"> ... <?php if (get_post(get_post_thumbnail_id())->post_excerpt) { // search for if the image has caption added on it ?> <div class="featured-image-caption"> <?php echo wp_kses_post(get_post(get_post_thumbnail_id())->post_excerpt); // displays the image caption ?> </div> <?php } ?> </div> <!-- .et_post_meta_wrapper --> The problem is, where he says to insert this (just before the closing </div> tag for the wrapper, ) the caption displays at the bottom of the page, not underneath the featured image. I'm thinking that this code can be adapted to the same section of the code I posted above so that it all works as one unit in summoning the thumbnail and the caption. However, my PHP skills are not up to speed in order to conjure up the correct syntax for merging these two. Any help would be greatly appreciated. Thanking everyone in advance!
  3. He shoots...he SCORRRRRRRRRES! :) Ok, akitchin...that was the code 'tweak' needed for that part. Huggie, adding the category id to the link was the other part of the puzzle. Independently they wouldn't work. Collectively they do. Here's what I did: * changed the COUNT code to what akitchin provided with 'mysql_result' instead of 'mysql_num_rows' * changed the display of the total results from $num_rows (which actually returned the correct amount, by the way) to $total_results * added Huggie's categoryid=$cat_id& to the URL string Now I get 14 results, 5 per page, and the pagination displays properly and each page has the specified number of results (5 or less) Take a look: [url=http://www.plateauprofessionals.com/category-page2a2.php?categoryid=4]http://www.plateauprofessionals.com/category-page2a2.php?categoryid=4[/url] Whew! Time for a beer...even though it's 7:30 am :)  Thanks for the help, gentlemen! Just a note of interest... pagination is  a BIG topic in the forums. This code works and is easy to implement. I'm going to modify the title a bit to reflect 'pagination' so it can possibly help others.
  4. I'm emailing you a Valium. :) It's not that complicated. Here's the whole thing in a nutshell: 1) Yes, it should show 5 per page and not 14. It's set to show 5 per page. 2) But, it's showing the first 5 only and the subsequent pages show 0. Meaning it's only showing a total of 5 results and not the 14 in 3 successive pages ( Page1 | Page 2| Page 3) as it should 3) I don't want it to show just 5 total results. I want it to show 14 total results but on 3 pages (hence the pagination) 4) Category ID 4 has 14 members in it. Not 5. Therefore it should show 3 pages of results based upon the fact we have it set for 5 results per page. Period. 5) I HAVE inserted your category id code into the script and uploaded it to the server and that's what is currently located at this link: [url=http://www.plateauprofessionals.com/category-page.php?categoryid=4]http://www.plateauprofessionals.com/category-page.php?categoryid=4[/url] Note the fact that it shows 5 results and NO page link to go to results 6-10 (page 2) or 11-14 (page 3). THAT is the problem. The code is EXACTLY as you posted it. I copied and pasted your post directly into my page. No deviations...no edits...exactly.
  5. That definitely got rid of the error. Must've been a brain fart. Unfortunately it's still not paginating correctly. It just wants to display 5 results when there's 14 in the category. :(
  6. Yes, I get this error message: [quote]Fatal error: Call to undefined function: mysql_num_results() in /home2/wwwplat/public_html/category-page2a2.php on line 24[/quote] That's this: [code]$total_results = mysql_num_results($result);[/code]
  7. Acutally the category id IS being passed in the URL as you can see in my example links: [url=http://www.plateauprofessionals.com/category-page2a.php?categoryid=4]http://www.plateauprofessionals.com/category-page2a.php?categoryid=4[/url] The other link was not category specific and was pulling all the results from the entire database regardless of the category. If you use that link you'll see it pulls 14 results from that category but does not put 5 per page and create the page links. If I take the two variables out in the LIMIT clause then it displays the links to the other pages but still shows 14 on the first page and states the others have 0. Here's an example of that: [url=http://www.plateauprofessionals.com/category-page2a2.php?categoryid=4]http://www.plateauprofessionals.com/category-page2a2.php?categoryid=4[/url] In the first link, note that it displays Page 1 | Page 2 | Page 3 . This is because the $row_count = 14 and it's created the links to the other pages to accommodate results 6 -10 and 11 -14. Even though it displays '5 results found' which is incorrect and stating that because of the LIMIT clause. But when you click on them there's 0 found. The pagination is fine but the results are not. Now, without the LIMIT clause in example 2 removed you see all 14 results on the first page, pagination to pages 2 & 3..but no results there. The quest is to have 1-5 show on the first page, 6-10 on the 2nd, and 11-14 on the 3rd.
  8. HuggieBear, the server was down when you tried it. It's working if you want to try it again now. Here's the code now: [code]include 'dbconfig.php'; include 'header.php'; //connect to db mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $cat_id = is_numeric($_GET['categoryid']) ? $_GET['categoryid'] : 0; // Double check for a valid value // If current page number, use it // if not, set one! if(!isset($_GET['page'])){     $page = 1; } else {     $page = $_GET['page']; } // Define the number of results per page $max_results = 5; // Figure out the limit for the query based on the current page number. $from = (($page * $max_results) - $max_results); // Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT(*) FROM members_cat WHERE categoryid='{$cat_id}'"),0); // Figure out the total number of pages. Always round up using ceil() $total_pages = ceil($total_results / $max_results); // Grab data from plateau_pros, where the member has the specified category id $sql = "SELECT p.* FROM members_cat c, plateau_pros p WHERE c.categoryid='$cat_id' "         . "AND c.memberid=p.memberid LIMIT $from, $max_results"; $results = mysql_query($sql) or die(mysql_error()); $num_rows = mysql_num_rows( $results ); echo "<font class='bodytext'>There are <b>$num_rows</b> professionals in this category</font><br><br>\n"; // Build Page Number Hyperlinks echo "<center>Select a Page<br />"; for($i = 1; $i <= $total_pages; $i++){     echo " | ";     if(($page) == $i){         echo "Page $i ";         } else {             echo "<a class=\"body\" href=\"".$_SERVER['PHP_SELF']."?page=$i\">Page $i</a> ";     } } echo "</center>"; if (empty($results)) {   echo "No profiles found in this category."; } else { while ($a_row= mysql_fetch_array($results)){[/code] Here's the same pagination code being used in another page on the site but does not include the WHERE clause in the query. It works perfectly: [code]// test to display addbiz results header ("content type: image/gif"); header ("content type: image/jpeg"); header ("content type: image/png"); include 'config.php'; include 'header.php'; $upload_dir = "http://www.plateauprofessionals.com/images/photo"; mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); // If current page number, use it // if not, set one! if(!isset($_GET['page'])){     $page = 1; } else {     $page = $_GET['page']; } // Define the number of results per page $max_results = 5; // Figure out the limit for the query based // on the current page number. $from = (($page * $max_results) - $max_results); $sql=("SELECT * FROM plateau_pros ORDER BY memberid LIMIT $from, $max_results"); $result = mysql_query($sql) or die(mysql_error()); $mysock = getimagesize($image); $setWidth = 125; function imageResize($width, $height, $target) { $newHeight = 0; $newHeight = ($setWidth * $height) / $width; return "width='{$setWidth}' height='{$newHeight}'"; } // Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM plateau_pros"),0); // Figure out the total number of pages. Always round up using ceil() $total_pages = ceil($total_results / $max_results); // Build Page Number Hyperlinks echo "<center>Select a Page<br />"; for($i = 1; $i <= $total_pages; $i++){     echo " | ";     if(($page) == $i){         echo "Page $i ";         } else {             echo "<a class=\"body\" href=\"".$_SERVER['PHP_SELF']."?page=$i\">Page $i</a> ";     } } echo "</center>"; while ($row = mysql_fetch_assoc($result)) {[/code] And here's a peek at how it works perfectly: [url=http://www.plateauprofessionals.com/display-page.php?page=1]http://www.plateauprofessionals.com/display-page.php?page=1[/url] Hopefully you can spot something. Thanks for your help!
  9. Ok, I see what you've pointed out and I removed the duplicate query. However, here's the continuing problem. The pagination code requires these two variables placed into the main query for the data: [code]// Grab data from plateau_pros, where the member has the specified category id $sql = "SELECT p.* FROM members_cat c, plateau_pros p WHERE c.categoryid='$cat_id' "         . "AND c.memberid=p.memberid LIMIT $from, $max_results";[/code] The $from and $max_results are the two. When I do this it sets the query limit to '5' which is not what I want. I want the query to go ahead and pull all matching data...which should be 14 results for category 4. The 'LIMIT' clause is overriding this and displays just 5 results on the first page then 0 on the next two pages. If I take those variables out of the query then I get all 14 on the first page and 0 on the next two pages. The pagination code still displays Page1 | Page 2 | Page 3 but when you click on 2 or 3 it displays "0 Results Found" when, in fact, there should be 5 results per page as the $max_results variable would dictate. Visit that url and you'll see what I mean. I know this is just a 'tweak' where the query or a variable needs to be replaced or changed. But I can't figure it out.
  10. Yeah, that space is gone. Here's the whole batch of code. Perhaps it just needs a tweak in order for the pagination to work properly in a situation where the WHERE clause is present. Like I mentioned, I have this pagination working perfectly on a set of pages that does not specify a WHERE clause in the query. That's the only difference between the two. Here's the code: [code]if(!isset($_GET['page'])){     $page = 1; } else {     $page = $_GET['page']; } // Define the number of results per page $max_results = 5; // Figure out the limit for the query based on the current page number. $from = (($page * $max_results) - $max_results); // Grab data from database, where the member has the specified category id $sql = "SELECT p.* FROM members_cat c, plateau_pros p WHERE c.categoryid='$cat_id' "         . "AND c.memberid=p.memberid"; $results = mysql_query($sql) or die(mysql_error()); $num_rows = mysql_num_rows( $results ); echo "<font class='bodytext'>There are <b>$num_rows</b> professionals in this category</font><br><br>\n"; // If current page number, use it // if not, set one! // Figure out the total number of results in DB: $results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM members_cat WHERE categoryid='{$cat_id}'"),0); $total_results = mysql_num_rows( $results); // Figure out the total number of pages. Always round up using ceil() $total_pages = ceil($total_results / $max_results); // Build Page Number Hyperlinks echo "<center>Select a Page<br />"; for($i = 1; $i <= $total_pages; $i++){     echo " | ";     if(($page) == $i){         echo "Page $i ";         } else {             echo "<a class=\"body\" href=\"".$_SERVER['PHP_SELF']."?page=$i\">Page $i</a> ";     } }[/code] Basically if I call the script and extend the URL to include the category ID then it displays the proper number of results but it doesn't paginate them. I have pagination set for 5 per page. The results yields 14 members and provides links to 3 pages (at 5 each) but still displays all 14 on the first page and the other pages are blank. Check it out: [url=http://www.plateauprofessionals.com/category-page2a.php?categoryid=4]http://www.plateauprofessionals.com/category-page2a.php?categoryid=4[/url]
  11. Ok, I see the ' ' and have tried those as well but still get the same error: [quote]Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home2/wwwxxxx/public_html/category-page2a.php on line 25[/quote] I'm using this same code (which is for pagination) in another page and it works fine. However, it does not have the WHERE clause in it. Here it is: [code]$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM plateau_pros"),0);[/code]
  12. When you say it works... what do you get? I just get errors as posted.
  13. Yeah, getting the $cat_id from: [code]$cat_id = is_numeric($_GET['categoryid']) ? $_GET['categoryid'] : 0;[/code] Also, I did try that slight modification of the query code you suggested already and produced the same error.
  14. I'm trying to get a count of results from a database containing category ids so I can set this variable for the pagination. It keeps giving me an error and, to me, the query looks fine: [code]// Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT (*) as Num FROM members_cat WHERE categoryid={$cat_id}"),0);[/code] [quote]Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home2/wwwxxxx/public_html/category-page2a.php on line 24[/quote] Help?
  15. roopurt, thanks for the post. I think we're getting closer. Here's what it produces: this line: [quote]$cat_id = ValidateCatID($_GET['categoryid']);[/quote] gets this error: [quote]Fatal error: Call to undefined function: validatecatid() in /home2/wwwplat/public_html/category.php on line 9[/quote]
×
×
  • 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.