<?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....
I'd repost with better whitespace in your code; I took one look at it and didn't want to hack through it...
<?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)|
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.
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.
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.