Think My Logic Is Screwy! :(

Discussion in 'PHP' started by IGiveMoney, Aug 27, 2008.

  1. #1
    
    
    <?php
    
    while ($row = mysql_fetch_array($result)) {
    $site_name = ucwords(strtolower($row["site_name"]));
    $new_id = $row["id"];
    $new_site = $row["site_name"];
    $ref_link = $row["ref_link"];
    	
    
    	echo ' <li><a href="http://www.mysite.com/sc_a2-site.php?id=' . $new_id . '" title="header=[Insert Your Referral Code For:<BR><br><b>' . $site_name . '</b><br><br>Network] body=[<br>] cssbody=[cssbody] cssheader=[cssheader] fixedrelx[54] windowlock=[on]"><b>' . $site_name . '</b></a><br>
    		' . $ref_link . '<input type="text" name="ref_link[]" value=""><input type="hidden" name="site_id[]" value=""></li><br>';
    
    }
    ?>
    
    
    
    PHP:
    My intention is to pass a couple things along to the next page for a database insertion.

    First is the $new_id (which is the actual id of the row called)
    Second the pass of the value they input into the field (ref_link)

    My end insertion is intended to be something like this

    INSERT INTO active_sites (user_id, site_id, ref_link) VALUES('3','24','83802')

    Because this is a dynamic call and it loops for the sites available
    for that network (meaning one site could have 10 sites and another
    site could have 13) it loops the ref_link field for them to enter in a referral
    code.

    Now on the page it posts to, where the processing is going to occur
    I have found my expectations aren't what I desired.

    When I do the check to make sure fields have been filled in
    I am getting the proper results which is making sure that
    fields 1, 5, 8, 10 were filled in and the rest are disregarded
    because nothing was filled in. I accomplish that by doing this:

    
    for($i=0;
    $i<count($_POST['ref_link']);
    $i++){
    if( $_POST['ref_link'][$i] != '')
    echo $_POST['ref_link'][$i] . '<br />';
    }
    
    
    
    PHP:
    My problem I have ran into and have just sat here for
    an hour trying to figure it out is how to get the id passed
    properly as well.

    I thought I could do it with

    <input type="hidden" name="site_id[]">

    But that didn't produce the results.

    I completely suspect my fault is in the coding of the first
    portion of this post. The part where I am looping a field
    and not passing the site_id as well.

    Maybe someone can assist me in figuring out a good way
    to get that processed as well.

    Thanks for the time....
     
    IGiveMoney, Aug 27, 2008 IP
  2. IGiveMoney

    IGiveMoney Peon

    Messages:
    116
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    please - someone??
     
    IGiveMoney, Aug 27, 2008 IP
  3. eponus

    eponus Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'd repost with better whitespace in your code; I took one look at it and didn't want to hack through it...
     
    eponus, Aug 27, 2008 IP
  4. IGiveMoney

    IGiveMoney Peon

    Messages:
    116
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    
    <?php
    
    while ($row = mysql_fetch_array($result)) {
    $site_name = ucwords(strtolower($row["site_name"]));
    $new_id = $row["id"];
    $new_site = $row["site_name"];
    $ref_link = $row["ref_link"];
    	
    
    echo ' <li>
    <a href="http://www.mysite.com/sc_a2-site.php?id=' . $new_id . '"><b>' . $site_name . '</b></a><br>
    
    ' . $ref_link . '<input type="text" name="ref_link[]" value=""><input type="hidden" name="site_id[]" value="">
    
    </li>
    <br>';
    
    }
    ?>
    
    
    PHP:

    I took out the java coding and lined it as it would be on the page.

    Basically gives you two lines

    SITE NAME GOES HERE
    http://site.ofreferralcode.com/ref=|(insert your ref id)|
     
    IGiveMoney, Aug 27, 2008 IP
  5. eponus

    eponus Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Well, your first problem is <input> requires a <form> to submit that information.
    You're just using an anchor tag <a href> so the <input> tag doesn't ever send its information.
     
    eponus, Aug 27, 2008 IP
  6. IGiveMoney

    IGiveMoney Peon

    Messages:
    116
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    for the sake of saving forum space i didnt put all of the code, just the
    part I was having issues with.

    The form tag is there and it does post to my next page just fine.
    that isnt the issue.
     
    IGiveMoney, Aug 27, 2008 IP
  7. IGiveMoney

    IGiveMoney Peon

    Messages:
    116
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ive got to be able to pass the ref_link[] and the new_id to the next page
    and get the results so that I know which field that had something in it
    is attached to which id

    id = 128 | 84384 (entered)
    id = 37 | 73721 (entered)
    id = 13 | 12810 (entered)

    but i also need to be able to insert that id into the database as well
    not just the data that was entered into it.
     
    IGiveMoney, Aug 27, 2008 IP