Welcome Guest, Not a member yet? Register   Sign In
Beginning a large Web Application, seeking guidance
#11

[eluser]boltsabre[/eluser]
Too easy champ, good luck with it.
#12

[eluser]roy3600[/eluser]
Hey boltsabre or anyone else,

I've run into an issue where I cannot seem to get the correct "forked" questions to appear based on the id. I've tried many different WHERE clauses to pull by ID, but having no luck.

Here is the code I have now, it's working correctly with AJAX for when I click "YES" on the first question, my forked q's appear.

However, on my next question (row id 5 in the database), when I click "YES" it is making the above question 1 forked questions appear instead of its own. Clearly an ID problem which I cannot fix.

Here is my AJAX code which is working fine:

Code:
[removed]
function getXMLHttp()
{
  var xmlHttp

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}

function MakeRequest()
{
  var xmlHttp = getXMLHttp();

  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse(xmlHttp.responseText);
    }
  }

  xmlHttp.open("GET", "fork-select.php", true);
  xmlHttp.send(null);
}

function MakeRequest2()
{
  var xmlHttp = getXMLHttp();

  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse(xmlHttp.responseText);
    }
  }

  xmlHttp.open("GET", "blank.php", true);
  xmlHttp.send(null);
}

function HandleResponse(response)
{
  document.getElementById('ResponseDiv')[removed] = response;
}
[removed]


Here is the query on my view:
Code:
<?php


$query = $this->db->query('SELECT * FROM survey_new');
foreach ($query->result() as $row)
{
echo $row->id;
    echo $row->question;
echo "<div id=ResponseDiv></div>";
echo "<hr>";
}
?&gt;

Then this is the query on my php response page "forked-select.php". Which selects my forked questions:

Code:
&lt;?php
$fork=mysql_query("SELECT * FROM survey_new");
$rows=mysql_fetch_assoc($fork);

echo $rows['fork'];
?&gt;


All questions, input fields and forked questions are stored in the database by the way.


Thanks for any help, again I've been trying for a good hour or two now but not having luck with any WHERE id = $id clauses.




Theme © iAndrew 2016 - Forum software by © MyBB