SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: problem

Hybrid View

  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP/MySQL Problem -

    Code here:

    http://216.74.101.27/help.html

    Example here:

    http://216.74.101.27/admin/newsubcat.php

    Thanx if anyone could help. I am trying to select from one table then use that to then insert into a difffernt table, with other data.

  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Once you get the data into an array (such as $results), you can do another query and just intepolate the variables in there.

    Is that what you were asking? There's no special way to do it other than what I just said, if I understood your question correctly.

  3. #3
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would you do that?

  4. #4
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $dbh = mysql_pconnect(...);
    mysql_select_db("...");
    $qry = mysql_query("select..."); // must only return one row
    $results = mysql_fetch_array($qry);
    mysql_select_db("...");
    $qry = mysql_query("insert ".$results['hi']."etc etc etc");

    Do you want more of a description?

  5. #5
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes.....sorrta.....i am very new to PHP and MySQL

    Thanx

  6. #6
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Going through my code line by line...

    Connect to the DB with a persistent connection so it will last longer. (you need to fill this in)
    Select the mysql db named ".." (you need to fill this in)
    Run a select query (you need to fill this in)
    Assign $results to the returned array
    Select the DB to insert to
    Do the insert query with interpolated variables.

  7. #7
    SitePoint Member
    Join Date
    Dec 2000
    Location
    Poland
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The correct syntax for the "INSERT ..." is
    INSERT INTO dbase SET field1='value1', field2='value2'
    so change the line in your script into
    Code:
    $sql = "INSERT INTO subcategory SET ".
    Chris

  8. #8
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx

  9. #9
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just have no idea how to incorporate this into my code, using the select box, text area and text input box?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •