Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Posts
    190
    Thanks
    25
    Thanked 0 Times in 0 Posts

    Call mysql straight after another one

    Hi guys

    Could someone please help me.
    Basically what I want ive tried to is firstly store values from my database into . Then create buttons corresponding to the amount of rows in the DB. These buttons will then copy the value from $OneLevel and $OneCode and paste them into the two textfields called encodedL and encodedP.

    The problem is, is once the buttons are pressed instead of copy and pasting the values from $OneLevel and $OneCode it instead pastes '$OneLevel' and '$OneCode'.

    Any suggestions would be great!!
    Thanks

    PHP Code:
    <?php 
    $username
    ="";
    $password="";
    $database="";

    mysql_connect(localhost,$username,$password);
    @
    mysql_select_db($database) or die( "Unable to select database");

    $query1="SELECT * FROM code WHERE Type='One'";
    $result1=mysql_query($query1);
    $OneLevel=mysql_result($result1,$i,"Level");
    $OneCode=mysql_result($result1,$i,"Code");

    ?>

    <?
    $i
    =0;
    while (
    $i $num_rows) {
    $Type=mysql_result($result,$i,"Type");


    print 
    "\t <input type=\"button\" onClick=\"document.getElementById('encodedL').value='$"."$Type"."Level'; document.getElementById('encodedP').value='$"."$Type"."Code'; decode() \" name=\"$Type\" value=\"$Type\" /> \n"

    $i++;

    }

    ?>

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Um... er... any reason you're not just using an array with mysql_fetch_array()?

    PHP Code:
    $i=0;
    while (
    $i $num_rows) {
    $Type mysql_fetch_array($result);

    print 
    "\t <input type=\"button\" onClick=\"document.getElementById('encodedL').value='{$Type['Level']}'; document.getElementById('encodedP').value='{$Type['Code']}'; decode() \" name=\"{$Type['Type']}\" value=\"{$Type['Type']}\" /> \n"

    $i++;



  • #3
    Regular Coder
    Join Date
    Feb 2005
    Posts
    190
    Thanks
    25
    Thanked 0 Times in 0 Posts
    Awesome!! Oh, I didnt know you could do that...I just started using mysql the other day.

    Anyway thanks for the quick response, it works great!!

    Thanks mate.


  •  

    Posting Permissions

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