ryantroop 177 Practically a Master Poster

Consider why you would get this result logically --

Your check states that if $rows is not an array, or the length of the array is NOT 1, then it's a failure.

In PHP, var_dump() is your friend (your best friend. Take it out to dinner and treat it nice sometimes. He works so hard for you!). It will help you debug almost anything. In this case, on line 25 I would put

var_dump($rows); 
exit(); 

and see what the output is.

You will likely find that rows is not an array, but instead may be some sort of string or object - alternatively, you may have multiple results or no results, and you will have to check your query to make sure it is doing exactly what you want it to be doing. Perhaps you will need more constraints in your where clause to limit your result set, though I find it strange that you would allow multiple admins with the same username (however, in testing you may have accidentally inserted the same user multiple times).

Hope that helps,

Ryan

ryantroop 177 Practically a Master Poster

you have no height, therefore the propery should be ignored. If it is not, then the ones adhering to your markup are likely at fault, or "figuring out" what you meant.

Try adding height 100% to body, html and see if that fixes your problem.

ryantroop 177 Practically a Master Poster

You would need to iterate over your $data array.. soo...

for ($Lup = 0; $Lup < sizeof($data); $Lup++)
  echo StringifyCartArray($data[$Lup]);

Or some variance of that, depending on your need.

ryantroop 177 Practically a Master Poster

it all depends on your data structure... I cant possibly answer your question without knowing more about how the data looks.

From your example, your most basic data had only 4 parts, so it would be silly to iterate through only 4.

If you have, say, 50 fields, then yes - iteration is likely the best method, but then you kinda lose the customization of your string based on index...

youre asking theory questions at this point - instead, why not show an example of what you are actually working on and you will get far superior answers that are more relevant to your exact problem. I can show you all the tools in the world by pointing you to php.net, but without knowing the job it's impossible to tell you the right one. (think, jack hammer to hang a picture? I think not..).

ryantroop 177 Practically a Master Poster

In my opinion...

extract() can be dangerous if you have an array key that matches a variable you already have in use in the namespace. In reality, all that extract is doing under the hood is looping through they array with a foreach loop, and using the $key part to declare a variable for you (to many developers, this kind of automation and magical creation of variables is bad since you did not declare it explicitly and therefore risk overwriting something of your own on accident, making a near impossible to find bug in your code).

If your array is always going to be the same, I would encourage you to make a sub function that processes by index, something like:

function StringifyCartArray($aArr)
{
  return $aArr[0] . " ( " . $aArr[1] . " x " . $aArr[2] . " ) " . $aArr[3];
}

Or, if this in a function already, simply access the variables by array index.

Of course, in the example above, if you have a two dimensional array, ($data), you would pass in $data[0], eg:
$message = StringifyCartArray($data[0]);

Reasoning:
As I understand it, arrays in PHP are not "really" arrays - they are more like iterable hash maps (like in javascript). These hashmaps are stupid fast already, so why bother iterating if the data is never going to change? And even if it does, if you abstract it out to a function, all you have to do is change the function to consume the …

ryantroop 177 Practically a Master Poster

I am a little confused as to what you are trying to do...
You have the solution to your question in your original code, it seems.

Can you show an example of your expected output, please?

ryantroop 177 Practically a Master Poster

I also question the need for making a file for each email sent, especially by name of the sender..

If you have database access, you should probably use it. You can templatize a single php page, and get the values from the database for that user. That way, you also have a paper trail of all the emails you sent out, and you wont be sucking up so much disk space making new files.

Just my 2c

cereal commented: +1 +14
ryantroop 177 Practically a Master Poster

Is your table column a varchar utf-8?

When you set it up, did you use this syntax:
myColumn varchar(10) character set utf8

ryantroop 177 Practically a Master Poster

Looks like StefanRafa is not a valid column name in your table kladilnica

Try adding quotes around '{User}' on line 18.

Stefce commented: Thanks that helped :D +2
ryantroop 177 Practically a Master Poster

Refresh may have lost your post data. Any number of things can be causing you trouble.

Without seeing all of your code and knowing our work-flow, it's impossible to give you a better answer that piece meal like I have been.

ryantroop 177 Practically a Master Poster

So you are getting the result of this line:

<?php echo $fetch_info['check_list'];?>

The value in there is an array. Instead of echo, try var_dump($fetch_info['check_list']); to see how you need to iterate or consume.

ryantroop 177 Practically a Master Poster

Good? I think... ?

So did this solve your problem?

ryantroop 177 Practically a Master Poster

Ahh..

It has been a while but if I recall, header() does not implicitly pass POST variables to the redirect.

Since you are using a database, why not use it as it is supposed to be used? Once it is saved, it is ready for consumption. Your "profile.php" page should remember the user (SESSION['last_id']), and should make a call to the database and retrieve what it just saved. While that seems kinda rediculous (because, you have the data why not just use it right?), this will allow you to 1) Debug your database and make sure the insert works, 2) have a re-usable profile page that can be accessed any time you know the user ID / session ID.

Just my 2 cents there.. I'm sure if I am misinformed about HEADER/Redirects not passing POST data, someone will correct me.. but Im pretty sure that's still the case.

Good luck!

Ryan

ryantroop 177 Practically a Master Poster

Im very confused as to how these pages are related....

On the one page, you have a form that posts to itself (the same page), and inserts into the database.

On the other, you have a page that is expecting a post from said form - and when it's not there, it echoes "You didn't select any interests."

When exactly do you post (or submit a form) to "profile.php"?

ryantroop 177 Practically a Master Poster

I believe you capitalized "Submit" on line 10:

`    if (isset($_POST['Submit']))`

Make that lower case, and see if that helps.

ryantroop 177 Practically a Master Poster

Well.. since no one else is saying it...

ASP and CSS are completely independent technologies.

ASP is a server side language that CAN produce HTML.

In that HTML, since you are in control of your ASP, you can output classes, etc... Those classes can then be used to control layout and styles using style-sheets. If you wan't quick and dirty, you can also output style directly into the HTML tag that ASP produces.

Now, if you are talking about server side scripting delimiters (these or these), then your value portion in the example:<%Response.Write(value)%> will have to have formatted HTML with the classes/styles as explained above.

ryantroop 177 Practically a Master Poster

You are not asking the function to return the set, you are asking the function to return the second element of the set. (return x[1])

If you want the set returned, simply return x

ryantroop 177 Practically a Master Poster

Also, as a matter of practice and good coding, please don't use

"select * from..."

with "production" code. It's slow, returns way too much data most of the time, and if you ever add a column you will be returning it without the need of it. Be explicit, and save yourself problems in the future. It will also make debugging easier for you, since you will know exactly what you are asking for, and helps the SQL engine return more meaningful errors to you (such as, invalid column name, etc..) where as PHP will just ignore the request because a mistyped column name simply doesn't have a map in the hash table.

ryantroop 177 Practically a Master Poster

Im not sure what you are asking..

If the column is varchar, what is being passed in as the value? Is it NULL? A number? Are you getting a SQL error? Have you tried doing a var_dump on $r and seeing what is actually in there? Are you sure buy_temp has a valid "option" column?

So many points of potential failure, it's hard to debug from what you have given...

ryantroop 177 Practically a Master Poster

There are multiple tutorials on this.
Use google - "php and ajax" The W3Schools one is pretty easy to follow, and many others will help you learn what you need to know.

Since you will have user id's and other such security, PHP sessions will help you. Feel free to read up on them as well.
google - "php sessions"

ryantroop 177 Practically a Master Poster

It's likely something you will have to contact the host to help you with. Most of the time, shared VMs will have a hard cap limit on what they can execute and how many resources they can take up, based on what you pay for.

As an alternative, how about you limit your query down to something a little more realistic. If you are getting that many results with a 10gb database, what good is all that data doing you? You may consider pagification, or simply being more concise with the data you are looking for.

You may also wish to look at their TOS as it references exactly what is happening to you :-/

TL;DR - call them or fix it so you're not pulling so much data.

ryantroop 177 Practically a Master Poster

Im sorry if this is not helpful, but why not just use tinyMCE? They have already gone through all the headaches that you are currently dealing with.

Ranges are weird, and are inconsistent across browsers. If you plan on being backwards compatible at all, you will find that your code will become bloated very quickly. If this is a personal project and you just want to learn more about it, just keep on trudging through until you get it to work on chrome, then modify for IE. When you are content with it all working, then go back and cry when you try to make it work for firefox.

Truthfully, I don't really remember all that had to be done to get this stuff working.

Likely, you are using a contentEditable div, and when you place any form of structure HTML into said div, the browser is parsing it and treating it as an actual element instead of the text you are attempting to display. Maybe try to convert all html entities to their escaped formats (&lt; etc..) and see if that helps?

Good luck! ..really..

ryantroop 177 Practically a Master Poster

Well... you have strings... you can store those strings and associate them to a player.
You have a comma delimited list of card numbers. You can have a table that has the columns: id, playerID, gameID, cardNo and insert them individually, or use a stored proceedure that takes the comma delim. string, and inserts them.

Your options are plentiful.. think about why you are putting this in the database, and what purpose it will serve, and that should help you come up with a schema for data tracking. You know the rules of your game, and you know the plays that will be made. Knowing this, you are the only one that can come up with a schema and method for storing, updating, deleting, and creating data as you need it.

Sorry bud, your question is too vague to give you any real answer :-/

ryantroop 177 Practically a Master Poster

You can use a combination cookie/ip as well as javascript localStorage. You can hold a session in localStorage that will re-initialize regardless of cookie or ip change. However, localstorage can be wiped out just as easily as cookies. Most people dont bother clearing cookies anymore, however.

The only way you can realistically track an individual's activity is by forcing them to log in through some fashion, and keeping that session data available. IP Addresses, LocalStorage, and Cookies, are tools you can use to track, but all of them are (as you stated) deletable or mutable in some fashion.

The other option is to look into browser fingerprinting. However, this too is mutable in some fashion (uninstalling a plugin, or changing a timezone), and therefore if you really want to look at uniqueness, you will have to implement a combination (or persistent cookie / evercookie), or have some sort of login mechanism.

Realistically, IP addresses don't change very fast. You can likely timestamp an ip address, and if it is within some range (1 week? 2 weeks? a month?) then you ignore the click. You can combine this with any sort of cookie / session / finger printing you like, but ultimately, it will be prone to failure somewhere along the chain without a user initiated session.

ryantroop 177 Practically a Master Poster

As a second year CS student, you should know code. You know your types, and you likely are aware of objects and their implementation. If you have written in any language other than C++ (which, as a 2nd year CS student I certainly hope you've had some exposure, even if it's doing things independently), then you know the foundations for success.

If you are unsure as to how to get started with C++ (what IDE to use, how to compile, how to split between header and source files, how the notation is different than other languages, etc..), then ask that - don't give your homework and expect someone to do it for you.

This is a simple problem asking you to apply your knowledge. Break it down into small pieces - start writing something! You know what you need and how the pieces will all relate. When you get stuck, then come back here and ask for more concrete help. No one in the world will make do your homework over a message board.

You have the world at your fingertips - use it to get started and figure stuff out. A good portion of your real world experience in programming will be learning how to use google to get started on your projects, and taking requirements like this and turning it into tangible code and a working product.

Have at it! And good luck!

ryantroop 177 Practically a Master Poster

including stdlib.h and time.h...

     srand (time(NULL));
     int iRand = rand() % 20 + 1;  //give me a random number between 1 and 20

More info can be found here:
http://www.cplusplus.com/reference/cstdlib/rand/

Note, however, that this method is only pseudo random, as noted in the link. Other options that can better support a uniform approach to random generation in C can also be found here:

http://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c

note: this is not my code, but from the link above --

    /* Returns an integer in the range [0, n).
     *
     * Uses rand(), and so is affected-by/affects the same seed.
     */
    int randint(int n) {
      if ((n - 1) == RAND_MAX) {
        return rand();
      } else {
        // Chop off all of the values that would cause skew...
        long end = RAND_MAX / n; // truncate skew
        assert (end > 0L);
        end *= n;

        // ... and ignore results from rand() that fall above that limit.
        // (Worst case the loop condition should succeed 50% of the time,
        // so we can expect to bail out of this loop pretty quickly.)
        int r;
        while ((r = rand()) >= end);

        return r % n;
      }

}
ryantroop 177 Practically a Master Poster

I have never used SQLite, so I cannot comment on that one - however, if you are going to be using an internet based system of data management, MySQL is a fine choice.

Without some sort of pre-processing, and making some sort of tokenized batch and sent to either a stored proceedure or a series of functions to untokenize, there is little you can do to run a mass update like this. However, tokenization should be very fast, and since it's just string manipulation up front whatever you are using should also process very fast.

The speed deficit you are experiencing is likely that you are doing thousands of inserts, which causes a lock on the tables, which in turn will have to adhere to any foreign key constraints and locks you have in place. No matter what you do, since you have to insert or update, you will always have these table locks, even with tokenization - however, if you tokenize you take one more thing away from your database software to have to deal with.

On the other hand, if you are pre-parsing, and all you are doing is running the same "insert into A (col1, col2, col3) values (val1, val2, val3);" over and over, you can't really get any faster than that. At that point, you will have to see if your processing code is taking long or the database (or both), and begin to optimize based on which is taking the longest. If you are trying …

ryantroop 177 Practically a Master Poster

For some reason I cant edit, so... A JavaScript socket*

To expand, you would still use polling for older browsers and use the socket for newer ones.

ryantroop 177 Practically a Master Poster

For modern browsers you can look into making ajs socket but you will need to write a custom socket server based on the spec (rfc).

ryantroop 177 Practically a Master Poster

I had a typo on line 10. It should read :

var myFriends = [
{firstName: "Bertrand", lastName: "Michel"}, 
{firstName: "Michel", lastName: "Bertrand"}, 
{firstName: "Henri", lastName: "Michel"}, {}
]; //this is an array of objects
var myFamily = {lastName: "Michel"}; //this doesnt have to be an object, but whatever.. in fact, you don't even use this?
var myFamilyMembers = []; //this is an empty array
var oObj; //declare outside to save cycles
for (var i=0;i < myFriends.length;i++) { //iterate through the array
    oObj = myFriends[i];  //set oObj to be the member of the array by index
    if (oObj.lastName && oObj.lastName == "Michel")  //check the value directly (I think you mean here oObj.lastName == myFamily.lastName)
        {
              myFamilyMembers.push(oObj);
         }
console.log(myFamilyMembers); //Im not sure you want to do this with each pass, but whatever floats your boat...
}

I encourage you to read the comments, and follow along with what the code is actually doing. You are misunderstanding the types of loops presented.

You are confusing an iterative loop (for loop) with an object lookup loop (for-in loop). They are not interchangable in any way, and will give completely different results. Example..

for (var i = 0; i < 10; i++) //this says, as long as i is less than 10, continue doing this
{ 
    console.log(i); //write the value of i to the console
}

for (var c in oObj) //walk through the object oObj, and let the variable c represent the "name" of the parameter
{
  console.log(c); //write the name of …
ryantroop 177 Practically a Master Poster

In your example, myFriends is an array of objects. (Ln. 1)
Your iteration is for object notation on Ln. 8. the for ... in construct only works on "objects" that have properties. Now, since everything in javascript is an extension of a root "Object" (other than primitives) your code does not fail. All you have done is map the variable "friend" to be a reference to a property of an "array object" that you are then iterating through. You are lucky that you are not getting any errors, as you are trying to reference a property that simply does not exists in the properties of an array, and the JS VM should have considered this a problem.

Here is what you are trying to do...

var myFriends = [
{firstName: "Bertrand", lastName: "Michel"}, 
{firstName: "Michel", lastName: "Bertrand"}, 
{firstName: "Henri", lastName: "Michel"}, {}
]; //this is an array of objects
var myFamily = {lastName: "Michel"}; //this doesnt have to be an object, but whatever.. in fact, you don't even use this?
var myFamilyMembers = []; //this is an empty array
var oObj; //declare outside to save cycles
for (var i=0;i < myFriends.length;i++) { //iterate through the array
    oObj = myFriends[iLup];  //set oObj to be the member of the array by index
    if (oObj.lastName && oObj.lastName == "Michel")  //check the value directly (I think you mean here oObj.lastName == myFamily.lastName)
        {
              myFamilyMembers.push(oObj);
         }
console.log(myFamilyMembers); //Im not sure you want to do this with each pass, but whatever floats your boat...
} …
ryantroop 177 Practically a Master Poster

You cannot, in any fast way, compare objects directly in JS.

The only way to check values is to iterate through the object and compare values directly for what you are looking for (or, as you pointed out, simply check the value directly). Since all an object really is on the inside is a giant hash map, lookups like this are very fast - as long as you know the key.

Your example is a little vague on what you are trying to accomplish. What is your end goal, and maybe someone can point you in the right direction.

To iterate, in case that was your question, you would do something like this:

//I am looking for "two"
var oObj = {a: "one", b:"two", c:"three"};
for (var cParam in oObj)
{
    if (oObj[cParam] == "two")
        {
              console.log("Found!");
              break;
         }
}
ryantroop 177 Practically a Master Poster

You... Have an unexpected if.. You can't concat with a logical step like you are doing... And if you read your code closely you will see you are not actually doing a logical operation at all, as there is no outcome.

Instead of doing dot notation to concat, try writing it the long way and see where all your errors are...

To do a logical concat like you expect you will need to use a ternary logical statement.

ryantroop 177 Practically a Master Poster

So.. not gonna lie.. but your echo's really hurt my eyes and my head.. I don't understand their purpose...

for example, this line:

echo $insert = mysqli_query($connection, "INSERT INTO packages (pkg_name, pkg_price, month_price) VALUES ('$pkname', '$pkgprice', '$mnthprice')");

I read this to say "please output the result of the action of setting the variable $insert to the return value (in this case, true or false) of the function mysqli_query, which in turn takes connection and the query provided."

In no way are you going to output anything useful. $insert will always set a value, true or false, and therefore you will always echo true or, more likely, nothing at all.

but anyway...

because you are sending an array to the server, you will have to iterate the data and insert using a batch query, or a bunch of individual queries for each data set.

It may help you to, instead of echo, to use var_dump() on things like $_POST. In fact, I encourage you to var_dump($_POST); right before your include and see what is there so you can better understand what your data looks like.

If, for any reason, var_dump($_POST); is empty or does not contain the data you expect, you may need to look at your server configurations, or add encoding on your forms so the server knows what to do with the incoming data.

I also would think that echoing before doing a header redirect would cause an error, or at the very least confuse the heck out of …

ryantroop 177 Practically a Master Poster

onclick="Calculate();" (line 65)

Just add the parens.

Right now, your onclick method is just a pointer to a function, but does not actually execute said function.

ryantroop 177 Practically a Master Poster

If I recall, a websocket is just an HTTP request that gets upgraded to a persistent connection. I haven't read the spec entirely, but it's much like a 302 response, but for the WS upgrade.

ryantroop 177 Practically a Master Poster

likely because you are passing limit twice, once as a const int, and then trying to cast it as an int when it is clearly a const int.

My C++ is not the best, but Im pretty sure you can't do what you are doing :-/ You stronly type for a reason, and it's not so you can not use it.

Your Q2 will come when you fix your code in Q1.

ryantroop 177 Practically a Master Poster

The query itself will determine if you have data.

"select * from table where id = 1 and date > dateadd(d, -90, NOW())"

(of course that's psudo-code so YMMV)

If it returns no results it basically means you have no data.

Basically, your "if exists" check can be summed up by looking at your data and seeing if it exists :-P

ryantroop 177 Practically a Master Poster

I am not familliar with Sadad, but if they are like any other payment gateway, they will have an API that you must process data in a specific way and send the data to them. You will have to contact them to find out if they have a pre-made interface for ASP.Net. If not, you will have to get example code from them in a language you do understand, and translate it into ASP.Net for your particular use.

tl;dr: ask Sadad.

ryantroop 177 Practically a Master Poster

I too went from teaching to programming. I had the same worry as you did. The best advice I can give you is to bring code examples with you to any interview, stuff you can explain in your sleep, and be prepared for the interviewer to push you past your comfort area. They will determine if you are what they are looking for, and if they want / need to train you.

Your skill set may be perfect for an older code base, and your experience may be perfect for a company looking to groom a specific style of programmer. If you know your fundamentals, can explain at least SOME code and know the principles behind what you are doing, and are friendly and easy to work with then it really comes down to if they like you and if you are what they are willing to invest in.

If you want to be a professional programmer, be a professional programmer. If you see yourself there, it will be.

As a side note, I learned more from sitting in a handful of interviews than I did in any academic setting - simply by being exposed to production code and being challenged to use my knowledge. You will get to read some interesting stuff, and see how people tackle problems differently than you do, or how you were taught - sometimes in ways you didn't even think of trying!

Interview for whatever position you like :-) What's the worst that will …

ryantroop 177 Practically a Master Poster
ryantroop 177 Practically a Master Poster

http://www.w3schools.com/svg/svg_polyline.asp

You will notice the line has a "stroke" which basically maps to thickness in pixels.

However, I really think you are looking for stuff like...
http://svgopen.org/2010/papers/28-Fractals_Visualization_Using_SVG/
http://codepen.io/collection/aBwGo/

Or, if you prefer a flash version..
http://www.danfergusdesign.com/classfiles/oldClasses/VCB209-2Danim/exercises/vineMask.php

You will likely be using similar methods of creation no matter the platform (other than a canvas, since that will be entirely pixel based). With SVG you will not be able to do multi-thickness lines, but instead can create <g> (groups) that can render as you want them to, and using masks or other tweening concepts (animation techniques) you can achieve your desired result.

Hope that is what you are looking for.

ryantroop 177 Practically a Master Poster

May just be a preference thing.. but making tables on the fly like that is probably not a good idea (and resource heavy), and then you iterate through your table list with each request...

Just by reading your code, trying to figure out what you intend to accomplish is difficult...

That said.. without knowing what your scipt is sending (or the var_dump($_POST)) it's impossible to figure out why you are getting the multiple updates. Since you are iterating through all permutations each time you send a request, I would assume your data is not correct coming to your code, and it is working quite admirably and doing exactly what you told it to.

also, for inline onclick handlers, you don't need "javascript:" anymore. Most browsers know it's javascript (of course, Im assuming you're writing HTML/4+, so YMMV).

ryantroop 177 Practically a Master Poster

I dont mean to ruin your day, but Flash may be better suited to your goal. It is the best of both worlds (SVG and Canvas) and has built in ECMA support for doing things like fractal art.

If you are dead set on using canvas, the only way I can think of doing what you are doing is to use the canvas itself as a pixel map, and then figuring out what you want to do artistically based on what colors (or fill) is at any given pixel position. You will likely have to keep track of special "root" points that represent the base or stem of your drawing, which you can then refer to when growing or shrinking your lines.

Alternatively, with SVG - you can use polylines (which are just a series of points) and give them thicknesses, and have multiple lines with multiple thicknesses being drawn as an overlay. You can also do them point by point as you would a canvas (but that would be obnoxious). With SVG you can also try using CSS (or CSS Like) transforms and other visual "tricks" to accomplish your goal... that's an interesting problem to solve..

ryantroop 177 Practically a Master Poster

Do you have a real world example of your goal? Or a mock up? Not sure what you are envisioning.

Side note: SVG = Scalable Vector Graphics. It's sole purpose is to be a graphic that is scalable.

ryantroop 177 Practically a Master Poster

The canvas is simply a grid. 0,0 -> whatever you define.
Since you know this, you can keep, say, an object that has each item being an array of points:

obj = { Line1: [{0,0}, {5,5}, {16,16}]};

You can obviously expand on this simple construct and have a line weight, color, etc... whatever. Basically, though, you have your needed info right there. If you want to move said line - you would have to figure out if an area you clicked on contains content (is it transparent or filled?), and then run through your map and find what crosses those points.

This gets super complex (you would actually have to keep an array of all pixels drawn for this to work, I think), and it's the reason I prefer SVG for content that needs to be edited post rendering.

The more realistic option is to make a new canvas layer for each drawing and have them stack and maintain their own handlers. It still gets very messy and hard to maintain, in my opinion. Others who may be much more clever, experienced, or smarter than I have probably done it.

ryantroop 177 Practically a Master Poster

On a canvas, once the pixels are drawn they are permanent, and reference to the individual line draw is lost. If you want to modify individual points you have a few options.

  • Create new canvas layers for each draw pass
  • keep an array of points (but this still leaves a lot of other logistics to figure out)
  • use SVG instead.
ryantroop 177 Practically a Master Poster

The canvas is a coordinate system. It is entirely pixel based (I may be over simplifying..), and it starts at left 0,0.

ryantroop 177 Practically a Master Poster
function func(param = <?php echo json_encode($row[0]); ?>) {

This is most definately a syntax error in javascript. :(

ryantroop 177 Practically a Master Poster

Your JS function needs to accept a parameter, and the PHP ouputs said parameter...

while($row = mysql_fetch_array($res)){                       
echo "<tr>".
"<td> <p><button onclick=func({$row[0]}) >View</button></p>  </td>" 
    ."</tr>";

is technically "fine" (assuming $row[0] actually prints something), though I do not think you should have a <button> tag inside a <p> tag. You may want to replace the paragraph tag with a <div> instead, but I don't know your markup or your particular needs.

however, your script should be something like...

<script>
function func(foo)
 {
    window.open("window.php?myParam="+foo,'Eployee Details','width=545,height=326,resizable=yes,scrollbars=yes,status=yes');
 }
</script>

and then window.php should accept a GET paremeter of myParam (or whatever you want to name it).