Jump to content

robert_gsfame

Members
  • Posts

    876
  • Joined

  • Last visited

Posts posted by robert_gsfame

  1. haha....actually i missed this part...so just change

     

    if(!empty($result))

    {

      echo "<table>";

      while($result_array=mysql_fetch_array($result))

     

    with this

     

    if(!empty($result_num))

    {

      echo "<table>";

      while($result_array=mysql_fetch_array($result))

     

    1000% WORK!!!

  2. <?php

    $con = mysql_connect("localhost","root","");

    if (!$con)

    {

    die('Could not connect: ' . mysql_error());

    }

     

    mysql_select_db("mydb", $con);

     

    $result =mysql_query("SELECT DISTINCT Category FROM Categories");

    $result_num=mysql_num_rows($result);

     

    if(!empty($result_num))

    {

      echo "<table>";

      while($result_array=mysql_fetch_array($result))

        {

          $category=$result_array['Category'];

          echo "<tr><td style='border-bottom:dashed 1px #000000'>$category</td></tr>";

     

          $check_table2=mysql_query(sprintf("SELECT * FROM movies WHERE ID='%s'",

          mysql_real_escape_string($category)));

          $check_table2_num=mysql_num_rows($check_table2);

          if(!empty($check_table2_num))

          {

            while($check_table2_array=mysql_fetch_array($check_table2))

            {

              $title=$check_table2_array['Titles'];

              echo "<tr><td>$title</td></tr>";   

              }

          }

        }

      echo "</table>";

    }

     

    mysql_close($con);

    ?>

     

    just copy and paste above code...let see if it works

  3. <?php

    $con = mysql_connect("localhost","root","");

    if (!$con)

    {

    die('Could not connect: ' . mysql_error());

    }

     

    mysql_select_db("mydb", $con);

     

    $result =mysql_query("SELECT DISTINCT Category FROM categories");

    $result_num=mysql_num_rows($result);

     

    if(!empty($result))

    {

      echo "<table>";

      while($result_array=mysql_fetch_array($result))

        {

          $category=$result_array['Category'];

          echo "<tr><td style='border-bottom:dashed 1px #000000'>$category</td></tr>";

     

          $check_table2=mysql_query(sprintf("SELECT * FROM movies WHERE ID='%s'",

          mysql_real_escape_string($category)));

          $check_table2_num=mysql_num_rows($check_table2);

          if(!empty($check_table2_num))

          {

            while($check_table2_array=mysql_fetch_array($check_table2))

            {

              $title=$check_table2_array['Titles'];

              echo "<tr><td>$title</td></tr>";   

              }

          }

        }

      echo "</table>";

    }

     

    mysql_close($con);

    ?>

     

    okay try that code...above, i just make a small change

    category with Category

    title with Titles

     

  4. After you changed this part

     

    $check_table2=mysql_query(sprintf("SELECT * FROM movies WHERE Category='%s'",

     

    with this

     

    $check_table2=mysql_query(sprintf("SELECT * FROM movies WHERE ID='%s'",

     

    and change this part either

     

    $title=$check_table2_array['title'];

     

    with this

     

    $title=$check_table2_array['Titles'];

     

     

    It will work...!!!! 100%

  5. i think i got this....

     

    please specify link so that two tables can be connected

     

    if i read what you've mentioned before, you might have to do this. try changing this part

    $check_table2=mysql_query(sprintf("SELECT * FROM movies WHERE category='%s'",

     

    with this

    $check_table2=mysql_query(sprintf("SELECT * FROM movies WHERE ID='%s'",

     

    and let see if it works

     

  6. <?php

    $con = mysql_connect("localhost","root","");

    if (!$con)

    {

    die('Could not connect: ' . mysql_error());

    }

    mysql_select_db("mydb", $con);

    =================================================

    (the way you join two tables seems to be wrong....as category and id cannot be connected)

    movies:    id - title - category - url

    categories: id - category (FK)

     

     

    $result =mysql_query("SELECT DISTINCT category FROM categories");

    $result_num=mysql_num_rows($result);

     

    if(!empty($result))

    {

      echo "<table>";

      while($result_array=mysql_fetch_array($result))

        {

          $category=$result_array['category'];

          echo "<tr><td style='border-bottom:dashed 1px #000000'>$category</td></tr>";

     

          $check_table2=mysql_query(sprintf("SELECT * FROM movies WHERE category='%s'",

          mysql_real_escape_string($category)));

          $check_table2_num=mysql_num_rows($check_table2);

          if(!empty($check_table2_num))

          {

            while($check_table2_array=mysql_fetch_array($check_table2))

            {

              $title=$check_table2_array['title'];

              echo "<tr><td>$title</td></tr>";   

              }

          }

        }

      echo "</table>";

    }

     

     

    well this code is not yet tested, but i think it should work...hope that helps!

  7. really confusing... :P why dont try this way..let say u use POST method

     

     

    <form action="actionTq.html" method="post">

    <input name="email" type="hidden" value="<?php echo $email;?>"> ===> pass the value

      <input type="submit" value="Request for Action" />

    </form>

     

    then when submit button is being clicked, then

     

    go to actionTq.html

     

    use

    $to=$_POST['email'];

    $subject="xxx";

    $body="xxx";

    $header="xxxx";

    $header.="Content-type: text/html r\n";

    $message="xxxxx";

     

    if(mailto($to,$subject,$message,$header))

    {

      echo "Alright, your message has been successfully sent";

    }

    else

    {

      echo "Oops error occured!";

    }

     

    okay hope that helps  :P

  8. i don't really get, but let see if my explanation is what you need.  :)

     

    Based on what you've explained to us, you wish to have this

     

    Category 1

    ---------------

    title

    title

     

    Category 2

    ---------------

    title

    title

     

    so why don't you check the what category exists (use DISTINCT in your mysql query) in table categories, loop it and then check what movies match the category and loop it either

     

    so in this case still u have to use 2 times looping ..but for sure there are so many ways to get the same results.  :)

  9. I have knowledges in javascript and still learning about AJAX. What i found here that AJAX only do a request to the server and execute particular script asked such as PHP, XML.

     

    I didn't find too much code for this , is that what AJAX all about..or i might have missed something??

     

    thx in advance

  10. this question seems so stupid, but i really want to know the best way to write this code. :P

     

    let say i have this code:

     

    if(empty($num))

    {

    header("Location:index.php");

    }

     

    is it okay if i write it down like this?

     

    if(empty($num))

    {

      header("Location:index.php");

    }

     

    i mean there is a whitespace behind header()

     

    thx in advance

  11. i have a form

    <form name=frm1>

    <input type="checkbox" value="a" name="xxxx">

    </form>

     

    i wish to get the name of the elements using document.frm1.elements

     

    to get the value, i simply use document.frm1.elements[1].value;

    when i try to use document.frm1.elements[1].name to get the name of the element, i cant get it

  12. I have this

    $val="my friend is a female";

     

    how to check whether a word "male" is there or not using preg_match()

     

    i wish to get FALSE result for that case and TRUE if i modify a bit into

    $val="both male/female"

     

    thx in advance!

     

     

  13. This is actually the problem

    i have two frames let assume this:

    1st frame is for name.php which is consist of name of a person

    2nd frame is detail.php which will display the detail of each chosen person

     

    so when u click on the name, 2nd frame will display the detail.

    I have something like favorite tag on the 2nd frame, so when they want to easily tag particular name to be easily memorized, they could just give a tag by clicking on the "favorite tag" button.

     

    When they click on it, i use header() and redirect them to another page to UPDATE the record and redirect them back to detail.php

     

    What i really want is to give some small flag symbol before each name if being "tagged" on name.php

     

    that is why i do refresh every second... :P . seems to be very easy if not doing it in frames  :)

     

     

  14. problem still exists even when i have closed the connection using mysql_close()

    actually i have 2 frames and when i update the second frame, i wish to display the updated one in the first frame either, that's why i update the 1st frame every second  :P

     

    don't have any idea on how to refresh the first frame from the second frame.. :P

     

    please give me some guides. thx

  15. will refresh a page every second will cause some crash or error ??

    cause when i try this, it sometimes display this error

     

    "Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL "

    this is occur when i run it in my local server. I am so worried if this might also happen when i run it online.

     

    thx

  16. Below is the script

     

    function refreshflag()

    {

    var totalx=document.getElementById("totaluser").value;

    var spx=totalx.split(";");

    if (window.XMLHttpRequest)

      {// code for IE7+, Firefox, Chrome, Opera, Safari

      xmlhttp=new XMLHttpRequest();

      }

    else

      {// code for IE6, IE5

      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

      }

    for(i=0;i<spx.length;i++)

    {

    var parameters="em="+spx;

    xmlhttp.open("POST","refresh_flag.php",true);

    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")

    xmlhttp.onreadystatechange=function()

      {

      if(xmlhttp.readyState==4 && xmlhttp.status==200)

        {

        document.getElementById("ref"+spx).innerHTML=xmlhttp.responseText;

        }

      }

    xmlhttp.send(parameters)

    }

    setTimeout("refreshflag()", 1000);

     

    The problem is that in refresh_flag.php, when i cannot get the result which is $_POST['em'] displayed as document.getElementById("ref"+spx).innerHTML) although in refresh_flag.php, i put this echo $_POST['em'];

     

    as if $_POST didn't pass the value

     

    thx for any help

  17. I am new to ajax n i have problem in reloading multiple elements

     

    so let say i have this

    var textbox="aaaa;bbbb;cccc;dddd";

     

    and in my page i also have

    <div id="aaaa"></div>

    <div id="bbbb"></div>

    <div id="ccccc"></div>

     

    how can i reload each element every 1 second.. i can only do this with single element  :P

     

    need some clue or small code

     

    thx

     

     

     

     

     

  18. dont really get it..okay i have modified certain script

     

    function refreshflag()

    {

    var x=0;

    if(x!=1)

    {

      setInterval(checkit(),1000);

    }

    }

     

    function checkit()

    {

    var totalx=document.getElementById("totaluser").value;

    var spx=totalx.split(";");

    for(i=0;i<spx.length;i++)

    {

      counter(spx);

    }

    }

     

     

    function counter(x){

    if (window.XMLHttpRequest)

      {

      xmlhttp=new XMLHttpRequest();

      }

    else

      {

      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

      }

    var parameters="em="+x;

    xmlhttp.open("POST","refresh_flag.php",true);

    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")

    xmlhttp.onreadystatechange=function()

      {

      if (xmlhttp.readyState==4 && xmlhttp.status==200)

        {

        document.getElementById(x).innerHTML=xmlhttp.responseText;

        }

      }

    //xmlhttp.send(parameters)

    alert(parameters);

    }

     

    and in refresh_flag.php

    <?php echo rand(0,9);?>

  19. this is what i did so far to refresh page using ajax periodically

     

    function refreshflag()

    {

    var x=0;

    if(x!=1)

    {

      setInterval(checkit(),100);

    }

    }

     

    function checkit()

    {

    var totalx=document.getElementById("totaluser").value;

    var spx=totalx.split(";");

    for(i=0;i<spx.length;i++)

    {

      counter(spx);

    }

    }

     

     

    function counter(x){

    if (window.XMLHttpRequest)

      {

      xmlhttp=new XMLHttpRequest();

      }

    else

      {

      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

      }

    var parameters="?em="+x;

    xmlhttp.open("POST","refresh_flag.php",true);

    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")

    xmlhttp.onreadystatechange=function()

      {

      if (xmlhttp.readyState==4 && xmlhttp.status==200)

        {

        document.getElementById(x).innerHTML=xmlhttp.responseText;

        }

      }

    //xmlhttp.send(parameters)

    alert(parameters);

    }

     

    and in refresh_flag.php

    <?php echo rand(0,9);?>

     

     

    the problem is that when i user alert i have the looping correctly but when i tried to get the responseText, i didn't get any result for each x. assuming that the

    document.getElementById("totaluser").value="Ronan;Dean;Jay"

     

     

    thanks for any helps

     

  20. How can i pass value to parent window?

     

    Let say

     

    page1.php

    <input type="button" value="open window" onclick="javascript:window.open('page2.php')">

    <div id="test"></div>

     

    page2.php

    <input type="button" value="close window" onclick="passvalue('HELLO WORLD')">

     

    so what should be written in function passvalue() so that the words "HELLO WORLD" shown up in <div id="test"></div>??

     

    what i've tried so far in confusion and not working is this

    function passvalue(x)

    {

    window.parent.document.getElementById("test").innerHTML=x;

    window.close();

    }

     

    thx for any help

     

     

     

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.