-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
Since you are not happy how about telling us what you have set the value of $sw to?
-
Have no idea what your beef is and No - I am not happy now. But I think you will be happier now that you fixed your function. Sic? Do you know what that mean? Period - means I am telling you the truth and that's that. But I shouldn't have had to splain that to you. HTH
-
I don't know what this "funcionts.php" (sic) file is doing for you but you are showing US a function that uses variables that simply Do Not Exist. Period. And your latest post has a comment followed by some definitions. Those items may be supposed 'Global variables' but there is nothing being done to make them global. And besides - just because you may have declared (properly) a variable to be global, if you don't also reference them with the 'global' command (construct?) inside each function that you want to have access to it, they will be strictly local
-
But the function does not make sense. Where are $sql_server, $ms_sql and $var_sql defined? And what is the point of a while loop if you are returning after fetching only one record?
-
trying to insert multple form data into msyql database
ginerjm replied to jcarney1987's topic in PHP Coding Help
Here is how I would write it: $num_rows = 3; echo "<table>"; for ($count = 1; $count <= $num_rows; $count++) { echo "<tr> <td>Item: <input type='text' class='item' size=3 name='item_number$count' value='$count'></td> <td>Desc.: <input type='text' class='description' size=20 name='description$count'></td> <td>Qty.: <input type='text' class='quantity' size=2 name='quantity$count'></td> <td>Unit $: <input type='text' class='unit_price' size=8 name='unit_price$count'></td> <td>What name is this? <input type='text' size=8 class='total_price'></td> </tr>"; } echo "</table>"; I have assigned size attributes but you should not use size. Setup a class instead for the width of your input values. And - you should make the 'labels' I created actual html <label> tags to be proper. -
trying to insert multple form data into msyql database
ginerjm replied to jcarney1987's topic in PHP Coding Help
While you have 2 very reliable responses to answer your question, I see no problem with the way you have designed your page. I think the problem you are having is you are not reading the input delivered to your script properly. You probably have a loop that is simply trying to check if an input is present rather than if it is empty, ie, not entered. As we all know your $_POST array is going to have all of the text inputs present (which you really should be designating) even if the user did not put something into them. So - in your processing logic, look for a value in your loop and not just whether isset() is true. It's always true (unless it's a checkbox or a radio) so that is not a good test. Check if it has something in it instead. Choose the key field that indicates whether the user is posting something to that data row and rely on your testing of that item. If it is empty then do a continue and move on to the next row. Just my $.02. -
How big is this report? How many records are being read to produce it? And - most importantly - is the data being collected with a single query execution or is the query to gather it run repeatedly from inside a loop? That would be a bad process and it would definitely slow things down if it involved hundreds of query exections.
-
You use the heredocs construct to output html or js code within a php script without having to switch modes all the time. Here is a sample of what you can do: $code = '<table border=1>'; $col1 = 'col1'; $col2 = 'col2'; for ($i=0;$i<2;$i++) { $code .= <<<heredocs <tr> <td>$col1</td> <td>$col2</td> </tr> heredocs; } $code .= '</table>'; echo $code; You can create your output using php and html without having to do the <?php and /?> mode switching all the time. I basically hardly EVER switch out of php mode by using heredocs.
-
I have written several modules (files containing small important pieces of code) that handle some standard features that get used all the time. Like checking the log in credentials for my apps or for making a db connection as well as some other particular operations that I use sometimes. As for heredocs Barand has pointed you to the Manual so that yyou can read up on that. I have a php function that I use for many of my scripts that outputs my standard html page which I modify for each page to handle what I need to adjust for that particular page. A big part of that is to add the div/form tags that I may need but the dynamic data that may be part of that is added after being built outside of this function. Keeps the html clean and all I do is insert a variable to display the data that I have formatted for it. The css is also part of this function. Something like this: .... ... if ($tbl_results) { echo "<div id='tbl_box'> <table id='rslts_tbl'>$tbl_results</table> </div>"; } where the variable is built before calling this display function with all of the html table's content already built.
-
Everybody has their own preference. Personally I write without using a framework and I don't use classes either. Write my php using functions and included php modules to handle security checking, db connections along with a bit of JS and a well-organized std. HTML template that I populate with php variables to create my page. Have at it. Tips that I find handy: - don't use upper and lower case in your php - make good use of heredocs - use POST or GET but never REQUEST - use PDO for your db connection and querying. Repeat - use PDO. - and of course design your database properly.
-
The little backtick located above the tab key is not a valid 'quote' character for php coding ( and probably a lot of other coding). Use either double quotes or single quotes - both on the same key next to the enter key. The backticks are used in sql coding to identify field names, if necessary
-
what do i need to do to make the code mountain safe and mountain good
ginerjm replied to egemen's topic in PHP Coding Help
I don't know what you wrote back to us but it makes no sense at all. I'm done. -
Nice pickup on the quotes. So much else to examine that I missed those little buggers.
-
what do i need to do to make the code mountain safe and mountain good
ginerjm replied to egemen's topic in PHP Coding Help
Huh? What is 'mountain safe' or 'mountain good'? Never heard of those terms on a forum. As for the ar function: What's the point? You have a $_POST array already so why do you need to make a new array? And then you create the em function just to find out if a value is empty. Why does one need a function for that when PHP gives the empty function to use already? And your bh function. Not at all sure what you are trying to do but what you have is going to simply create a single element array (?) with a key and a value that you already know and that you could have put into an array on your own. This function doesn't do anything. And it also creates an extra array just so you can return it. Why? And the bb function. I won't even discuss that one. Nor the commented code. -
Var names are strictly up to the writer. He/she is the only one who will ever see them. But that also means that down the road someone else could inherit this project and have to make sense out of your logic. So - make the names meaningful but learn to use shorter words or abbreviations that will make sense to the next person. Comments are also helpful in code to pass along your thoughts to the next coder as well. As I see in your latest post Class names could also be shortened. They don't have to be so 'informative' since everyone knows what they are. If you keep typing such long names in your projects, at some point in your future you will begin to wonder why you ever started out this way.
-
You are using brackets to wrap your function args. Use parens. And - I would not use dashes for varnames. Use underscores. And - A comparison (in an if) uses 2 = signs, not just one. And - you are going to get real tired of re-typing var names that are way too long pretty quickly. I know you are trying to be clear but perhaps you could re-think your names to make it easier to type them and read them later on.
-
Could really use some basic assistance, please!
ginerjm replied to WorldwideGaming's topic in PHP Coding Help
A lot of people - like me - don't open up attachments. If you have SOME code that you want looked at, post it here using the <> tag to frame it. We aren't interested in the html and JS and CSS, mostly just the PHP. -
Could really use some basic assistance, please!
ginerjm replied to WorldwideGaming's topic in PHP Coding Help
If you want to show us this error setting code (and more) please post readable real code and not some image of it. That way somebody might play with it and test it out perhaps. Can't do that with a pic. -
How do I get the results to show as a table
ginerjm replied to AlphaOneIntelligence's topic in PHP Coding Help
Do you mean to show it as an HTML table? <table> <tr><th>heading</th><th>heading</th></tr> <tr><td>data</td><td>data</td></tr> </table> That is roughly the structure you have to use. There is some more modern items that now belong in there but I still use (and get away with) this simple old-style structure. Add your styling using css from a style section, not in each element. Assign a different class to your td tags and your th tags as well as your table tag itself to do different settings for each. -
Since you cannot use the mac address to identify the client that is making a login request, what do you have available to help you make an id? Are you that uncomfortable with users keeping their own passwords secret? If this password is important enough to the employee that he/she should not be sharing it, how can you make that real to the staff?
-
I suppose this topic is closed now after Requinix told you it cannot be done. Hopefully your next post will be written a bit clearer and in a style that makes it easier to read
-
Get? Are you trying to say 'fetch' as in retrieve a query result? At least now I understand one sentence. The rest is still not clear.
-
What does 'Fitch' mean?