Jump to content

theoretical_dreamer

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Posts posted by theoretical_dreamer

  1. I had a search form but I have to separate the values that was inputted by the user. For example
    the user inputs m12ws001. How can I separate this query into 4 separate field in the database?
    Example:
    mw12ws001 -----> m=branch,12=floor, ws=machine, 001-host number
  2. Just want to ask y there is no output in the If condition:

    <?
    include("conf/config.php");
    $link = mysql_connect($database['host'],$database['username'],$database['password']);
    mysql_select_db($database['name'],$link);

    $rs4 = mysql_query("SELECT IP4 FROM ipadd ORDER BY IP4")or die(mysql_error());
    $info4 = (mysql_fetch_array( $rs4 ));
    $ctr=31;

    if ($ctr != 31) {//if ctr is equal to the 1st value of IP4 field in the database
    Print "<b>The IP is available:</b> ".$info4['IP4']. " <br>";
    }

    else
    {
    //Print "<b>IP4:</b> ".$info4['IP4']. " <br>";
    $ctr++;
    Print "The value of ctr is ";
    Print $ctr; //value of ctr is 32
    while($info4 = mysql_fetch_array( $rs4 ))

    {
    $ctr++;
    Print "<br> <b>IP4:</b> ".$info4['IP4']. " <br>";
    Print "The value of ctr is ";
    Print $ctr;

    if ($ctr==$info4['IP4'])
    {
    print "It is equal "; //Doesn't output at all
    print $ctr;
    }

    /*
    else
    {
    print "Finally, its not";
    $ctr;
    }
    */
    }
    }
    ?>

    Output:
    The value of ctr is 32
    IP4: 32
    The value of ctr is 33
    IP4: 33
    The value of ctr is 34
    IP4: 34
    The value of ctr is 35
    IP4: 35
    The value of ctr is 36
  3. guys i did wat u said but it still didn't work here's my edited code

    $rs4 = mysql_query("SELECT IP4 FROM ipadd ORDER BY IP4")or die(mysql_error());
    $info4 = (mysql_fetch_array( $rs4 ));
    $ctr=31;

    if ($ctr=.$info['IP4'].) //if ctr is equal to the 1st value of IP4 field in the database
    {
    print "The available IP is:".$info4['IP4'].;
    }
    else
    {
    Print "<b>IP4:</b> ".$info4['IP4']. " <br>";

    while($info4 = mysql_fetch_array( $rs4 ))

    {

    while ($ctr=.$info4['IP4'].)
    {
    $ctr++;
    if ($ctr!=.$info4['IP4'].)
    {
    print "It works";
    }
    }

    Print "<b>IP4:</b> ".$info4['IP4'] . " <br>";
    }
    }
  4. need help regarding syntax please check my code tnx

    $rs4= mysql_query("SELECT IP4 FROM ipadd ORDER BY IP4")or die(mysql_error());
    $info4 = (mysql_fetch_array( $rs4 ));
    ctr=31;
    if (ctr=.$info['IP4'].)
    {
    print "The available IP is:".$info4['IP4'].;
    }
    else
    {
    Print "<b>IP4:</b> ".$info4['IP4']. " <br>";
    while($info4 = mysql_fetch_array( $rs4 ))
    {

    while (ctr==.$info4['IP4'].)
    {
    ctr++;
    if (ctr!=.$info4['IP4'].)
    {
    print "It works";
    }
    }

    Print "<b>IP4:</b> ".$info4['IP4'] . " <br>";
    }
    }
  5. Guys need help in using forms, I have 4 fields in my database table named "ipadd". I have a search form that handle the queries inputted by the user. The user will input values in this format "192.168.2.1". In the database table, the values in each octet of the IP address is distributed in the four fields. For example using the value "192.168.2.1". The value of the 1st Octet "192" is in the 1st field of the database named "IP1". "168" will be in the second field and so on. However the value of the 1st and the second Octet is constant: "10" and "0". The problem is how can I get the value of the third and 4th Octet in php (can I use the trim command?). Please check my code:


    case "ip":
    $ip1 = 10;
    $ip2 = 0; $ip3 = // What should I put in here?
    $ip4 = // What should I put in here?
    $rs = mysql_query("SELECT * FROM ipadd WHERE IP1 LIKE'%".$_GET['ip1']."%' AND IP2 LIKE'%".$_GET['ip3']."%' AND IP3 LIKE'%".$_GET['ip3']."%'" AND IP4 LIKE'%".$_GET['ip4']."%'");
    break;
×
×
  • 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.