Ok, I'm going to assume that you have fixed the SQL statements, and the checkbox creations prints, as per instructed in the previous nodes

About the actual algorithm...

If i understand your problem correctly, you want to
print a list of all of the items in @id
and
if this $id[$i] is also in the database (identified by variable $identifier)
print $id with a checked checkbox,
else print $id without an unchecked checkbox.

If this is what you want to do, then...
1. Loop through @id,
1.1 Query database using your $id as a search criteria,
1.2 If there is a match, then
1.2.1 print a checked box with $id
1.3 If there is no match, then
1.3.1 print an unchecked box.

It this is not what you want to do, just forget I mentioned it.

PS: If @id is huge, then another algorithm may be more appropriate, which minimizes all the queries to the database.

My $.02 worth: When I was first learning to program, my mentor insisted that I write my algorithm 1st, and then step through it with 'dummy data' while pretending to be the computer (do what I say, not what I mean). This method works well when you are still at the learning phase of programming.


In reply to Re: mysql database by Sandy
in thread mysql database by bory

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.