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
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Scoured the Internet... Unable to jump to row MySQL result index

    I cannnot find a good answer for me on this subject. I'm looping through a dynamic sql query to get different results from the same two columns. Eventually I want to have dynamic text areas. This worked before I tried to do it dynamically.. I check dynamic checkboxes on one page, pass the values over to the next page, and then try to loop through to get the code, code descr from the db. The link to the site is..
    http://www.dataspiral.com/WholeDocPh...tNotesList.php

    The code on the page receiving the posted data is:

    <?php


    $count = 3;
    $i=0;
    while ($i < $count){
    echo $i;
    $Code= $_POST[$i];
    echo $Code;

    $dbconnection = mysql_connect(host, database, password) or die("Died!");
    echo "Connected to MySQL". '<br />';
    mysql_select_db("dbwholedoc",$dbconnection) or die("Died!");
    echo "Connected to Database". '<br />';


    if ($Code <>''){

    $sql = ("SELECT Code, CodeDescr FROM VisitCodes where Code = '".$Code."'");

    echo "Query: " . $sql;


    $result=mysql_query($sql);

    ${'code'.$i}=mysql_result($result,$i,"Code");
    ${'codeDescr'.$i}=mysql_result($result,$i,"CodeDescr");

    echo $code0;
    echo $codedescr0;
    }
    /*result not coming through query for code and codedescr... query not executing correctly*/

    $num=mysql_num_rows($result);
    echo $num;



    ?>


    <?php
    mysql_close();
    $i++;

    }
    ?>

    Thanks in advance!

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,327
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    Check out the link in my signature (the one about [php] tags)
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    All the code posted above is PHP. It is a block straight off the page. thx.


  •  

    Posting Permissions

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