C# Interview tomorrow

Hello fellow programmers.

I know this doesn't have anything to do with code but I really need some advice. I have a .NET(C#) interview tomorrow for a junior vacancy. The problem I have is that all my experience is based on PHP. I have a good understanding of the fundamentals of OOP which is why I am looking to make the switch to C#. I have worked on my own at home, gone through a few books but I have nothing to show in terms of .NET projects. All my experience is in PHP. I have been working with PHP for 6 months but I have decided to make the switch now rather than later because I enjoy working with C# although I still have a lot to learn. I also feel like it offers better career prospects. How would you approach the interview if you were in my position?

Please help me.

Regards

You my friend are a genius! It was that URL

I am having trouble getting this example to work. I posted exactly like it is put on the google documentation but it just won't work for some reason. Some please help me, am I doing something wrong. The link to the documentation is https://developers.google.com/youtube/iframe_api_reference#Getting_Started

The code I am using is

<html>
  <body>
    <!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
    <div id="player"></div>

    <script>
      // 2. This code loads the IFrame Player API code asynchronously.
      var tag = document.createElement('script');
      tag.src = "//www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      // 3. This function creates an <iframe> (and YouTube player)
      //    after the API code downloads.
      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          height: '390',
          width: '640',
          videoId: 'u1zgFlCw8Aw',
          events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
          }
        });
      }

      // 4. The API will call this function when the video player is ready.
      function onPlayerReady(event) {
        event.target.playVideo();
      }

      // 5. The API calls this function when the player's state changes.
      //    The function indicates that when playing a video (state=1),
      //    the player should play for six seconds and then stop.
      var done = false;
      function onPlayerStateChange(event) {
        if (event.data == YT.PlayerState.PLAYING && !done) {
          setTimeout(stopVideo, 6000);
          done = true;
        }
      }
      function stopVideo() {
        player.stopVideo();
      }
    </script>
  </body>
</html>

Hey there buddy, I'll try and help you.

<?php
 $a= array(12,5,78,10,63,11);
 $size=count($a);//counts elements in the array
 sort($a);//sorts elements in the array, no need for those loops    
?>

To find out more about sorting arrays take a look at http://php.net/manual/en/array.sorting.php

I hope this helps

Oh yeah, I didn't realise that lol. Thank you yet again. You are a legend.

Solved, I just copied the for statement into every case. Thank you so much for your help.

Thank you so much for taking timeout to help a newbie. I like the idea you gave me but I just can't get it to work. Any idea what I'm doing wrong?

[CODE]
<html>
<head>
<script type="text/javascript">
function loadGame(level){
var values;
switch(level){
case 'hard':
values: [7,8,9];
break;
case 'normal':
values: [4,5,6];
break;
default://easy
values: [1,2,3];
}
for(i=0;i<=values.length;i++){
document.getElementById('n'+i).innerHTML= values[i];
}
}
</script>
</head>
<body>
<div id="n0"></div>
<div id="n1"></div>
<div id="n2"></div>
<input type="button" value="easy" onClick="loadGame('easy')"/>
<input type="button" value="normal" onClick="loadGame('normal')"/>
<input type="button" value="hard" onClick="loadGame('hard')"/>
</body>
</html>
[/CODE]

Hi guys, please help me out with this. I'm seriously considering suicide. I have three buttons that load numbers into divs. The problem I'm having is that the buttons only seem to work once. Any idea as to why this is happening? You help will go a long way.

[CODE]
<html>
<head>
<script type="text/javascript">
var easyGame = {
easy: [1,2,3],
s: 1,

    easyLoad: function(){
        for(i=0;i<=this.easy.length;i++){
        document.getElementById(this.s).innerHTML=this.easy[i];
            this.s++;
        }
    }//end of easyLoad function

}//end of easy game

    var normalGame = {          
    normal: [4,5,6],
    s: 1,

    normalLoad: function(){
        for(i=0;i<=this.normal.length;i++){
        document.getElementById(this.s).innerHTML=this.normal[i];
            this.s++;
        }
    }//end of normalLoad function

}//end of normal game

    var hardGame = {        
    hard: [7,8,9],
    s: 1,

    hardLoad: function(){
        for(i=0;i<=this.hard.length;i++){
        document.getElementById(this.s).innerHTML=this.hard[i];
            this.s++;
        }
    }//end of hardLoad function

}//end of hard game

</script>
</head>
<body onLoad="normalGame.normalLoad()">
    <div id="1"></div>
    <div id="2"></div>
    <div id="3"></div>
    <input type="button" value="easy" onClick="easyGame.easyLoad()"/>
    <input type="button" value="normal" onClick="normalGame.normalLoad()"/>
    <input type="button" value="hard" onClick="hardGame.hardLoad()"/>
</body>

</html>
[/CODE]

thank you for taking time out to answer my question. I was really impressed by your explanation.

I've had a nightmare over the past couple of weeks wondering why my code wasn't working in ie. I've finally realised that it was because I was using textcontent which works fine in firefox. I tried using innertext and it worked fine in ie but stopped working with firefox. Chrome seems to support both. I switched and used innerHTML and it works fine across all three browsers.

My question is what is the different between innerHTML and the other two and is it safe to use?

Your question doesn't make sense...I think you have a field with a timestamp and you want it to be displayed as a normal date in PHP. Is that what you mean. I don't know how to do it but I'm sure ARDAV can help you.

I've figured out what it is. Apparently Chrome and IE have issues with certain scripts running on local machines. I ran IT in from my localhost instead and it worked on all browsers. Thank you so much for your help. It's people like you who take time out to help others that makes the difference. THANK YOU !!!

[QUOTE=iamthwee;1773180]I used the same xml file as you. I just renamed it to cd.xml[/QUOTE]

I've just realised. It works in Firefox but not in chrome and internet explorer :-(

Thank you so much for your help though.

[QUOTE=iamthwee;1773130]Could be because the xml tags are case sensitive.

I tried the following with your xml and it worked...

[code]
<html>
<head>

<script type="text/javascript">
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","cd.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

x=xmlDoc.getElementsByTagName("cd");
i=0;

function displayCD()
{
document.getElementById("to").innerHTML=
xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue;

}
</script>
</head>
<body onload="displayCD()">
<div>
<b>Title:</b> <span id="to"></span><br />
<b>Artist:</b> <span id="from"></span><br />
<b>Country:</b> <span id="message"></span>
</div>
<div id='showCD'></div>

</body>
</html>[/code][/QUOTE]

Thank you so much for taking time out to help a newbie. Please post the cd.xml file that you used. I'm getting a bit confused.

Regards

Hi there

I have been trying to experiment with Parsing XML using Javascript. For some reason nothing happens. I found this example on W3 schools. Any idea why it's not working?

This is my HTML page which contains the Javascript
[CODE]<html>
<head>

<script type="text/javascript">
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","cd_catalog.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

x=xmlDoc.getElementsByTagName("CD");
i=0;

function displayCD()
{
artist=(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);
title=(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
year=(x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue);
txt="Artist: " + artist + "<br />Title: " + title + "<br />Year: "+ year;
document.getElementById("showCD").innerHTML=txt;
}
</script>
</head>
<body onload="displayCD()">

<div id='showCD'></div>

</body>
</html>[/CODE]

This is my XML file saved in the same folder

[CODE]<?xml version="1.0" encoding="utf-8"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>sdgdsgdg</title>
<artist>Breyrth</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>[/CODE]

Hi

I'm having problems unsetting session varibles using this code. I'm not sure what I'm doing wrong. Nothing happens. Please help

[CODE]<?php
session_start();

$id = $_GET['id'];
$pro = $_SESSION['products'];
$qua = $_SESSION['quantity'];

echo $pro[$id].''." Has been removed";

unset($pro[$id]);
session_write_close();
unset($qua[$id]);
session_write_close();

?>[/CODE]

Thank you very much. Even my lecturer didn't know lol

Hi

I have been going through a tutorial i came across online. Please let me know what this would read if it wasn't written in shorthand. Regards

[CODE] $products = isset($_SESSION['products']) ? $_SESSION['products'] : array();[/CODE]

[QUOTE=jstfsklh211;1760696][CODE]<select id="select" onchange="doThis()">
<option value="easy">Easy</option>
<option value="medium">Medium</option>
<option value="hard">Hard</option>
</select>[/CODE]
though I'm not sure what doThis is doing[/QUOTE]

Thanks for taking time out for me, I really appreciate it. DoThis() fills the divs with values from the arrays which are dependant on which option is selected. It's a sudoku game. I want this to change dynamically so if the user chooses easy the easy puzzle is shown....the same applies to the other puzzles. I'm not too sure what I'm doing wrong. Any suggestions?

Somebody please help me. The page loads fine but when I change the option on select nothing happens. I'm sure it's just a small problem. Your help will go a long way. Thank you in advance.

[CODE]<body>
<table id="main" width="50%">
<tr>
<td><div id="1"></div></td>
<td><div id="2"></div></td>
<td><div id="3"></div></td>
<td><div id="4"></div></td>
<td><div id="5"></div></td>
<td ><div id="6"></div></td>
<td><div id="7"></div></td>
<td><div id="8"></div></td>
<td><div id="9"></div></td>
</tr>
<tr>
<td><div id="10"></div></td>
<td><div id="11"></div></td>
<td ><div id="12"></div></td>
<td><div id="13"></div></td>
<td><div id="14"></div></td>
<td ><div id="15"></div></td>
<td><div id="16"></div></td>
<td><div id="17"></div></td>
<td><div id="18"></div></td>
</tr>
<tr>
<td ><div id="19"></div></td>
<td ><div id="20"></div></td>
<td ><div id="21"></div></td>
<td ><div id="22"></div></td>
<td ><div id="23"></div></td>
<td ><div id="24"></div></td>
<td ><div id="25"></div></td>
<td ><div id="26"></div></td>
<td ><div id="27"></div></td>
</tr>
<tr>
<td><div id="28"></div></td>
<td><div id="29"></div></td>
<td ><div id="30"></div></td>
<td><div id="31"></div></td>
<td><div id="32"></div></td>
<td ><div id="33"></div></td>
<td><div id="34"></div></td>
<td><div id="35"></div></td>
<td><div id="36"></div></td>
</tr>
<tr>
<td><div id="37"></div></td>
<td><div id="38"></div></td>
<td ><div id="39"></div></td>
<td><div id="40"></div></td>
<td><div id="41"></div></td>
<td ><div id="42"></div></td>
<td><div id="43"></div></td>
<td><div id="44"></div></td>
<td><div id="45"></div></td>
</tr>
<tr>
<td ><div id="46"></div></td>
<td ><div id="47"></div></td>
<td ><div id="48"></div></td>
<td ><div id="49"></div></td>
<td ><div id="50"></div></td>
<td ><div id="51"></div></td>
<td ><div id="52"></div></td>
<td ><div id="53"></div></td>
<td ><div id="54"></div></td>
</tr>
<tr>
<td><div id="55"></div></td>
<td><div id="56"></div></td>
<td ><div id="57"></div></td>
<td><div id="58"></div></td>
<td><div id="59"></div></td>
<td ><div id="60"></div></td>
<td><div id="61"></div></td>
<td><div id="62"></div></td>
<td><div id="63"></div></td>
</tr>
<tr>
<td><div id="64"></div></td>
<td><div id="65"></div></td>
<td ><div id="66"></div></td>
<td><div id="67"></div></td>
<td><div id="68"></div></td>
<td ><div id="69"></div></td>
<td><div id="70"></div></td>
<td><div id="71"></div></td>
<td><div id="72"></div></td>
</tr>
<tr>
<td><div id="73"></div></td>
<td><div id="74"></div></td>
<td ><div id="75"></div></td>
<td><div id="76"></div></td>
<td><div id="77"></div></td>
<td><div id="78"></div></td>
<td><div id="79"></div></td>
<td><div id="80"></div></td>
<td><div id="81"></div></td>
</tr> ...

[QUOTE=Troy III;1759020]who's calling the check function?[/QUOTE]

Its a button I have on the page. Here is a clearer picture.

[CODE]<head>
<script type="text/javascript">

window.onload = function(){
easy();
}

function easy(){
var ids = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]
var items = [3,0,6,5,0,0,0,9,0,2,0,0,4,0,0,8,5,1,1,0,0,7,8,0,0,6,0,0,0,9,3,6,8,5,0,0,6,2,8,0,0,0,3,4,9,0,0,5,9,2,4,1,0,0,0,4,0,0,9,7,0,0,2,8,6, 3,0,0,1,0,0,5,0,7,0,0,0,3,4,0,8];

var ans = [3,8,6,5,1,2,7,9,4,2,9,7,4,3,6,8,5,1,1,5,4,7,8,9,2,6,3,4,1,9,3,6,8,5,2,7,6,2,8,1,7,5,3,4,9,7,3,5,9,2,4,1,8,6,5,4,1,8,9,7,6,3,2,8,6,3,2,4,1,9,7,5,9,7,2,6,5,3,4,1,8];

var x = 0
for (var i = 0; i < items.length; i++) {
var item = items[i];
var id = ids[i];        
var element = document.getElementById(id).innerHTML = item;

if (item === 0){
    document.getElementById(id).innerHTML="";
    document.getElementById(id).contentEditable = "true";
    document.getElementById(id).style.backgroundColor = "yellow";
}
function check(){
        for (var i = 0; i < items.length; i++) {
        var id = ids[i];
        var answ = ans[i];

        if(document.getElementById(id).textContent!= answ){
            document.getElementById(id).style.backgroundColor = "red";
        }
    }

    }//end of check

}// end of easy

}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="tablestyle.css" type="text/css" />
</head>

<body>
<table id="main" width="50%">
<tr>
<td><div id="1"></div></td>
<td><div id="2"></div></td>
<td><div id="3"></div></td>
<td><div id="4"></div></td>
<td><div id="5"></div></td>
<td ><div id="6"></div></td>
<td><div id="7"></div></td>
<td><div id="8"></div></td>
<td><div id="9"></div></td>
</tr>
<tr>
<td><div id="10"></div></td>
<td><div id="11"></div></td>
<td ><div id="12"></div></td>
<td><div id="13"></div></td>
<td><div id="14"></div></td>
<td ><div id="15"></div></td>
<td><div id="16"></div></td>
<td><div id="17"></div></td>
<td><div id="18"></div></td>
</tr>
<tr>
<td ><div id="19"></div></td>
<td ><div id="20"></div></td>
<td ><div id="21"></div></td>
<td ><div id="22"></div></td>
<td ><div id="23"></div></td>
<td ><div id="24"></div></td>
<td ><div id="25"></div></td>
<td ><div id="26"></div></td>
<td ><div id="27"></div></td>
</tr>
<tr>
<td><div id="28"></div></td>
<td><div id="29"></div></td>
<td ><div id="30"></div></td>
<td><div id="31"></div></td>
<td><div id="32"></div></td>
<td ><div id="33"></div></td>
<td><div id="34"></div></td>
<td><div id="35"></div></td>
<td><div id="36"></div></td>
</tr>
<tr>
<td><div id="37"></div></td>
<td><div id="38"></div></td>
<td ><div id="39"></div></td>
<td><div id="40"></div></td>
<td><div id="41"></div></td>
<td ><div id="42"></div></td>
<td><div id="43"></div></td>
<td><div id="44"></div></td>
<td><div ...

hi

I'm having serious problems with this code. It all started when I tried to use functions. The function easy() works fine when the page loads but the button has stopped calling the check() function. could it be because I have that stored inside another function? I tried placing outside the function easy() but it still didnt work. Does anyone have any ideas? You help will be greatly appreciated

[CODE]window.onload = function(){
easy();
}

function easy(){
var ids = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]
var items = [3,0,6,5,0,0,0,9,0,2,0,0,4,0,0,8,5,1,1,0,0,7,8,0,0,6,0,0,0,9,3,6,8,5,0,0,6,2,8,0,0,0,3,4,9,0,0,5,9,2,4,1,0,0,0,4,0,0,9,7,0,0,2,8,6, 3,0,0,1,0,0,5,0,7,0,0,0,3,4,0,8];

var ans = [3,8,6,5,1,2,7,9,4,2,9,7,4,3,6,8,5,1,1,5,4,7,8,9,2,6,3,4,1,9,3,6,8,5,2,7,6,2,8,1,7,5,3,4,9,7,3,5,9,2,4,1,8,6,5,4,1,8,9,7,6,3,2,8,6,3,2,4,1,9,7,5,9,7,2,6,5,3,4,1,8];

var x = 0
for (var i = 0; i < items.length; i++) {
var item = items[i];
var id = ids[i];        
var element = document.getElementById(id).innerHTML = item;

if (item === 0){
    document.getElementById(id).innerHTML="";
    document.getElementById(id).contentEditable = "true";
    document.getElementById(id).style.backgroundColor = "yellow";

   function check(){
        for (var i = 0; i < items.length; i++) {
        var id = ids[i];
        var answ = ans[i];

        if(document.getElementById(id).textContent!= answ){
            document.getElementById(id).style.backgroundColor = "red";
        }
    }

    }//end of check
}

}[/CODE]

Hi guys

We have been asked to create a sudoku game using some type of CSS grid framework. I can't find any good explanations as to what a grid framework is. Someone please explain or direct me to an explanation.

Regards

If you don't put an effort into describing the problem no one will put an effort into solving it. What error message are you getting? It would also help if you used the code tags.

Try removing the coma on line 62 first, if that doesn't work remove the curly brackets on line 64 and put apostrophes instead in addition to my first suggestion. Let me know how you get on.

I have been trying to follow this google maps API tutorial.

[url]http://code.google.com/apis/maps/articles/phpsqlajax.html[/url]

The problem is i keep getting this error and I don't know what I'm doing wrong. Here is my code.

[CODE]<?php
require("phpsqlajax_dbinfo.php");

function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}

// Opens a connection to a mySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}

// Set the active mySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}

// Select all the rows in the markers table
$query = "SELECT * FROM markers WHERE 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}

header("Content-type: text/xml");

// Start XML file, echo parent node
echo '<markers>';

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker ';
echo 'name="' . parseToXML('&','&', $row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
}

// End XML file
echo '</markers>';

?>[/CODE]

Please help me.