PHP: Making a simple screen transition Dashboard - php

im planning to make a Simple Screen transition Dashboard. I am going to make several stored procedures that returns columns to be displayed between transitions.
My question is what would be the best way to do this in PHP, since this is the only accessible language to be used with MSSQL and that doesnt need license.
I was thinking to make a hidden Pane(Frame) that handles the delay and loop that loads the Main Page. But im worried that between transition it will take time to Load and might not be a good presentation.
Any tips?
Sorry.. Simple Screen Transition..
Ex. First page, shows columns (customer, number of transactions, total sales)
Second Page, Pie Chart of Last Month vs This Month
Third Page, shows columns (seller, number of transactions, total costs )
Fourth Page, shows the Bargraph of Costs for this years months vs last years months
and so on.. like 10 of like this.
I was adviced on making like an advertisement of sort. Like an Infinite Loop of Power Point presentation that does real time query as the Data is updated every minute.
Hope I did some clarifications, if it didnt please let me know.
FYI. The client PC that will handle this will only have the local webserver ( i will use xampp) and will connect to MSSQL thru network, they wont have access to the internet for security reasons that I dont know.

Let your php print them as normal html (nothing special there).
For your panels, have a page with div containers and use AJAX to load your php intermittently (JQuery and JQuery UI would be the easiest. Make a JavaScript function that uses JQuery delay() and then calls itself to set up a timer that loads the pages into the div containers using $.ajax()

Related

HTML page load time

Hi guys I got a small problem. I got some site which get displayed on handheld computers. Those computers are SLOW. Even though they cost 4 figures they have Windows CE5/CE6 and 300-800 MHz CPUs.
Those handhelds are running a php based database application. We already minimized the javascript to speed it up but now the raw html data just takes too much time to get displayed. Sometimes only 1-10 records of the database are getting displayed thats not much of a problem. But around xmas our client has much more to do so we end up with 100+ records.
I'm already trying to minimize the html per record like shorter class/id names etc. Doesn't do much but it sums up on 100+ records.
I wonder if someone has some other ideas. Some other ideas of mine would be to display only a fixed amount and implement some system for multiple pages or load the data via ajax requests after the site was rendered. Anyone has some better ideas? Atm it takes up to 5-10 secs for the page to get displayed and if u have to work on 100+ records where some guy has to work on and you have 20-30 workers it sums up, so our client isn't pretty happy with the situation.
Is it definitely not the queries taking the time to load? Can you try loading it in a proper browser on a PC? Try using the Chrome developer tools to find out exactly which bits are taking time to load, and exactly what is using the most memory etc.

Ajax / js on refresh, limit content shown/gotten from php/sql

So long story short, im trying to build a chat application....well its already built kind of but, ive been trying to implement AJAX into it. Essentially so that as the messages come through from the db when a user posts it, that it reflects on the page automatically without page refresh.
on the javascript side the only event i could think of that would run without user input is the javascript setInterval() function that i have set to repeat # every 5 seconds for now.
on the PHP side which has the messages (echoed out), i have a statement that only displays the
last 10 messages.
The problem is that, every 5 seconds, it spits out the same 10 messages. over and over...broken record kinda lol. anyways so what i dont know/cant figure out how to implement, is a filter kind of, or SOMEthing that says "
hey only show me the last 10 messages and update ONLY when there is
new content.
"
So what i need is something( i assume javascript since its the one refreshing the page) that says only display the latest x posts only when its new content. I was thinking maybe an if/else that compares one value to another and then if false/true, run the refresh...but
what do i compare to???
as you can see, im stuck.
i dont post the code because its alot...dont want to put two chunks of code here but essentially the PHP reads rows from a DB section, and posts the latest 10 posts from the db via echo.
and the Js has AJAx commands that gets those messages and posts them on the page.
And again, both work except for the re-posting the same 10 messages on ajax /js refresh.
any tips,links, LOGIC...anything to help me get through this hump i gladly and humbly appreciate.
P.S - if you need to see code. let me know and ill post it but i think its pretty clear.
Thanks in advanced.
so webchat clients do this thing where they make a request to the server and the server lets it hang, as if its taking a long time to process, but instead, its waiting to see if someone else posts a chat or what have you, the moment it does, it replies to the user, if the timeout max is reached, it just allows the connection to actually timeout, at which point the javascript causes it to fire again. this eliminates the nasty, make a call every 5 sec feature for starters.
Keep a last returned timestamp in your javascript, and when you need to update the clients, send that along, and use that as your sql conditions:
select * from chat_logs WHERE datetime > $postedValueFromClient # AND YOUR OTHER CONDITIONS
Give that query results back to your clients, and update the last timestamp as well.
I can't help you further since I don't have any code, but that's one way of implementing it.
I'd fetch 1 line at a time and remember the ID of the last line that was received, also make a column in your table for instance read and set it to 1 or 0, if the message was receive set to 1 and only look for messages that have read set to 0.
MySQL statement:
SELECT * FROM `table` WHERE `id` > `lastID` AND `read` = 0;

Query and Display Results Every 'X' amount of Minutes from Oracle Database

Is there a way that I can query an Oracle 10g database, and display the results in a dynamically refreshed html file every 3 minutes, for example?
Here is my predicament: I have several queries that I would LOVE to display the results of to a whole organization on a basic HTML web page with some CSS. The problem is that I do NOT want a user to be able to constantly refresh a page in his/her browser, and thus severely bog down the database. I have no problem writing the queries, or writing the HTML and CSS needed to display the tables. It's almost as if I would like to query, export results to XML every 3 minutes, and constantly have an HTML or PHP file that is pointing to the dynamically updated XML file. I am open to other options as well...
I have basic user access with the Oracle DB...nothing Admin like. I do have access to a server, though, and have experience with PHP, PL/SQL, and HTML. Perhaps I would have to get into a lower level programming language like Python? I am kind of stuck here. Any kind of help would be appreciated!
you can also execute an Ajax Request every 3 minutes using the setTimeout() function.
Using jQuery framework
$(document).ready(function() {
setTimeout("getFeed()", 180000); //180000 = 3 minutes in milliseconds
});
function getFeed() {
//ajaxRequest here
}
For more info on ajax you can go here: http://api.jquery.com/jQuery.ajax/
Setup a materialized view(mv), point your app to this mv, and then setup a scheduler job to refresh it on whatever frequency you like.
See dbms_scheduler for setting up scheduler jobs in Oracle.
One note: you may want to do an atomic_refresh=>true to do deletes/inserts into the mv instead of truncate/insert (if atomic_refresh=>false, there will be 0 rows in mv until refresh is completed).
An simple example mv creation:
create materialized view MY_MV
tablespace MY_TS
build immediate
refresh complete on demand
with primary key
as
SELECT a.foo, b.bar
from table_a a, table_b b
where a.col1 = b.col2
and a.baz='BLAH'
;
An example refresh call:
dbms_mview.refresh('MY_MV', 'C', atomic_refresh=>true);

Browser MMORPG basics ideas

I started making a MMORPG to improve my web design skills. I managed to make users able to move around the screen and get some items with a combination of Javascript, PHP and MySQL.
I want to show all logged users at the same time moving around and push info to the user on what the others I doing but I have no idea how to do it. What are the general ideas/methods to do this?
Thanks
Try using this engine to accomplish what you want: MMO.js... it allows you to build real-time MMORPGs in JavaScript using websockets =)
You basically create a table called "online" with two columns "ID,Time" and whenever a player does some action it updates "Time" that's for the logging part.
And you get a cron job to check the database and if the Time in the database is greater than the current time minus (for example) -5 minutes (timing out time) DELETE the row.

Few issues with creating a web based chat system

I've decided to create a web based chat system for the experience. I'm using a mixture of AJAX(jQuery), PHP, and JSON to transfer the data. Now that I've started thinking about certain things, I've come to a mind block.
Right now, I use javascript to post the last loaded message id to a php file that queries the data and echoes new posts in json and then displays those posts in order on the page. However, the dates don't reflect the current time for the user. Since I use php to get the current time, I have no idea how to display the correct time to the user which takes into account of their time zone. Second, how would I incorporate a who's online list with this method? I could create a separate table and update it when a user creates a session and delete their name when they end the session; but what if they don't close it properly? Should I just add their last sent message into the the table and if it's been about 5 minutes since their last message consider the user disconnected? Lastly, is the method I'm using to collect new posts efficient? This there a better way to go about this? I appreciate any input.
This seems related: Determine a User's Timezone
I'm going to make you go there for the code snip so you give proper credit with your upvotes.
I get the impression that Javascript is the best/easiest way to get that data.
What I would probably do is use GMT or some other fixed time zone for all your server stuff and then just adjust that with js once it hits the browser depending on their time zone. Either that or just collect it once at the start of the conversation and adjust your output accordingly. There might be advantages to either way.
Edit:
Oh yeah, about the "who's online" I think you're headed in the right direction. I might suggest 2 lists. "Who's active" and "Who was active recently"
That way you can put people inactive after 5 mins and consider them disconnected after 10 or something. I guess it's about the same but it seems more accurate to me somehow.
The other option would be to set an ajax request to automatically fire of a request every minute or so. When they stop then you know the user is gone.

Categories