Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,352
  • Joined

  • Days Won

    173

Everything posted by mac_gyver

  1. the $pagenum variable doesn't exist. the ?pagenum parameter in the url would be available to the php code as $_GET['pagenum']
  2. in general, you wouldn't put derived values into a database, but assuming your code is just an example/exercise, you didn't show us the code that's making an instance of your cal class and calling the ->insert() method. also, you should not be using the msyql_ database functions because they are obsolete and will be removed in a future php version, which is interesting because at least one of your earlier threads in this forum was using the mysqli_ database functions.
  3. for your auto predict, it sounds like are asking about a wild card search, that starts with whatever has been entered upto that point, but should match anything after whatever has been entered. if so, you would add an * on the end of the search term. btw - this is all covered in the documentation, which jazzman posted a link to.
  4. the MATCH(city,Countryname) AGAINST ('South shields*' IN BOOLEAN MODE) term produces a relevancy score (a positive (true) value for matches, a zero for non-matches). you need to include this term in your SELECT term (give it an alias name of score) and then use ORDER BY score DESC in your query.
  5. for your database tables, you should have a category table, with a category id and the category name (i.e. Shirts, Jackets, Long Sleeves, Raglan, Pants, Shorts, Boxers and etc) and an item table, with an item id, category id, item name, and item description. you would also have only one transaction history table. as to "helping me on connecting to the database, adding a database/tables", that is basic, prerequisite, information that you would be expected to learn first before you attempt to design any code that requires the use of a database.
  6. if ($wp->query_vars[$this->namespace.'_p'] == 1){ $args['posts_per_page'] = 10; $args['offset'] = 0; }else{ $args['posts_per_page'] = 40; $args['offset'] = 10; } the meaning of that code is: if you are on page 1 of the pagination, show 10 posts per page, start with the first overall post. if you are not on page 1 of the pagination, show 40 posts per page, start with the 10'th overall post (i.e. skip the 10 that were displayed on page 1.) this was done so that the first page shows less total information, resulting in pagination with two different number of posts per page, i.e. 10 on the first page, 40 on all other pages. you would not add code for each possible page. you would only change that code if you want to alter the number of posts per page, i.e. to make all pages have the same number of posts per page or to change the number of posts on the first page to be for example 5, while the number of posts on the rest of the pages are 40 per page. here is the documentation for the $args parameters (the Pagination Parameters are about half-way down on the page) - http://codex.wordpress.org/Class_Reference/WP_Query#Parameters if your pagination isn't working, there's some other problem then the specific code in your post above.
  7. cyberRobot, posts by new members are currently fully moderated and could magically appear when approved. as to what Barand observed, i have no specific info as to what caused it.
  8. for a prepared query, the only code that would be inside the loop are the statements setting the bound variables with each set of data and the $stmt->execute();.
  9. check your web server error log to see if there is more information. i suspect a permission problem for the folder(s), i.e. the user the web server is running under doesn't have permission to access the needed folders.
  10. this is called a 'chained select'. you can do it using mostly php (the first select menu choice is submitted to the server and php retrieves the relevant data and builds the second select menu) or any combination of php/javascript. for the solutions using javascript, for a relatively small amount of total data, you can output all the data on the page (as a javascript array or object) when the page is requested and use javascrpt to populate of the second select menu as needed or you can use ajax to retrieve the relevant data from the server on demand to populate the second select menu.
  11. the single-quotes around the 'abcd' value in your first query have significance to the query. they indicate literal string data. you need to use that same syntax in the query for the case where php is supplying the string data value.
  12. when you retrieve the data from a database query, you can do anything you want with the data.
  13. the goal for your code would be to use a data driven design, where you have data defined somewhere (a database table, array) that tells one small set of code what to do and how many times to do it. here's an example of your form code that takes only about 1/10 the number of lines of code (this doesn't retrieve the fan data from the table as that's a trivial task) - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> <html> <head> <title>Ventilation Calculator Input</title> <meta id="meta" name="viewport" content="width=device-width; initial-scale=1.0"> <style type="text/css"> div { font-family: "tahoma"; font-weight: "bold"; font-size: "24pt" } table { text-align: center; } table { border: 1px solid black; border-collapse: collapse; } td { border: 1px solid black; } .right { text-align: right; } .left { text-align: left; } </style> <script language="JavaScript" type="text/javascript"> function validate(evt) { var theEvent = evt || window.event; var key = theEvent.keyCode || theEvent.which; key = String.fromCharCode( key ); var regex = /[0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } </script> </head> <body> <div> <form id="form" name="form" action="http://www.swinevetcenter.com/tools/ventresults.php" method="post"> <b><h1>Ventilation Calculator</h1></b> <b><span >Pig Info:</span></b><br /> Number of pigs in the barn:<br> <input id="pigNumber" name="pigNumber" type="text" size="10" onkeypress='validate(event)'> <br> <br> <?php mysql_connect('db', 'un', 'pw'); mysql_select_db('un'); // stage 1 fans 9" 10" 14" 16" 18" 20" 24" 36" 48" 50" 52" 54" $stage1_fans = array(9,10,14,16,18,20,24,36,48,50,52,54); // this apparently your fan.csv data // barn fans 9" 10" 18" 20" 24" 36" 48" 50" 52" 54" $barn_fans = array(9,10,18,20,24,36,48,50,52,54); $category['stage1'] = array('legend'=>'Stage 1','sizes'=>$stage1_fans); $category['barn'] = array('legend'=>'Barn','sizes'=>$barn_fans); // produce option list 0-10 $num = range(0,10); $options = ''; foreach($num as $val){ $options .= "<option value='$val'>$val</option>\n"; } // pig weight $sql = "SELECT weight FROM cfm ORDER BY weight"; $result = mysql_query($sql); echo "<p><b>Pig Weight</b><br>"; echo "<select weight='weight' name='weight' id='weight'>"; while ($row = mysql_fetch_array($result)) { echo "<option value='" . $row['weight'] . "'>" . $row['weight'] . "</option>"; } echo "</select>"; ?> <br> <br> <b>Fan Info</b> <?php foreach($category as $key=>$arr){ ?> <table> <tr> <td colspan="<?php echo count($arr['sizes'])+1;?>" class="left"><b>Select Size and Number of <?php echo $arr['legend']; ?> Fans</b></td> </tr> <tr> <td class="right">Fan Size</td> <?php foreach($arr['sizes'] as $val){ echo "<td >$val\"</td>"; } ?> </tr> <tr> <td class="right">Number of <?php echo $arr['legend']; ?> Fans</td> <?php foreach($arr['sizes'] as $val){ echo "<td ><select name='{$key}[$val]'>"; echo $options; echo "</select></td>"; } ?> </tr> </table> <br /><br /> <?php } ?> <br /> <input id="submit" name="submit" type="submit" value="Submit" method="post"> </form> </div> </body> </html> other than reducing the amount of code, the only significant change in the above is to name the form fields as an array that you can loop over to process the submitted data. the code you posted has two different sets of fan sizes. is this intentional or should the list of 'Barn' fan sizes be the same as the 'Stage 1' fan sizes?
  14. Please use the forum's bbcode tags (the edit form's <> button) around code when posting it in the forum. i modified your post above.
  15. i'm guess that you mean you tried using generated buy now/add to cart/check out buttons and you would like to change this so that the cart is built on your site, with the contents being stored in a database, then when the cart is finalized, you display the complete cart contents in a form that paypal expects, with a check out button that takes the visitor to the paypal site to finalize the order? if so, you would write (or find a script) to implement the cart on your site, then see the paypal cart upload command to submit the cart information and take the visitor to the paypal site - https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/cart_upload/
  16. it would probably help if you posted the code you tried, using the forum's bbcode tags.
  17. and as mentioned in a previous thread, you are not specifying join conditions fully, which is resulting in every row from the left-hand side of the join being joined to every row on the right-hand side of the join without regard to the relationship between those rows. LEFT JOIN categories c ON ... needs to specify how you want to join the item/sub-category information to the category table. JOIN users u ... needs to specify how you want to join the item/sub-category/category information to the users table. lastly, concat(i.listing_duration) <- that's concatenating one value. why not just use the value itself?
  18. you are likely getting a fatal runtime error. do you have php's error_reporting set to E_ALL and display_errors set to ON in your php.ini on your development system so that php would report and display all the errors it detects?
  19. there's nothing in the posted code that would cause the problem. however, given your class="...." naming in all the html markup, i suspect you have some client-side code, that's likely causing this. what's all the relative code on the page(s) that would be needed to reproduce the problem?
  20. the login_check(){} function definition. the current focus of this thread, is defined in the functions.php file. you should not have any code referencing $login_check == $login_string in your login_success2.php code (as indicated by the last image of php error messages attached.)
  21. i get ~60 execution time for the mysql pdo code as well, for engine type InnoDB. for engine type myisam 0.25 seconds
  22. because the for() loop is what is incrementing the $i variable, you would need to put the if ($i % $imagesPerRow == 0) test before you output the image. this would result in an extra <br> before all the output or you would need to add a condition so that it only does this when $i is greater than zero. what i would do is use a foreach() loop instead of a for() loop and use a separate $i variable that gets incremented inside the loop.
  23. the issue isn't that the second image is entirely missing, it's that the first row of output only has one image in it. the problem is because $i is a zero and - if ($i % $imagesPerRow == 0) is a true value.
  24. is the html that's being produced and output to the browser what you expect? if the problem is always the second image, does the first or second image name contain any html special characters in it that could be breaking the html? what are the file names and what is the html that's being output?
  25. just listing what you want doesn't help us to help you as that doesn't tell us where you got stuck at when you tried to do this. i can only offer two recommendations - 1) for each step, define what your input(s) are or what data you need to get/produce, what processing you want to do on those inputs/data, and what result or output that step needs to produce. 2) "So each fan size would have two variables, its name and its output." your variables should be general purpose. you should not have variables with names like $capacity9, $capacity14, ... in fact, since you have a SET of data that's all going to be processed the same, just with different values, you should use an array to hold the data. storing the rows you retrieve from the fan/product table into an array would be a good first step, as this will decouple the actual database statements from the code using that data.
×
×
  • 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.