You cannot change a column name on the fly like this.
You're better off making another column and calling it type and flagging it to know what "type" it is.
You cannot change a column name on the fly like this.
You're better off making another column and calling it type and flagging it to know what "type" it is.
What have you tried?
You're also missing the word "where" before your case. Lastly, comma joins are pretty old and likely will be deprecated at some point...
Your where clause always have to result in a boolean to check equivalency. For example "where 1 = 1". From reading this, it does not look like the case has a match, and therefore it is in error.
Ex: 1 = case u.foo when t.foo then 1 else 0 end and ....
So.. the problem is your question is very vague. Instead, I will walk you through how to find your answer on your own and hopefully that will help you.
First, you need to understand the basics of how HTML/Form Data work. You can find that here:
https://www.w3schools.com/htmL/html_forms.asp
--Alternatively, if you don't want to do it as a form post and would like to do it as AJAX, you can instead look here:
https://www.w3schools.com/xml/ajax_intro.asp
In either case, you will either wrap your table in a "form" element, and each node of your table will require an input (which holds the value).
If you instead go the AJAX route, you will need to iterate the cells of your table, and create your AJAX parameters through script.
(need help iterating through table cells? try this: https://stackoverflow.com/questions/3065342/how-do-i-iterate-through-table-rows-and-cells-in-javascript)
From there, you send your data off to your server, which requires PHP (which seems to be what you are using to make your table). I will make the assumption that you know the basics based on your code: however, the things you are going to be most interested in with form data / ajax data are:
https://www.w3schools.com/php/php_superglobals.asp
-- Particularly, GET or POST depending on how you decide to send your request (likely a POST, as you want to "save" data, which is the intended use).
From there you will need to use PHP to take the incoming values and use MySQL to save the data …
As I noted, if you want to do "everything" in javascript, look at building out a nodeJS stack. While it's "all javascript" it just happens to replace the PHP part (you still need a server though)
You are going to need to learn about AJAX, some server side language to format your JSON to output to the AJAX request, and of course - SQL to write the query that the server side language will process/execute.
A very common free stack is called a LAMP stack, which stands for Linux (the server OS), Apache (the web server), MySQL (database), PHP (server side language / processor) stack. It is common/popular because it's free, and all you need is a host (which, if you look hard enough, you can get for free as well - but if this is sensitive information, or information that you want to keep for future use, you may want to look into a paid hosting solution).
There are other iterations of this: if you are a windows user, there is also a WAMP stack (windows instead of linux) but it tends to cost more.
Of course, there are also other free server side languages to pick from - Ruby on Rails, Python (Flask is common), ASP, NodeJS, etc... but each has their own strengths and weakenesses, as well as learning curves.
And other database options as well: Oracle, TSQL/MSSQL, MongoDB, .... (this list is crazy long, for the most part they are all the "same" but different). As well as the option to go with NoSQL but... meh.
Hope that helps,
Ryan
Yes, that's exactly what I meant.
How are you determining your $per_page_records value?
Edit: actually... since youre using the active='1' in your query, you just wouldn't pull any data if your page values were too high for your limit...
So.. it seems to be a bigger problem than what you are showing in your small bits of code. Somewhere, you are likely forgetting that active='1' flag when pulling the data, or you just have all of them flagged as active, when you think they should have a 0 or 2.
What is your methodology that gets the count of all items? (ie, how are you determining you only need 3 pages of 25 a piece?)
you are looking for the javascript function window.open
(or, in your case, top.window.open("https://www.yahoo.com")
or whatever....)
I'm always confused by questions like this...
You studied this field. You know your stuff.. build something important to you - with EE you can do SOOOO much.. Take something that you are interested in or something that a family member or friend could benefit from. The quality of what you produce will be SO much higher when you have someone (especially yourself) in mind when making something usable. Your grade will reflect the care, usability, and expression of what you have learned.
Having an off day pty?
The only "secret" to JS-Less toggles is an input type="checkbox" and use a label to toggle the checkbox's state
from there, you use your css "+" and :checked pseudo selector to modify your visual state
ex:
.myWrapperElement .input[type="checkbox"]
{
height: 0;
width: 0;
overflow: hidden;
padding: 0;
margin: 0;
opacity: 0; //just really really hide the thing
}
input[type="checkbox"] + .myElementThatNeedsStyle
{
//generic styling
}
input[type="checkbox"]:checked + .myElementThatNeedsStyle
{
//styling for checked state
}
edit:
if the design itself is your issue, take note that the reason your "toggles" at the bottom break are because you used floats to position them. They are for all rendering purposes, "out of the page flow" and will not look quite right without a relative parent container to contain them. Even then, you will have to do hacky things like put overflow:hidden on the parent to make sure it always encompasses them.
tcol1 = 0
tcol1[mm] = col1 + amt
You can't set a member of 0 to a value. You are essentially saying 0[mm] = col1 + amt;
http://www.sqlfiddle.com/#!9/c6632/15
I believe this will work for you (I gave you two versions to work with)
select
room_type.room_type,
room_type.room_typeID,
room_type.room_type_des,
room.room_id,
room.room_number,
room.room_typeID,
room.room_adultcapacity,
room.room_childcapacity,
room.room_img,
room.room_status
from
room
left outer join room_type on room.room_typeID = room_type.room_typeID
left outer join room_rate_default on room_type.room_typeID = room_rate_default.room_typeID
left outer join room_rate on room_type.room_typeID = room_rate.room_typeID
where
room.room_id NOT IN (select room_id from reservation where reservation.room_id = room.room_id and
(reservation.reserve_date_start between cast("2018-06-17" as date) and cast("2018-06-23" as date)));
select
room_type.room_type,
room_type.room_typeID,
room_type.room_type_des,
room.room_id,
room.room_number,
room.room_typeID,
room.room_adultcapacity,
room.room_childcapacity,
room.room_img,
room.room_status
from
room
left outer join room_type on room.room_typeID = room_type.room_typeID
left outer join room_rate_default on room_type.room_typeID = room_rate_default.room_typeID
left outer join room_rate on room_type.room_typeID = room_rate.room_typeID
left outer join reservation on reservation.room_id = room.room_id and reservation.reserve_date_start between cast("2018-06-17" as date) and cast("2018-06-23" as date)
where
reservation.room_id IS NULL
group by
room.room_id;
in your example code there.. your room_id for the reservation is NULL... is that right?
where the inputed check in and check out dates of the present guest...
things like this make it confusing. Another attempt at clarification please:
Given a date range (fromDate and toDate):
Am I correct that you want:
To me, this means you're going to have a very large result set. You will get a list of all rooms for every day in the date range. Otherwise you will have false positives for certain dates. If that's what you want, that's fine. It's just a lot of potential rows to deal with (but it is not an abnormal request). To clarify: if you have 100 rooms in your hotel, and a date range of 3 days, then you will have 300 results.
If instead you are looking for a specific date:
Given a date (singleDate):
This is far more straight forward, but it makes looking up date ranges very difficult (as you have to run the query for each date in the range, and again you get a ton of rooms to parse through for each date. But that's ok if that's what you need).
So now this comes down to the "what are you trying to do" question... Make your data request match what you are doing.
Your tables are not complicated.
However, I am still struggling to have a plain English explanation of what you want (and is likely the root of your problem. If you can't explain it, you likely can't express it in code).
Can you explain in a simple way what you want to see?
When you say "available" rooms, it doesn't seem to make sense that you also want rooms that have a reservation.
Maybe.. can you give me an example of the output you expect to see?
So.. let me make sure I have your request right:
You want all rooms
-- show the reservation information when a room is reserved
-- limit by a specific date range
is this correct?
So.. I didn't pop this in a fiddle or anything due to laziness... however, I believe I found your problem:
so, you're pulling ALL ROOMS (and appropriate meta data) where the room ID is not in a single instance of reservation.room_id (in most cases, this will be NULL and will never match anyway because in the SQL world NULL != NULL, so you have to match on IS NULL).
If you want to do the "not in" method, it should be
where room.room_id not in (select * from reservation where reservation.room_id = room.room_id) --of course, you need date ranges
however, this is crazy style inefficient.
That basically makes every record in the result set run against a new sub query.
It may be better serving to do:
where reservation.room_id IS NULL --again.. dates
of course, this is only part of the way to your solution. You also need to make sure your date ranges for that reserved room are checked, and that the record is NULL for those date ranges.
I believe this should work for you...
select distinct
room_type.room_type,
room_type.room_typeID,
room_type.room_type_des,
room.room_id,
room.room_number,
room.room_typeID,
room.room_adultcapacity,
room.room_childcapacity,
room.room_img,
room.room_status,
reservation.room_id,
reservation.reserve_date_start,
reservation.
reserve_date_end
from room
left outer join room_type on room.room_typeID = room_type.room_typeID
left outer join room_rate_default on room_type.room_typeID = room_rate_default.room_typeID
left outer join room_rate on room_type.room_typeID = room_rate.room_typeID
left outer join reservation on room.room_id = reservation.room_id
where
reservation.room_id IS NULL
order by
room.room_id desc
Good Luck!
Ryan
Edit: You will find much joy in learning about …
couldnt you just do a grep/find (notepad++) on "function fnName("
Am I oversimplifying something?
Well.. currently there is a flood of people who put out youtube vids and personal blogs on that sort of stuff... you can write a page that indexes / ranks those tutorials / blogs by allowing users to both post them and vote on their usefulness. You can further categorize by application or makeup company or whatever... Sky's the limit.
Call it something topical like Blush or Accent or something hipstery like that :-P
Since this is for a class, it doesn't really have to be useful to anyone other than you...
I get that English seems to not be your primary language.
Let's try asking another way...
What class is this for?
What other instructions have you been given?
What are you interested in (hobbies, etc...)
.... are you asking what you should reasearch or just some random title?
I mean... no offense here... but you have a problem (you need a title generated).
Solve it (write a title generator).
SO requires a certain amount of "points" to allow replies. It's a community filter. It's annoying. However, as was pointed out with how hostile the internet is in general to everyone, it seems to work for them. It prevents people from tanking their own accounts because it makes it harder to get help when you really need it.
Reddit... it's just noise. If it's not on the front page (or like.. front 3 pages) I don't bother. They have so much churn and reposts that it all gets lost in the noise. It's also not a great place for "help" since it's just a public free for all forum.
I don't use Quora much, most because they have a registration wall to access data in some cases. Honestly, I don't use it enough to know what qualifies as a "public" post vs what you have to be registered for. If I find a Quora response, I tend to overlook it unless I don't have a choice.
DW is a community - SO and Quora are research filters. Reddit is a collection of communities. That's not to say StackExchange doesn't have its own community driving many of the sub Exchanges - but it's not quite as connected and open as say DW is. Within a few months of posting here I knew right away who was likely going to reply to a message, and what quality of an answer I could expect (and that was before I started looking at profiles …
Well.. here's my 2¢
1: Old threads (like.. some are 3+ years old!) being commented on. They need to be locked. A lot of the comments are outdated, spam, or often times not even on point with the rest of the thread. (Granted, this hasn't happened super recently, but there seems to be spurts of it throughout the year).
2: A majority of my time here is spent trying to help others. People just aren't posting things I can help with :-/ (not anyone's fault in particular, just my skill set doesn't cover some things). If there is nothing new for me to address on the first page, I tend to go back to work and that's my break... so.. I guess get more traffic so my breaks can last longer than 20 seconds please? :-D
3: DW doesn't have the name recognition or priority as Stack Overflow, and Im sure that drives a ton of potential traffic away. In general, though, if it's within the first couple spots people will visit just to see what's there. On top of that, SO was designed as a skim-to-find process. Some of the answers here require you to read. I don't mind it. Others who are in a hurry might.
4: The people here are what I find as a huge value over other places. There are 2 things that piss off mods here: Asking for someone to do your homework (which may actually push people away, sadly...) and spam / hate …
did the two suggestions above not work?
@janicemurby
try this:
else eval("$$rowcf['Variable'] = $rowcf['Value'];");
or
else eval("$\$rowcf['Variable'] = $rowcf['Value'];");
Im not sure what the escape for the 2nd $ will do... it seems odd to need it.. but again, I don't eval in php often, so I'm generalizing based on how other script languages work...
if you are really dead set on using column names to create variables, then you should just manually do that. I don't understand the need for what you are doing. If this is a lazy way to iterate over all results, then... I mean... there are far more efficient ways of being lazy :-/
Can you explain why there is a need to do that eval (or getting variables named as the column names)?
@Dani, I will admit.. as much as I love to program, I am very much a "point me at a problem" kind of person... I have a bit of a hard time wrapping my head around how to best use Dazah.
I get the whole Immediate user base kind of thing... it's smart. It makes a platform for an immediate audience. I just don't have any ideas that I have the kind of need for that, and my hobby programming tends to be for self use or to better understand a concept for work. But I am just one of however many active members there are on DW. Don't let my short coming (or just lack of need or even underststanding) be a benchmark for what others have or will need.
You built it. They will come.
@gdi888, start your own thread. You will need to post example code to see what you are doing to see if we can help.
By posting in your own thread, you will get much higher quality answeres specific to your problem, and you will make a lot of people less upset - it's a bit rude to hijack another thread for something pretty unrelated to it.
So.. first, did you write this?
Are you aware of what "$$" variables do?
(
for those who don't, they make a (scoped?) variable with the "VALUE" as the variable NAME; eg.
$a = "hello";
$$a = "world";
You now have $a = "hello" and $hello = "world";
)
I assume, then, that since you are attempting to eval code that is reading the value of the code as a string but is really an array "index" of a hash table that you are making some sort of odd behavior that cannot be resolved.
Which begs the next question - why are you using eval?
You are not being handed a stringified chunk of code that you need to arbitrarily execute on your server (and if you are, that's pretty dangerous). Your else can simply be served with (what I think is) identical behavior as:
else $$rowcf['Variable'] = $rowcf['Value'];
Of course.. YMMV.. I don't often write code that has a side effect of making variables for me. Generally, I find this to be confusing and often damaging behavior in a program. Such as, what if the $rowcf["Variable"] value turns out to be "$_SESSION" and you have now blown away a super global (of course, depending on scope here...)?
From a personal perspective, I would avoid doing what you are doing here and find another solution. However, I don't know your experience level, or if you know exactly why you are doing this. If you do, and you are comfortable …
You obviously put a lot of thought into this. Personally, I am either not experienced or creative enough to figure out how to exploit the system you created.
I get that DW is one giant "example" service using your platform. Lets take it a step further. I want to make an app. My app does X and I build it on Dazah for the oAuth black box aspect.
As I understand it - my users automatically get a dazah profile. Im a bit lost on what happens here. Are my users going to be randomly "connected" with other apps? Other users from other apps? If this is a bad use case lets move on to another.
It seems that Dazah is meant as an alternative to meetups or just networking in general. Professional networking is an interesting problem to solve... I get that the idea is to find people who have a need to meet others with a solution. If thats the case, some of the difficulties on building on top of this, especially with automation, is being able to guarantee skill level and professionalism.
I get you are sitting on a TON of user data and are looking to monetize. As I started this with - I don't think I am proficient in data mining or creative enough to use what you have done.
for PHP and PDF, I have used http://www.fpdf.org/ in the past (pretty sparse and straight forward but gets the job done well).
From that, I found this post on SO which suggested using https://www.setasign.com/products/fpdi/about
Which seems to solve your problem.
Your local MySQL configuration has port 33061 open? No firewall blocking the connection?
I also doubted the need for the \PDOException but I havent used PDO in quite a while now... that said, the only way you are likely gonna solve this at this point is to echo/vardump after each step and see what you got.
It's possible that if the port or URL is not acceptable/accessible, PHP just hangs and waits and times out.
I tried your assignment just to do it (because... why not, right?)
The way I solved your issue is I put all 4 lines in their own arrays, and made an array of arrays as the parent (so a 2D array, top level if 4 members deep, and the sub arrays are their respective lengths.
From there, you can do most of the work in a single for loop to fill the buffer. You can control which bucket you pull from (all caps is just using the 3rd bucket), otherwise you can randomly choose between 0-3 then 0-the respective size of the text block.
Im not sure which one gives you higher entropy, since your data set is longer you have more to pick from - where mine has 2 random ops to get the result you get from 1.
Over all, it was a fun exercise. Cool to see you figured a way to solve it on your own. Great work! :)
char caFoo[11]; // 10 characters + null terminator
memset(caFoo, 0, 11); //set all 11 buckets to null for ease of use
start a loop:
for (int ilup = 0; ilup < 10; ilup++)
Generate a random character
if ilup == 0, make sure it's a cap value, so either keep generating, or modify your generated char from a subset of available chars
else, caFoo[ilup] = generated char
when this loop is all done, caFoo will have all the characters available to you in the form of a null terminated "string"
you can then std::cout(caFoo); and you can see what is in the buffer.
you can then compare using strcmp(password, caFoo) and if it is equal to 0, then they match, otherwise they don't.
Get into the habit of giving your variables meaningful tips so you know what they are. I used iLup to denote an "int" value, "ca" for character array. There are other standardizations, but pick one and stick with it. When your code gets super long and you have to scan 10,000 lines youll be happier.
How do you expect to compare what the user has entered if you don't keep reference to the password you generated?
I stand by my original comment: start by filling a buffer with your created password, then use that to both output the password as well as compare it to what they input.
I would encourage you to fill a buffer with the user's password first, then display it - and in that local buffer you can do a strcmp.
Just my preferred way of solving your problem.
Otherwise... you have uncompleted code here.. not sure what part of it you need help with since there is no clear thing you want help with (and I'm not sure it works at all the way you intend... so... I don't even know where to begin).
so.. this worked for me using a pointer, but it still suffers from the offset. I believe that tinstaafl is correct in fgets including the last space/newline as a character in its read of the stdin pipe.
#include <stdio.h>
#define LENGTH 128
int my_bcmp (const void *b1, const void *b2, size_t len);
int main()
{
int b1, b2, len;
char str[LENGTH];
char *pStr = str;
printf("Enter length and two indexes followed by a string:\n");
scanf("%d%d%d",&len,&b1,&b2);
printf("Enter a string:\n");
fgets (str, LENGTH, stdin);
printf("len:%d strb1:%s strb2:%s str:%s\n",len,pStr+b1,pStr+b2,str);
printf("Mybcmp result: %d\n",my_bcmp(pStr+b1,pStr+b2,len));
return 0;
}
int my_bcmp (const void *b1, const void *b2, size_t len)
{
int i=len;
const char* r1=(const char*)b1;
const char* r2=(const char*)b2;
while (i-- > 0)
{
if (*r1++ != *r2++)
return -1;
}
return 0;
}
in an effort to prove that theory, we can simply convert the char at str[0] to a value and see what it has.
ex:
printf("Value at str[0]: %d", *pStr); //get the numerical value of the char at this memory location.
when I added that line after fgets(...), I got a "32" which is the ascii value for a space.
http://www.theasciicode.com.ar/ascii-printable-characters/space-ascii-code-32.html
To continue answering your second question - a "string" in a buffer basically walks down contiguous memory until a null terminator is found. If you have a pointer to the beginning of the "string" you can keep going until you find a null (0). And if you want to break your code / the world, go ahead and …
That, sir, is a fantastic question.
My assumption is that the inline cast to a char *
is somehow mangling the memory space on the stack, or the assumption of the pointer starts at a negative index to account for the pointer itself...
no idea :-/
That being said.. why not just make a pointer and use it?
at some point, you are using a loop. The variable $i is being assigned a value, and at some point that value is 6.
if $i = 6 AND 6 + 5 is 11 ----
it appears your problem is that you are trying to access a member of $list['photoID'] at member 11, and it does not exist.
without seeing the output on line 67 it's hard to say, but my assumption is that you are geting an output like...
insert into foo (a,b,c) values (1,2,3,1,2,3,1,2,3,12,3) -- kinda suprised this doesn't throw an error...
when instead I believe you want something more like
insert into foo (a,b,c) values (1,2,3), (1,2,3), (1,2,3), (1,2,3) ....
You can also buy an sms gateway device, or just a phone that allows AT commands. From there it costs however much your local carrier charges per month for access to their network.
Alternatively, every phone number is an email address to their respective carrier. Ex: 555555555@tmomail.net will send an sms to that phone number on the tmobile network. They will not forward, however, by you have to know the network for this method to work.
I short - for commercial or production, there is no good free option at the moment.
So fusion charts requires their data in a specific format. You can choose to parse that data (as they have), or you can write a conversion script to output the format they expect from the data you have.
You gotta do some of this on your own. I get fusionCharts is not the nicest of APIs to work with, but it's not terrible. At the end of the day it's all JSON and javascript primitives (mostly strings cause fusionCharts is just weird like that). As I suggested in another post, use the fiddles to do a bulk of your work (since you start from a working example), and you will start to see patterns in how they want things set up. (also, I noticed you are using AngularJS - in the fiddles you can easily import that to make the data look / work the way you want). Their docs are really only useful, in my opinion, after you play around with the fiddles so you can visualize what they are trying to convey.
I don't use Angular, so if you can rephrase your question about x.IDR and what you are expecting, I can try to help - otherwise, maybe someone with a bit more experience with Angular can chime in.
When dealing with fusion charts, I encourage you to just go striaght to their fiddles.
http://jsfiddle.net/s7t8F/5379/
I made that with a color change to one column. You likely forgot the comma.
It's a cool thing to look out for. Thanks for the update :)
Is this a MS issue or just developers being lazy and not putting their toys away? (or both)
How many of those handles may have been ghosts that are just doing nothing? How many were socket connections that were active instead of using select or IOCPs?
Javascript (JS) is a top down JIT. Which means if the DOM element exists before the JS gets called, it will be available for use.
In example 1, your function declaration and call happen before "demo" is available on the DOM (in the body element, however you want to think about it).
In example 2, the element is declared first, and therefore available for JS to use.
In the wild, you will see a lot of websites put code library or include type script at the very bottom of the page for 2 reasons.
1 - you load the HTML and the DOM displays to the user even if there is a network hiccup to the provider (akamai, or whatever)
2 - you are guranteed all elements are rendered and available on the page
That said, the "right" or "javascript" way of doing this is to have a window "onload" handler (window.addEventListener("load", fnYourFunction)) which will fire off all script after the DOM has finished loading and has parsed all elements.
Link for reference: https://developer.mozilla.org/en-US/docs/Web/Events/load
Edit ---
This leads to some of the wonky ways that JS uses DOM elements and references them. For example, in your example #2 you could have just put :
demo.innerHTML = myFunction(4, 3); //dont do this youll make people mad.
because all elements get referenced in the global scope of JS
My first suggestion - stop using a, b, c, and i as variable names. Give them meaning, they will help.
My second suggestion is to consider using a placeholder as a loop helper - just because you are looping though "i" doesn't mean you have to use it for anything other than how many iterations you have gone through.
eg:
int iLup = 0;
int iStep = 1;
int iMax = 200;
int iVal = 1;
for (; iLup < iMax; iLup++)
{
if (iStep == 1) //(this can be step "a")
//concatenate stuff
else if (iStep == 2) //(this can be step "b")
//do some math and concat...
else if (...) //(etc....)
iStep++;
if (iStep > 6)
//do something special here ;)
}
using std::cout is fine as a buffer... but if you use the method I suggested you are going to have do either do an additional if check to see if iLup == 199 to not append the final comma, or get some magical buffery (yay char arrays!) and build your string into memory before outputting the string. If you do that, rememeber that all "strings" in c/c++ must be null terminated :)
You will probably need to learn about itoa() and strcat_s() and either learn about pointers (to point to the last comma and convert it to null (0)).
Alternatively, you can learn more about the std::string (#include <string>) object and use that instead. Either one should be acceptable for academic work.
Likely, if done right - the car will just drop you off at the door and come back when you call it. The decision to find a place to idle/park or go into a loop will be one of necessity (I need to recharge / nowhere to loop) or convenience (owner flagged it as a 15 minute stop, so drive around the block a few times until past a threshold and then park).