Jump to content

rsleventhal

New Members
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

rsleventhal's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks to all who replied. @berridgeab: yes, all the data is there when I just dump it out like that. @ Jessica: adding trim(), while a good idea and something I've now done, does not affect the output @ManiacDan: I've run the query by hand in shell and all's as expected. The column I'm losing is always the first column and contains only plain text, no HTML. I have a feeling I'm doing something earlier in the code that's affecting the output, so I'll look there and continue debugging. Will post the solution once i find it. Again, my thanks, -R
  2. I'm in a quandry. I have a series of records in a table. I'm allowing NULLs on my varchar columns, because the imported data may not have values for some of them. I need to manipulate each record with the end-goal of creating another query which will be used to insert data into another table. The first table, with the NULLS permitted, is the one I'm currently traversing with a 'while loop': $sql = "select * from " . DB_TBL; $result = mysql_query($sql); while ($data = mysql_fetch_assoc($result)) { //my foreach loop goes here } Pretty straightforward so far. So, I thought, was my foreach loop: foreach ($data as $key => $value) { if ((strlen($value) != 0)) { echo "key: " . $key . ': =' . $value . '<br />'; } else { echo '<br />'; } } When I run that, I seem to lose the first column, which is never NULL or strlen=0. It just doesn't display. Should this be done another way? Perhaps getting the numrows first, then doing the foreach, incrementing the row inside a for/next loop? thanks in advance for any productive ideas.
  3. wow...that certainly makes sense! Thanks for the tip. I'll work it and will reply to this thread when [solved] Many many thanks, ~Ray
  4. Hi all, Please forgive the 'newbie-ness' of this question, but I think I'm getting unusual results from a fairly simple construct. Basics: LAMP server, running Apache 2.0x and PHP 4.3.11. Not the most current, but that's what I've got Smile I'm building a <select> dropdown list in a form. The data is coming from a MySQL table. The purpose of the form is to allow the admin of the site to email a list of users or a single user from the list. Pertinent code: $query = "Select `contact_email` from `contactlist` order by `contact_email` ASC"; //$query = "Select `contact_email` from `contactlist`"; $result = mysql_query( $query ); $list = mysql_fetch_array( $result ); $reccount = mysql_num_rows( $result ); The $reccount var is just my own reality check. It returns the correct/expected number of records as 17. now the html/php integration for the form: <select type="text" name="addressee" /> <option value="all">All contacts</option> <?php // begin looping through to permit single selections of contacts while ($addr = mysql_fetch_array( $result ) ) { $sendto = $addr['contact_email']; print "<option value=\"" . $sendto . "\">" . $sendto . "</option>\n"; } ?> </select> My issue is that while $reccount shows 17, I only get 16 records in the drop down list. The missing record is *always* the array element, meaning that if it's a naturally obtained order (db order), the first value is lost to the <select> construct. If I sort, the first sorted value is lost. This appears to be different behavior to what while() should do, I think... If anyone has any suggestions, I'd be very thankful. Kind regards, ~Ray
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.