-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
Why not an onclick event on the submit button that triggers a js function that outputs your message?
-
Knowing where you are in a non-numeric index loop
ginerjm replied to Strahan's topic in PHP Coding Help
oops - I see a typo. That s/b 'array_keys' -
Knowing where you are in a non-numeric index loop
ginerjm replied to Strahan's topic in PHP Coding Help
array_keya(), array_values() and implode() -
save data to database checkboxe values checked or not
ginerjm replied to tom7890's topic in PHP Coding Help
Have you EVER looked at the manual to solve any of your mysqli usage problems? $num_rows does not exist. It is not a local php variable. It is a property of a mysqli result WHICH if you had ever looked at the manual you would see you LEFT out of your code. Change this: $db->query($sql); to this: $results = $db->query($sql); NOW you have a result set to play with which you did not before Now change this: if ($db->num_rows > 0) { to this: if ($result->num_rows > 0) { Note the dollar sign. These would have been very clear to you if you EVER read the manual. PS - for the future - when you post an actual error message it would be nice to point out the line that it is referencing in the message. This one was easy but it won't always be that way. -
week date range in calendar pagination increment
ginerjm replied to hfheuhf's topic in PHP Coding Help
What are you getting back from your urls? Have you looked? -
Not a 'basic' kind of thing, but still not that hard to do. Need to do some googling on ajax requests and try to understand how it works. Basically - your js code is triggered by the onchange (or an onkey* event) event of your input field. That means as the user types something your js code executes immediately and prepares an http request that is sent to the server as a totally separated task. That task is going to run a php script to do your bidding and return you something - whatever you want. Your js code retrieves the response and then handles it - probably by putting something into the html of your screen. If you have a slow connection to your server this will be problematic. Question - are the possibilities part of a limited (ie, small) set that you know beforehand? If so, you could build an array for your js code to use instead of using ajax to go back to the server on every keystroke.
-
CyberRobot is not alone. What the heck are you talking about?
-
Whatever. I'm confused and can't make sense from your writings.
-
Putting an array in to a CSV using fputcsv
ginerjm replied to Kristoff1875's topic in PHP Coding Help
How did the csv'ed data get INTO that database? It needs to stop. Then you won't have this problem. -
I tried to point you in the right direction. The thought of creating a 'key' is not going to work for you I don't believe. Think of querying for concepts in your data, not 'keys'. Define how the data has to look for a given situation and use that as your 'key' if you will. Closed - when a time slot is assigned Open - when a time slot is undefined or assignment field is empty As for partial and full usage - is this really something that will occur? Can you possibly get "full utilization" of time slots when you book them back to back for different users? Have you thoug about how the actual use of your resource will happen? Think about a meeting room. Someone books it for one hour. Yet you have to have it available for a certain amount of time prior to that hour for it to fill up, and for some time afterwards for it to empty and for it to be re-fitted for the next user (cleaning?). So - you have to actually book a time slot for extra time. Do you really want to be booking partial time slots?
-
Why does the url 'get lowercased'? Something you are doing elsewhere? If you have data stored in one way why would you not use that data correctly (as is) to build your URL? Or did you not build your file/folder structure using the same exact values as the data? You do realize that you can build your anchor/links using a modified version of the data for the 'displayed' portion and still use the original stored version for the href portion? This has got to work unless you did alter how you used the data previously and now can't make it match. As for the 'foreach' method of altering the case and not getting permanent results - try using & on your foreach arguments. It's in the manual.
-
Putting an array in to a CSV using fputcsv
ginerjm replied to Kristoff1875's topic in PHP Coding Help
May I just ad my two cents here? BoneHead Move. You have data. You are using a database. Use It Properly. A csv string/file inside a db table? Now I've heard of every stupid thing that a newbie can possibly do wrong. In my previous incarnation a programmer working for me would never be allowed to do this (let alone think of doing it!) or he wouldn't work for me very much longer. You are getting good advice from people who know what they are talking about. You came here just for that, didn't you? LISTEN TO THEM! You're driving your car down a one-way street in the wrong direction. Turn around now and stop debating them. -
The key to this whole process is having sufficient data stored on each "day" so that you can write a query that determines the things you wish to find out about that specific "day". So - have you that data? You say you are trying to manage "time slots", therefore I assume that you table contains records that identify each time slot for use. Is every possible time slot created in the table before it is allotted, or do you only create a record when someone books it? That would be one way to identify availability. Once a slot is booked do you treat that specific time slot as 'fully booked' and therefore unavailable to anyone else? Again - that answers the availability question. With my two examples (very small help) I'm hoping that you are inspired to think about your problem in a more logical way and come up with more ideas on solving your needs.
-
Nothing new there re: PDO. All those points are addressed in the manual I believe.
-
You decide. You could use the data's saved date/time value and send the latest one out on the web page as a hidden field in your form. Or you could just send the current date/time. When the web page is submitted/posted back to your script you get that hidden value and use it as your compare value for when you build the new/refreshed page.
-
Only thing missing now is how to retrieve the results.
-
You will need to output your results using some html and css to do your highlighting. From what you wrote I'm guessing you are just echo'ing some query results. Try putting them into an html table or in an html list and use css to produce the highlighting. echo "<table>"; while($row = $pdo->fetch()) { if ($row['datefld'] > $highlight_date) $classname = 'hilight'; else $classname = 'normal'; echo "<tr class='$classname'><td>{$row['field1']}</td><td>{$row['field2']}</td><td>{$row['field3']}</td></tr>"; } echo "</table>"; You would need to set the value of the $highlight_date field based on something and write a couple of css classes to achieve your highlight or normal effects.
-
It works anyway you want it to. How is the refresh done? By the user clicking something that triggers a POST? You can put something on the page to mark the last shown record and then highlight ones that succeed that on your next page build. You can use a datetime value for this, or a record id value. It's really not an exact science - it's just some algorithm that you yourself make up and follow. The highlight is the easy part using css. It's the recognizing that you will have to work out for yourself.
-
1 - I'm surprised that during your build of this site you didn't run across ANY warnings about this interface being deprecated. 2 - Since you apparently didn't use the official PHP manual to build your site, I suggest that you begin LEARNING mysqli by reading the manual and using the examples you will find there. While mysqli is a bit different from the old MySQL interface it is not going to bring tears to your eyes. May I suggest though that you get permission to use PDO instead? I find it to be much simpler and it provides the ability to connect to non-MySQL dbs as well.
-
Two Input Forms - One Based Upon Input to the Other
ginerjm replied to nshaw's topic in PHP Coding Help
Another day; another bit of knowledge. -
You have the if statement, but what is this "this" that you use? Why "this"?
-
If it has to happen without refreshing the screen you probably are talking about using a js function to capture the value and then make an ajax call that passes the value to a php script that will generate your html and then paste it into your hidden div and then make the div visible.
-
Two Input Forms - One Based Upon Input to the Other
ginerjm replied to nshaw's topic in PHP Coding Help
1 - please wrap your code properly in tags 2 - I believe you have either a rarely used syntax in your array definitions or a completely wrong syntax. Usually it is done: $array = array(1=>'first entry',2=>'second entry',3=>'third entry'); This could be a problem for your process. Also - turn on php error checking - it could point out errors that may occur. PS - you could utilize single quotes inside your double-quoted strings to make it easier to type and read. -
Actually not my code but the OP's which I left there- commented - for his benefit
-
Already covered