Jump to content

mtvaran

Members
  • Posts

    61
  • Joined

  • Last visited

    Never

Posts posted by mtvaran

  1. Adam, i cudn't correcr errors. this is my code..... can you pls have a look....

     

    <?php

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

    if (!$con)

      {

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

      }

    mysql_select_db("uni", $con);

     

    $sql="INSERT INTO Student (StudentID,StudentName)

    VALUES ('$_POST[sid]','$_POST[sname]')";

     

    if(!mysql_query($sql,$con))

      {

      die('Error: ' . mysql_error());

      }

     

    if (!preg_match('/^[0-9]{7}$/', $_POST['sid']))

    {

      echo"existing id ......... "; // invalid

    }

     

    $sql = "SELECT StudentID FROM student WHERE StudentID =" . $sid;

    $query = mysql_query($sql); or trigger_error('MySQL error: ' . mysql_error());

     

    if (mysql_num_rows($query) > 0)

    {

        echo"id  already taken......";// already taken

    }

     

    mysql_close($con)

    ?>

     

  2. sorry guys, I COULD NOT GET IT. i know im bit stupid. all i want is i have already displayed data from two table one is drop-down list another one multi select list, now i need to select one data from drop-down list and one or more data from multi select list then send to another table. hope i made this clear for you guys. plss if you can help me...

  3. <?php

     

     

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

    if (!$con)

      {

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

      }

      mysql_select_db("my_DB_name", $con);

     

     

    $result  = mysql_query("SELECT * FROM buy");

     

    echo "<select multiple='multiple'>";

     

    while($row = mysql_fetch_array($result))

    {

    echo "<option value=''>";

    echo $row['ID'];

     

      echo "</option>";

     

     

     

    }

    echo "</select>";

    mysql_close($con);

     

    ?>

    this is the code im using to display data as select list. but i need a code for select data from that and insert ito another table.

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