Jump to content

mac_gyver

Staff Alumni
  • Content Count

    4,505
  • Joined

  • Days Won

    121

mac_gyver last won the day on August 5

mac_gyver had the most liked content!

Community Reputation

486 Excellent

About mac_gyver

  • Rank
    Staff Alumni

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

148,653 profile views
  1. if you do this - you will end up with code that looks like this - $out = ''; foreach($indexed_data as $type=>$arr) { // start a group $out .= "<optgroup label='$type'>"; foreach($arr as $row) { // add the output for each $row of data within the group $out .= "your makdup here for the <option ...>...</option> tag"; } // finish the group $out .= "</optgroup>"; }
  2. that's an acceptable var_dump() output. the length matches the number of displayed characters. i suspect you are seeing the result of two (or more) requests to the page. for the first request, there is an input value and when you are using echo/var_dump to display it, this is preventing a header() redirect, that's causing additional request(s), which don't have the expected input. you are seeing the displayed result from the last request made. this 'works' when you hard-code the value, since all requests have the input value. so, two things - if it sounds like your code is capa
  3. the value probably contains some non-printing character(s). what does var_dump($_SESSION['bid']); show?
  4. you got an sql syntax error message calling your attention to a specific point in a query. did you look at that sql query and attempt to determine what might be wrong with it at that point?
  5. no. the parameters and values in code can come from any expression, such as a literal string, a variable, the return value from another function call, a math/logical operation, ... you would define a data structure (array or database table) that contains a list of the expected form field names (types, validation tests...) you would then loop over this defining structure to dynamically test/validate the inputs. the field name, which would be in a variable, would be used in place of any hard-coded associative field name in the code. except for unchecked check-boxes and radio-buttons, a
  6. as a side note - if you use the PDO::FETCH_COLUMN fetch mode with the fetchAll() method, you will directly get an array of the (column) values, rather than an array of rows of data.
  7. for the $jokes variable to not exist, either the query failed due to an error or there are no (matching) rows in the database table. for the first case, most database statement errors are fatal problems, either due to programming mistakes or the database server not running, and there's no point in code on the page continuing to run at all. therefore, you would want your error handling to display the actual error information when you are learning, developing, and debugging query(ies) and to log the actual error information when on a live/public web server. to do this, simply let php catch
  8. here's a page with a more specific date sort example - http://www.javascriptkit.com/javatutors/arraysort2.shtml
  9. you will get a false return value if an error occurred (you will get a zero return value for no match.) you can specifically detect the false value and log both the $needle value and the debug_backtrace() information.
  10. if you are trying to paginate an array of data, just use array_slice(). it takes the same offset and length values as the LIMIT clause in an sql query would. this would eliminate all this 'glue' logic. you would just foreach(){} loop over the array of data returned. this will also work correctly for a partial last slice or an initial slice with less than ROWS_PER_PAGE elements in it. if this data is coming from an sql query, why aren't you just getting the requested page of data directly in the query?
  11. the value returned from the ->execute() method is - you don't fetch data using that returned value. ->query() and ->prepare() are PDO methods. they both return a PDOStatement object (when successful.) ->fetch() and ->execute() are PDOStatement methods. ->fetch() returns a row of data (or a false if there's no data to fetch) and ->execute() returns a boolean value as listed above. typical code for a non-prepared query - $sql = "build the sql query statement in a php variable"; $stmt = $pdo->query($sql); // fetch a single row of data $row = $stmt-&g
  12. you should allow for multiple stock in events per date. this will assign a 'stock in id' for each event that increases the stock. when you consume stock, you would insert 'child' records, using the parent's stock in id to relate the stock out event back to the corresponding stock in event. if you consume stock from more than one stock in event, you would insert a stock out/child record for each amount you take from each stock in event. to find the earliest stock in event(s) that has(have) an available stock amount equal or greater than a needed quantity, you would join the parent and
  13. it will probably take having all the code that's part of 'it' to be able to help.
  14. you probably have some broken html, prior to that input field, due to the short opening php tags <? being used. when you do a 'view source' of the page in any of the browsers, do you see the raw php code or do you get the values that php is trying to echo onto the web page?
×
×
  • 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.