SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict mcrumlish's Avatar
    Join Date
    Jan 2002
    0 Post(s)
    0 Thread(s)

    help me: Can someone help me with some PHP code?

    can someone please help me with this PHP code? I am a newbie but I need this urgently.

    I want some code for a loop. The loop will iterate a certain number of times, defined by a mySQL database entry.

    The loop will be outputting HTML to the screen into a table. I need the loop to, after it reaches 20 cells across, automatically start a new row. The table will be 20 cells across and 10 rows deep.

    I also need the loop to check a DB entry. If that entry is 1 it will produce HTML code A, if it is 0 the lopp will output HTML code B.

    I am really stuck with this so can someone help please.


    To summarise:
    The loop beings and sees it has to iterate "loopnumber" times where loopnumer is a mySQL DB entry
    In each iteration of the loop there will be a condition:

    output HTML A
    output HTML B

    (status is a variable that is set to a mySQL DB entry "status")

    Also, I want it to check that 20 cells across have been output. Once it reaches 20 cells in a row it outputs HTMLO code to start a new table row.

    I have the pseudo code and theory for this right in my head but I cant get it working in PHP.

    Thanks for your help,


  2. #2
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Before These Crowded Streets
    0 Post(s)
    0 Thread(s)
    I have not had a chance to check this, but this is what I came up with quickly. You may have to tweak it and I'm sure there's a better way to write this, but it might get you started:
    PHP Code:
    mysql_query("SELECT status FROM statustable");
    $row 1?>
    while($row <= 20) {
    $row 20) {
    $row 1;
        else {
    $row $row 1;
    $q1arr mysql_fetch_array) {
    $qlarray['status'] == 1) {
            <td class="1">&nbsp;</td>
    } else {
            <td class="2">&nbsp;</td>
    Aaron Brazell


Posting Permissions

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