-
Posts
5,450 -
Joined
-
Days Won
175
Everything posted by mac_gyver
-
sorry, but we are not here to fix a script that you found/modified. if you don't have the php skills to narrow down the problem to just the relevant parts of the code and to post the symptoms or errors you got, you need seek help from the author of the script or hire someone to fix it for you.
- 1 reply
-
- 1
-
see my reply at the following link on how to do something once when a value changes - http://forums.phpfreaks.com/topic/289403-issue-showing-results-1-row-keeps-alternating/?do=findComment&comment=1483684 also, about your tables. the table you show for Products (i would name it order_details) should have an id (auto-increment), o_id (order id), product id, and quantity. the product name should be gotten by joining with your product/item table (whatever you have named it) via the product id. i would also recommend using alias names for the tables in your query. your current query would become - SELECT c.CLIENT_ID, c.CLIENT_NAME, o.o_id, o.client_id, o.o_date, o.o_number, o.o_notes, p.o_id, p.qty, p.name FROM clients c, orders o, products p WHERE c.CLIENT_ID = o.client_id AND o.o_id = p.o_id AND o.o_id = $theOrder
-
show is a reserved mysql keyword. to use it as a column name, you must surround it with back-ticks `` i recommend renaming the column so that it isn't a reserved keyword so that you don't need to do anything special for it.
-
Getting current month and displaying result on Chart
mac_gyver replied to dapcigar's topic in PHP Coding Help
your solution will get data from every matching month, ..., 2012-07, 2013-07, 2014-07. if you really only want the current month, you need to match both the current year and the current month. -
Insert One table ID to another for loop table column field.
mac_gyver replied to ripon_81's topic in PHP Coding Help
after the first INSERT query, you can get the last inserted id that was used by that query and use that id as a value in the other INSERT query. for the msyql_ functions, you would use mysql_insert_id(). however, the mysql_ functions are depreciated and you should not be writing any new code that uses them. you should be using either msyqli_ or PDO functions (which each have an equivalent last insert id property/method.) -
A field that updates with server time on any row update - mysql
mac_gyver replied to Drewser33's topic in MySQL Help
you can define the column to be a TIMESTAMP data type and use ON UPDATE CURRENT_TIMESTAMP in the definition to get it to only automatically update it's value when the row in updated. ref: http://dev.mysql.com/doc/refman/5.0/en/timestamp-initialization.html -
issue showing results - 1 row keeps alternating
mac_gyver replied to Dicko_md's topic in PHP Coding Help
you would use a variable to remember the last phone value (initialize to a value that won't ever exist as data, such as a null) and use this variable to test when the phone changes inside your while(){} loop. when the value changes, close out any previous phone section, output the new phone information, and set the variable to the new phone value. even though your query is searching for a single model, this method will work for any number of models your query matches. pseudo code - $last_heading = null; // variable to remember and detect when the heading changes while(...){ $new_heading = $row['some_column_that_you_want_to_do_something_only_once_when_it_changes']; // detect when the heading value changes if($last_heading != $new_heading){ // detect if it's not the first one (not the initial value) if($last_heading != null){ // there is a previous data section, close it here... } $last_heading = $new_heading; // remember the new heading value // output a heading section and start a new data section here... } // output the data under each heading here... } // close out the last data section if there is one if($last_heading != null){ // there is a previous data section, close it here... } -
[SOLVED] including marquee tag on a database output
mac_gyver replied to webtuto's topic in PHP Coding Help
take the time to start your own thread for your problem. topic locked... -
you need to do a little defining before you can write any code. for each of the four possibilities, 1) exact, 2) exact with excluded word(s), 3) any, 4) any with excluded word(s), what will be the search term you build and supply to the $swish->query() method? you also need to define if you are going to allow multiple excluded words (i.e. -word1 -word2) and you must handle the case where there is a - as part of an exact phrase search, such as finding a negative number -1000 and how to distinguish that from excluded word(s). you also need to decide if the excluded -word can appear at any place within the term entered in the search box or if they must be at the end (or even if you should have a separate box for excluded word(s) - this method would address the questions i posed about things like a -1000 in an exact phrase search. you could even do away with the - to identify excluded words since any excluded words would come from a different input text box.) also, if the search box contains any of the and, or, near or not boolean operator keywords, you must surround those keywords with double-quotes, making them a phrase, so that they won't affect the actual search result logic. the key to understanding the search terms you are trying to build is that the search term is a logical statement that produces a boolean (true/false) value. when the search term is TRUE, the matching file will be in the search results. 1) for an exact phrase search, the phrase must be enclosed by double-quotes. the double-quotes are part of the string you pass to the $swish->query() method, not be confused with any double-quotes that delimit php strings that are part of the php syntax in your code. for your Oil Gas Company example, the literal query would be "Oil Gas Company". 2) for an exact phrase with excluded word(s), the phrase is enclosed by double-quotes, followed by the not keyword and the word(s) to exclude. for the example Oil Gas Company -money, the search term would be "Oil Gas Company" not money (there is an implied/default and operator right before the not keyword.) 3) your any phrase condition is actually an or (the default between words/terms is an and). for the example Oil Gas Company, the search term would be Oil or Gas or Company. 4) for the any phrase with excluded word(s), for the example Oil Gas Company -money, the search term would be (Oil or Gas or Company) not money (the (...) around the or'ed term insures the intended operator precedence due to the implied/default and operator right before the not keyword.) next, in addition to your exact phrase and any word searches, are you planning on an all word search (all the word(s) must be present, but not necessarily together in the form of a phrase)? this would use and between the words (or simply leave it out between the words since it is the default.) lastly, you may want to consider having the user's put double quotes around the exact phrase part of what they are searching for.so that they can enter just about anything for a search - "Oil Gas Company" credit -money (search for the exact phrase Oil Gas Company, with the word credit, and without the word money. in this case, they would need to select between the any/all search (or you could allow them an option to enter the search exactly the way the want with the and, or, near or not boolean operator keywords fully under their control.)
-
what you are asking is likely, but it would take reading the swish documentation and examples. have you done so? then, once you have determined if swish can exclude words/force exact matches, you would need to write the php program logic that supplies the necessary parameters/search term to the swish methods.
-
the http 500 server error for php files is usually due to a fatal parse or a fatal runtime error. in your case, there's a fatal parse/syntax error in your code. you need to set php's error_reporting to E_ALL and display_errors to ON in your php.ini on your development system to get php to help you by reporting and displaying all the errors it detects (putting these settings into your file won't help with fatal parse errors in your main file because your code never runs to modify the settings.) as to what is causing the fatal parse/syntax error, it looks like you are missing a closing } for one of your foreach(...){ loops.
-
@crowds40, your question lacks context and definition that would would allow us to answer it (it didn't even start as being a question about making one url, which means that the answers given at first didn't apply to the actual problem.) you have an array of one or more colors. you either need to combine them into one url parameter, i.e. ?color=blue|green|white or you need to use a separate parameter in the url for each one (which could actually be an array name so that php would receive an array when the url is submitted.) which method you use depends on what you are using the values for, how cluttered/long you want to make the url, and how much code you want to write to extract the values when the link gets submitted.
-
you already have a thread for this, merging your two threads....
-
what format do you want the link to be in, because it's impossible to write code without knowing what end result you are trying to produce.
-
your link is repeating the color= parameter, so each value in turn is overwriting the previous value when php populates the $_GET['color'] variable. what overall goal are you trying to accomplish? a separate link for each possible color or one link that contains all the values from the array?
-
your sql query is running without errors (the var_dump($stmt); would be a false if there was any sort of permission/database/table problems.) all indications are that for the database you are using, the query is matching zero rows. if you were putting an external value into the WHERE clause using a php variable, i would suspect you have some white-space as part of the value in your query and it isn't matching the actual data in the table, but that's not the case here. are you sure the $sql query you are showing in this thread is EXACTLY the same query (including all capitalization/letter-case) you ran manually? about the only other thing that comes to mind is a php error is occurring (perhaps you have a mix of versions of drivers/extensions and the sqlsrv_fetch_array() statement is throwing a php error.) do you have php's error_reporting set to E_ALL and display_errors set to ON and you know for a fact that ALL php errors are being shown?
-
i have to ask, did you read the documentation for the pdo ->query() method? it states three different times what it returns -
-
as to the bool(false), have you read the documentation for sqlsrv_num_rows()? you can however use sqlsrv_has_rows() to find if php thinks the query matched any rows or not. as to why the query apparently didn't match any rows and your while(){} loop is being skipped, about the only thing that comes to mind is you have multiple database names and the database selected in your code above is not the same database you used when you directly ran the query.
-
what does adding the following debugging statement in your .php code show - echo '<pre>',print_r($_POST,true),'</pre>';
-
perhaps you missed this important information -
-
the code i posted is tested and submits the expected $_POST data when the <form> shown in my code is submitted.. if your code doesn't work, there's something specific in your code that's a problem. what exactly does the code do that makes you think it doesn't work? does the add/remove image/button add and remove form fields? how are you submitting the form data? what $_POST data is submitted to the .php code?
-
PHP GD Image Graphing problem with color running out
mac_gyver replied to akphidelt2007's topic in PHP Coding Help
since colors in the gd function calls are actually color identifiers for that specific image resource, i would guess your normal color identifier (black) is being redefined/overwritten as (white.) again, these are just educated guesses/general troubleshooting tips since i/we are not there in the room with you and only see the information you have supplied in this thread. in fact, the only thing i can definitely tell you about your code is, in the display() method, the exit; statement after the return statement doesn't do anything since the return statement ends execution of that method's code. -
you have markup that's not valid (reusing id's) and some that doesn't appear to be used (classes on everything.) you should only produce the markup that you need. id's must be unique, so they should only be used when you need to reference a specific element via code. your code should also be general purpose and should work for any number of different groups of text inputs. the following example is general purpose that will work with any number of groups of input fields and contains no id's (it references the current element using $(this)) - the javascript - <script> $(document).ready(function(){ $('.add').click(function(){ var d = $(this).parent('div'); // the (parent)div the add element is in var inp = d.find($("input")); // find ALL input fields within the <div> var i = inp.length + 1; // the next placeholder number to use var name = inp.attr("name"); // the name attribute of the first input in the div // this code is specific to <input> fields, but could be made to work for all field types $('<div><input type="text" name="'+name+'" placeholder="Input '+i+'"/> <img src="remove.png" width="32" height="32" border="0" align="top" class="remove" /></div>').appendTo(d); }); $('body').on('click','.remove',function(){ $(this).parent('div').remove(); // the (sub)div the remove button is in }); }); </script> example form with two different groups of input fields - <form method='post' action='formaction.php'> <div> <input name="code[]" type="text" placeholder="Input 1"> <img src="add.png" width="32" height="32" border="0" align="top" class="add" /> </div> <div> <input name="something_else[]" type="text" placeholder="Input 1"> <img src="add.png" width="32" height="32" border="0" align="top" class="add" /> </div> <input type='submit'> </form>
-
the name attribute should only be - name = "code[]" you are creating - name = "code[]2" name = "code[]3" ... (i'm not sure how php will treat those as they are not valid php variable names.)
-
PHP GD Image Graphing problem with color running out
mac_gyver replied to akphidelt2007's topic in PHP Coding Help
the problem's either in - 1) the actual data values. perhaps something (number format or magnitude) about the specific data in the 200-300 range is causing a calculation problem... 2) the length/amount of data. perhaps some of the calculations/scaling is wrapping round and overwriting values... 3) perhaps the data is actually being written to the image but the color being used got changed (i would be logging to a file the actual data that the program is using when it calls the gd functions to try and pin down the problem.) 4) could be a php bug in the gd functions, but in about 99.8% of cases where code doesn't do what you expect, the problem is in the code.