PHP again... Help..

Tharindu DR

Well-known member
  • Jan 29, 2007
    3,201
    245
    63
    Machan How can I take two values from the address bar? and entering them to a SQL query?

    Like this...

    http://localhost/Eweb/biditem.php?id=1%20+%20table=book_new_item

    these two values
    id=1

    table=book_new_item

    I need them here.. Separately

    SQL

    $table=$_POST['table'];
    $ids = $_POST['id'];
    mysql_select_db($database_localhost, $localhost);
    $query_items = "SELECT * FROM $table WHERE id= '$ids'";


    Any1 can help???
    Small Problem But I dont No PHP :(
     

    mldarshana

    Well-known member
  • Apr 2, 2007
    34,059
    1,404
    113
    ආශ්චර්ය අභියස :nerd:
    Tharindu DR said:
    Machan How can I take two values from the address bar? and entering them to a SQL query?

    Like this...

    http://localhost/Eweb/biditem.php?id=1%20+%20table=book_new_item

    these two values
    id=1

    table=book_new_item

    I need them here.. Separately

    SQL

    $table=$_POST['table'];
    $ids = $_POST['id'];
    mysql_select_db($database_localhost, $localhost);
    $query_items = "SELECT * FROM $table WHERE id= '$ids'";


    Any1 can help???
    Small Problem But I dont No PHP :(


    u have to capture those values

    let's say

    $id = $_REQUEST['id'];
    $table = $_REQUEST['table'];

    then u can insert it to DB

    mysql_query("insert into TABEL_NAME (id,table) VALUES ('$id','$table')");

    hope u got it
    cheers
     

    Tharindu DR

    Well-known member
  • Jan 29, 2007
    3,201
    245
    63
    Problem is machan


    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id= 5 ?table=camera_new_item' at line 1


    Meeke dekama 1 line1 kata gannaawa ne
     

    kanish1567

    Junior member
  • Dec 18, 2006
    39
    0
    6
    mama hithanne machn umbe error eka thiyenne sql eke.Umba samaharawiat sql quary eke single quation danne nathuwa athi.awlak na ,just follow what i have added.ok let's say like this

    $id=$_REQUEST['id'];
    $table=$_REQUEST['table'];

    $DBconnect=mysqli_connect("servername","username","password");
    mysqli_select_db($DBconnect,"DATABASE")
    or die("<p> The Database is not available </p>");

    $sql="SELECT * FROM WHERE ID='$ID' ";

    $SQLresult=@mysqli_query($DBconnect,$sql);

    ----------------------------------------------------------------
    this is the right syntax for selecting records from the table.if u provide me enough details then i can help get u through it machn.Ela site ekak thiyenawa,i learned php from that site.www.w3schools.com.just surf and get knowladge from it.