-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
Why do you need to do this with JS in real time? Simply have the uses submit the form with the entered times and let php do the work.
-
In that case - forget my comment. As for your problem though - do you understand what I posted?
-
?? I said "What URLs". You aren't showing any urls in your example, so I'm confused as to what you want to work on.
-
Uh - what urls?
-
That's not how you mix in your vars to the JS function. You can't use php in a js function since one is client-side and the other is server-side. Make you js function retrieve the values you want from the dom by using simple js things such as getElementById. (google it). Ps - Is English not your normal language? Cause if it is, how are you ever able to spell php functions correctly?
-
Pdo does not have to be used as OOP. I use it strictly in procedural mode and find it very easy to use. $q = "select * from (table) where key1= :mykeyvalue1"; // note use of : in the key argument here $qst = $pdo_conn->prepare($q); // $pdo_conn is created in a separate piece of connect logic that one can easily write in an included module if (!qst) echo "error doing prepare"; $qst->execute(array('mykeyvalue1'=>$key1)); while ($row = $qst->fetch(PDO::FETCH_ASSOC)) { (process the returned rows) } Hope this makes it clearer.
-
Yes - it is php code and s/b at the top along with all of your php code (and not your html) whenever you are developing your scripts.
-
Except you mixed your html and php code together.
-
Submiting form with text fields and checkbox's Need help
ginerjm replied to ericjw316's topic in PHP Coding Help
With all that input I would not use a GET for my input. Set your form method to be POST instead. Also - your checkboxes don't have a value clause which is usual. Of course you still have to check if they are set but then you can simply use the value as the value to be saved. if (isset($_POST['checkbox1'])) $checkbox1 = $_POST['checkbox1']; else $checkbox1 = 0; // or whatever you want saved -
Turn on error checking to see if something is wrong with your script. See my signature.
-
"Login system"? Is this something more than a simple form that asks for a user id and password? I've not heard it referred to as a 'login system' before. Normally it is simply the form and some logic and a db query to check the entries or to save them.
-
How to validate user login on every page only with cookies
ginerjm replied to thegweb's topic in PHP Coding Help
1 - create your text file and store it outside of your web-accessible tree for security purposes. 2 - create a small php script that contains a function that has two arguments - user and password. 3 - in this function open the text file and start a loop on it to read the lines one at a time. 4 - match the user and password argument against the contents of the current line you just read. If it matches, set the cookie and return true from the function 5 - if it doesn't match, read the next line from the text file and repeat step 4 6 - if you reach the end of the file and exit the loop, return false. -
Maxdd - I rarely use oop. Small projects, not enough repetition to warrant classes, use includes for standards pieces of code. Hansfore - function does stand out on the function header, but in use that word isn't obvious! Of course, function names in php are case-insensitive so it doesn't matter but it's just one of my own conventions.
-
as Maxdd says commenting a much ignored attribute of programmers. Sometimes when we get deep into a process and develop some code to do some tricky maneuver we lose all sense of it just a couple of months later when we come back to 'tweak' it a bit. Comments about your thought process when you write something are essential! Unfortunately, I can't agree with Maxdd on his use of camelcase for naming things. It's bad enough that JS endorses it - there is no reason for you to introduce it in your own code. A needless distraction in my opinion since it leads to many errors during development where you inadvertently leave out a capital letter which PHP will not catch and WILL give you an error or worse. IMHO - stick to all lowercase for your vars. Another of my preferences is to use initial caps on my own function names just to make them stand out. MyFunctionName() versus myFunctionName() or myfunctionname().
-
Sorry about my previous post. For some reason the forum is acting strangely today. I did not spread my code out like that intentionally.
-
$first = true; while($row = mysqli_fetch_assoc($result)) { if ($first) { $first = false; continue; } ... ... ...
-
Great question! More people should think like you! There are lots of preferences on "how to indent". So what I'm showing you is just my personal choice. I believe it gives one an easier view of the code and makes it much quick to browse thru code looking for "blocks" of statements. I indent any block of code that is wrapped in curly braces ( { }). I indent any single lines that are part of an if else statement. I indent all function code, again because it is inside those braces. I indent if statements that are inside other if statements (of course, I try not to nest too many if statements). Below is a sample ( I hope the site shows it accurately) of what my code would look like: php line php line php line if (condition) { tabbed line tabbed line } else tabbed line php line php line php line //****************** //****************** function MyFunction() { php line php line php line } ( I see that the forum added blank lines between my original input. Oh, well....) (note that this code was posted using the proper code tags for this forum ('php' and '/php' wrapped in square brackets) Also it is encouraged to separate your main html code away from your php code. Too many people think in a straight line as they write a script and begin by beginning the html document before they do any php. Start your script with the initialization you need (a session_start is always a good start), determine what you need to do in your php, then do it and save any dynamic information to be displayed in php vars and at the end of your processing output the html document in its entirety, including those php vars where the data they contain should be displayed. Some html may be generated by the php process, such as building a drop-down box or an html table but that should all be in a loop that is producing the data to be contained by them and therefore makes sense.
-
YOu need to show us some contiguous code here. A radio button only returns one selection so there is no need for a loop. Show us the whole code where you build your html (the query that produces the data would be nice) and then how you completely receive the data. We can't possibly understand what you mean by having multiple ids in one radio button.
-
Strange? What happened when you set your column widths as I suggested?
-
PHP $_GET? At least I think that is the function I need to get working
ginerjm replied to DogMan's topic in PHP Coding Help
The url that would be used is: domain.com/mypage.php?quitdate=x To receive that value in your script you need: if (isset($_GET['quitdate'])) $quit_date = $_GET['quitdate']; else (handle a missing argument however you wish) Of course you then need to validate that value to be sure it is something you expect -
If you want: 21, 33, b4, 42 You need to output that: echo "$key$val, "; If you don't want that, I'm not sure what you are asking for.
-
When you declare your table, add specific col widths to it so that the format isn't determined by the browser. Look up the <col> tag
-
Convert from text file to html table using php.
ginerjm replied to Tyka95's topic in PHP Coding Help
If you did all this, WHERE IS THE CODE? -
Convert from text file to html table using php.
ginerjm replied to Tyka95's topic in PHP Coding Help
So - where is your attempt at getting to your goal? You wrote all the php code (which you really need to post properly next time) but you didn't write the easy part.