Jump to content

zenag

Members
  • Posts

    443
  • Joined

  • Last visited

Posts posted by zenag

  1. script to validate 10 digit number

    function validateNumber(field, msg, min, max) { 
    if (!min) { min = 10 } 
    if (!max) { max = 10 } 
    
    if ( (parseInt(field.value) != field.value) ||  
           field.value.length < min || field.value.length > max) { 
    alert(msg); 
    field.focus(); 
    field.select(); 
    return false; 
    } 
    
    return true; 
    }
    
    

  2. <?
    $con=mysql_connect("localhost","root","");
    mysql_select_db("login",$con);
    $j=0;
    for($i=0;$i<=4;$i++)
    {
    $z= $j+2;
    //echo "select * from user limit($j,$z)";
    $sql=mysql_query("select * from user limit $j,$z");
    while($row=mysql_fetch_array($sql))
    {
    ?><table><tr><td>heading1</td></tr><tr><td>
    <? if($z==2){ echo $row["nickname"];}?></td></tr></table>
    
    <table><tr><td>heading2</td></tr><tr><td>
    <? if($z==4){ echo $row["nickname"];}?></td></tr></table>
    
    <table><tr><td>
    <? if($z==2){ echo $row["nickname"];}?></td></tr></table>
    
    <?
    }
    $j=$j+2;
    };
    
    ?>
    
    
    
    

  3. u have not gvn open bracket before..INSERT

     

    $new = ("INSERT INTO travek_user_cols(1,2,3,4,5,6) VALUES('".$result["online"]."','".$result["online"]."','".$result["online"]."','".$result["online"]."','".$result["online"]."','".$result["online"]."'");
    
    

  4. 
    $server = "localhost:3306"; // this is the server address and port
    $username = "web15-ian"; // change this to your username
    $password = "1234567 "; 
    $link = @mysql_connect ($server, $username, $password)
    or die (mysql_error());
    

  5.  

    while ($row1=mysql_fetch_row($result2)){
    $uuid=$row1[0];
    echo $uuid;
    }
    [quote]
    i ve assigned this value...echo $uuid;
    
    [/quote]
    #$result3 = mysql_query("SELECT users.firstname,users.surname,incidents.owner_id FROM incidents,users where (incidents.owner_id = users.id) OR (incidents.owner_id = NULL)
    $result3 = mysql_query("SELECT users.firstname,incidents.description,users.surname,incidents.owner_id FROM incidents,users where (incidents.owner_id = users.id) OR (incidents.owner_id < '$uuid') AND (incidents.owner_id = 0)",$link);
    

     

    refer this....
    this query might help u ...check this query ..it will output results from users table where owner_id in incidents table is null...
    SELECT users.firstname,incidents.description,users.surname,incidents.owner_id 
    FROM users
    LEFT OUTER JOIN incidents
    ON incidents.owner_id = users.id
    WHERE incidents.owner_id IS NULL
    
    

  6.  

    sorry pal....ur query works fine ..ur correct...set in ur database for owner_id field as default value as NULL OR 0 in mysql...it will work fine..

     

     

     

    $result3 = mysql_query("SELECT users.firstname,incidents.description,users.surname,incidents.owner_id FROM incidents,users where (incidents.owner_id = users.id) OR (incidents.owner_id < '$uuid') OR (incidents.owner_id = NULL)",$link);
    

  7. query hasnt yet accepted .." incidents.owner_id=NULL "..its not working ,we cannot display fields from two tables by satisfying condition from single table (ie.incidents.owner_id satisfies only incidents table but not users).if the condition satisfies both tables only we can able to display fields from both tables..

  8. query hasnt yet accepted .." incidents.owner_id=NULL "..its not working ,we cannot display fields from two tables by satisfying condition from single table (ie.incidents.owner_id satisfies only incidents table but not users).if the condition satisfies both tables only we can able to display fields from both tables..

  9. since u have selected only four fields here..

     

    $result3 = mysql_query("SELECT users.firstname,incidents.description,users.surname,incidents.owner_id FROM incidents,users where (incidents.owner_id = users.id) OR (incidents.owner_id < '$uuid') OR (incidents.owner_id = NULL)",$link);

     it would display that selected fields only....if u need to select all fields from two tables u can write it as...

    SELECT * FROM incidents,users where ...

  10. this solves all ur probs.....

    
    <?
    
    session_start();
    
    $clicked=$_POST["gender"];
    
    ?><?
    if($clicked=="open")
    {
    ?>
    <html>
    <title> Welcome to Project Management Tool</title>
    <body bgcolor=#AFC7C7>
    <h1> Report</h1>
    
    
    <?php
    
    $myusername = "administrator";
    echo $myusername;
    
    //put the above right at the top of your script. Everything else can follow
    ?>
    
    <?
    
    //header("Content-Type: text/plain");
    
    
    /* set's the variables for MySQL connection */
    
    $server = "localhost"; // this is the server address and port
    $username = "root"; // change this to your username
    $password = ""; // change this to your password
    
    /* Connects to the MySQL server */
    
    $link = @mysql_connect ($server, $username, $password)
    or die (mysql_error());
    
    /* Defines the Active Database for the Connection */
    
    if (!@mysql_select_db("helpcore", $link)) {
      echo "<p>There has been an error. This is the error message:</p>";
         echo "<p><strong>" . mysql_error() . "</strong></p>";
         echo "Please Contact Your Systems Administrator with the details";
    }
    
    $sql1 = mysql_query("SELECT id from users where loginname ='".$myusername."'",$link);
    
    while($row=mysql_fetch_row($sql1 ))
    {
    
    #echo $result[0];
    $uid=$row[0];
    echo $uid;
    #$uid=$result["id"];
    #echo "$uid";
    
    }
    
    #$result2 = mysql_query("SELECT incidents.id, incidents.description, users.firstname, users.surname, users.loginname FROM incidents,users WHERE (incidents.owner_id = users.id) AND (incidents.contact_id = '".$result[0]."')", $link);
    $result2 = mysql_query("SELECT  id, description  FROM incidents where contact_id = '".$uid."'", $link);
    #echo ("SELECT incidents.id, incidents.description, users.firstname, users.surname, users.loginname FROM incidents,users WHERE (incidents.owner_id = users.id) OR (incidents.contact_id = '".$uid."')";
    //echo $result2 ;
    
    #$result2 = mysql_query("SELECT incidents.id,incidents.description,users.firstname,users.surname,users.loginname from incidents,users where (incidents.owner_id = users.id) OR (incidents.contact_id =  '".$uid."')", $link);
    while ($row1=mysql_fetch_row($result2)){
    $uuid=$row1[0];
    echo $uuid;
    }
    #$result3 = mysql_query("SELECT users.firstname,users.surname,incidents.owner_id FROM incidents,users where (incidents.owner_id = users.id) OR (incidents.owner_id = NULL)
    $result3 = mysql_query("SELECT users.firstname,incidents.description,users.surname,incidents.owner_id FROM incidents,users where (incidents.owner_id = users.id) OR (incidents.owner_id < '$uuid') OR (incidents.owner_id = NULL)",$link);
    //echo "SELECT users.firstname,users.surname,incidents.owner_id FROM incidents,users where (incidents.owner_id = users.id) OR (incidents.owner_id < '$uuid') OR (incidents.owner_id = NULL)";
    
    
    if (!$result3) {
      echo("<p>Error performing query: " . mysql_error() . "</p>");
      exit();
    }
         
    
    /* Starts the table and creates headings */
    ?>
    <table border="1">
    <tr>
    <td><strong>ID</strong></td>
    
    <td><strong>Description</strong></td>
    <td><strong>Owner Name</strong></td>
    <td><strong>Notes</strong></td>
    
    <?
    /* Retrieves the rows from the query result set
    and puts them into a HTML table row */
    
    
    
    
    
    /* Retrieves the rows from the query result set
    and puts them into a HTML table row */
    #echo "hello";
    #echo "$myusername";
    while ($row2 = mysql_fetch_array($result3)) {
    
    
    echo "\n";
         echo("<tr>\n<td>" . $row2["owner_id"] . "</td>");
        echo("<td>" . $row2["description"] . "</td>");
        echo("<td>" . $row2["firstname"] . $row1["surname"]. "</td>");
        echo("<td>" . $row2["loginname"] . "</td></tr>");
    
       # echo("<td>" . $row["name"] . "</td>");
       # echo("<td>" . $row["create_time"] . "</td>");
    }
    
    /* Closes the table */
    ?>
    </table>
    <?
    
    /* Closes Connection to the MySQL server */
    
    /* Closes Connection to the MySQL server */
    mysql_close ($link);
    
    }
    else
    {
    if($clicked=="closed")
    
    {
    echo "closed";
    }
    }
    
    ?>
    
    

×
×
  • 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.