Desperate help needed on tables in .php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ladysniper@gmail.com

    Desperate help needed on tables in .php

    DESPERATE doesn't begin to describe it.

    Can someone PLEASE tell me what is WRONG with this code?

    Now..a bit of background. It is a search results page for
    http://www.azsoma.info/directory.htm. (use Scottsdale for the city)

    If you go look, you see that the search results post (I do have my
    table borders up for debugging) but it doesn't line up with the table
    above it...the whole scroll background doesn't show up and I cannot get
    my results to have a space between them. And on top of it...they want
    an inline frame! I haven't even attempted that...at all....

    Please...can someone help me. Hell, I'll pay someone if I have to...be
    glad to...but this page needs to be done for the client....

    Warning...long coding....

    Thank you in advance....plea se, if someone could/would help me....



    Code:

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=windows-1252">
    <title>Director y Search Results</title>
    </head>

    <body bgcolor="#00000 0">
    <div align="center">

    <table width="800" border="1" cellpadding="0" cellspacing="0"
    height="100%">
    <table width ="800" border="1" cellpadding="0" cellspacing="0"
    height="15%>

    <tr>
    <td width="4"></td><td valign="top" align="center" height="19%">
    <img border="0" src="images/header3.gif" width="800"
    height="150"></td></tr></table>

    <table width ="800" border="1" cellpadding="0" cellspacing="0"
    height="10%">
    <tr>
    <td width ="800" height="19" bgcolor="e1d7a4 " valign="top"
    align="center">

    <p style="margin-left: 25"><br>
    <font face="Rockwell" size="2" color="#990000" > <font color="FF7256">
    <a href="/index.htm"><fon t color="#990000" >Home</font></a></font><font
    color="#990000" >&nbsp;&nbsp;&n bsp;&nbsp;
    </font> <font color="FF7256">
    <a href="applicati on.htm"><font color="#990000" >Member
    Application</font></a><font color="#990000" >&nbsp;&nbsp;&n bsp;&nbsp;
    </font>
    <a href="/membership.htm" ><font color="#990000" >Member
    Benefits/Products</font></a><font
    color="#990000" >&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;
    </font>
    <a href="/directory.htm"> <font color="#990000" >Member
    Directory</font></a><font
    color="#990000" >&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;
    </font>
    <a href="/news.htm"><font
    color="#990000" >Announcement s/News/Links</font></a></font></font></p></td></tr></table>





    <table width = "800" border ="1" cellpadding="0" cellspacing="0"
    align="center" background="ima ges/scroll.jpg" length="800">
    <form method="post" action="http://azsoma.info/results.php">




    <!-- <table width="800" border="1" cellpadding="1"
    cellspacing="0" align="center" background="ima ges/qi-gong2_16.jpg"
    height="100%"> -->

    <!-- <tr>

    <!-- <td width="60" valign="top"><b >id</b></td> -->
    <!-- <td width="20%"><fo nt size="3" color="990000"> Full
    Name</font></td> -->
    <!-- <td width="30%"><fo nt size="3"
    color="990000"> Address</font></td> -->
    <!-- <td width="10%"><fo nt size="3"
    color="990000"> City</font></td> -->
    <!-- <td width="10%"><fo nt size="3"
    color="990000"> Zip</font></td> -->
    <!-- <td width="10%"><fo nt size="3"
    color="990000"> Phone</font></td> -->
    <!-- <td width="20%"><fo nt size="3" color="990000"> Website
    Address</font></td> -->
    <!-- </tr> -->

    <tr>




    php:


    <?php
    //print_r($_POST) ;
    //echo "<br>\n";

    $hostname = "***DON'T SHOW***"; // The server.
    $username = "***DON'T SHOW***"; // The username you created for this
    database.
    $password = "***DON'T SHOW***"; // The password you created for the
    username.
    $usertable = "***DON'T SHOW***"; // The name of the table you made.
    $dbName = "***DON'T SHOW***"; // This is the name of the database you
    made.

    MYSQL_CONNECT($ hostname, $username, $password) OR DIE("DB connection
    unavailable");
    @mysql_select_d b( "$dbName") or die( "Unable to select database");

    //error message (not found message)begins
    // $XX = "No Record Found, to search again please close this window";

    /*+-------------------------------------------------------------------------------------+

    | Query Details Begin:
    |

    +-------------------------------------------------------------------------------------+

    | Since I don't know if phpForms has a built in search function and I
    don't have time |
    | to try to decipher how they are storing/retrieving information from
    the tables, |
    | this is the long way around it but it should work.
    |

    +-------------------------------------------------------------------------------------+

    | May 2006 - AJM re-edited by RJP
    |

    +-------------------------------------------------------------------------------------+*/


    /*+-------------------------------------------------------------------------------------+

    | First we get all distinct records that have the matching criteria
    from the search |
    | page (directory.htm)
    |

    +-------------------------------------------------------------------------------------+

    | Determine which fields they have used: Name, City, Zip - and build
    the WHERE clause |

    +-------------------------------------------------------------------------------------+*/

    $sql = "SELECT DISTINCT sub_rec_id "
    ." FROM pf_submissions "
    ." WHERE ";

    if($_POST['Name']>"")
    $sql .= " (sub_fld_name LIKE '%name%' AND sub_fld_value LIKE '%".
    $_POST['Name']. "%') AND ";

    if($_POST['City']>"")
    $sql .= " (sub_fld_name LIKE '%city%' AND sub_fld_value LIKE '%".
    $_POST['City']. "%') AND ";

    if($_POST['Zip']>"")
    $sql .= " (sub_fld_name LIKE '%zip%' AND sub_fld_value LIKE '%".
    $_POST['Zip']. "%') AND ";

    $sql .= " 1=1 "
    ." ORDER BY sub_rec_id ASC";

    //echo "sql=".$sql."<b r>\n";
    $qry = mysql_query($sq l);

    /*+-------------------------------------------------------------------------------------+

    | Now, if there are any records, we'll step through getting the name
    first. |

    +-------------------------------------------------------------------------------------+*/

    while($row=@mys ql_fetch_array( $qry))
    {
    $sqlName = "SELECT sub_fld_value "
    ." FROM pf_submissions "
    ." WHERE sub_rec_id = '" .$row["sub_rec_id "]. "' "
    ." AND sub_fld_name = 'Full Name'";
    //echo "sqlName=".$sql Name."<br>\n";

    $qryName = mysql_query($sq lName);
    $rowName = @mysql_fetch_ro w($qryName);
    //print_r($rowNam e);
    //print("<br>\n") ;

    print(" <tr height='20'><td valign='top'><p
    style='margin-left:150'><font
    size='2'>".$row Name[0]."</font></td></tr><br>\n");


    /*+---------------------------------------------------------------------------------+

    | Now, if there are any records, we'll step through getting the
    office address. |

    +-----------------------------------------------------------------------------------+*/

    $sqlAddress = "SELECT sub_fld_value "
    ." FROM pf_submissions "
    ." WHERE sub_rec_id = '" .$row["sub_rec_id "]. "' "
    ." AND sub_fld_name = 'Office Address'";
    // echo "sqlAddress=".$ sqlAddress."<br >\n";

    $qryAddress = mysql_query($sq lAddress);
    $rowAddress = @mysql_fetch_ro w($qryAddress);
    print(" <tr height='20' valign='top'><t d valign='top'><p
    style='margin-left:150'><font
    size='2'>".$row Address[0]."</font></td></tr><br>\n");



    /*+-----------------------------------------------------------------------------------+

    | Now, if there are any records, For now we get the Office City.
    |

    +-------------------------------------------------------------------------------------+*/

    $sqlCity = "SELECT sub_fld_value "
    ." FROM pf_submissions "
    ." WHERE sub_rec_id = '" .$row["sub_rec_id "]. "' "
    ." AND sub_fld_name = 'Office City'";
    //echo "sqlCity=".$sql City."<br>\n";

    $qryCity = mysql_query($sq lCity);
    $rowCity = @mysql_fetch_ro w($qryCity);
    print(" <tr height='20'><td valign='top'><p
    style='margin-left:150'><font
    size='2'>".$row City[0]."</font></td></tr><br>\n");


    /*+-------------------------------------------------------------------------------------+

    | Now, if there are any records, we'll step through getting the
    Office state. |
    | RJP 05/28/06
    |

    +-------------------------------------------------------------------------------------+*/

    $sqlState = "SELECT sub_fld_value "
    ." FROM pf_submissions "
    ." WHERE sub_rec_id = '" .$row["sub_rec_id "]. "' "
    ." AND sub_fld_name = 'Office State'";
    //echo "sqlState=".$sq lState."<br>\n" ;

    $qryState = mysql_query($sq lState);
    $rowState = @mysql_fetch_ro w($qryState);
    print(" <tr height='20'><td valign'top'><p
    style='margin-left:150'><font
    size='2'>".$row State[0]."</font></td></tr><br>\n");

    /*+-------------------------------------------------------------------------------------+

    | Now, if there are any records, we'll step through getting the
    Office zip. |
    | RJP 05/17/06
    |

    +-------------------------------------------------------------------------------------+*/

    $sqlZip = "SELECT sub_fld_value "
    ." FROM pf_submissions "
    ." WHERE sub_rec_id = '" .$row["sub_rec_id "]. "' "
    ." AND sub_fld_name = 'Office Zip'";
    //echo "sqlZip=".$sqlZ ip."<br>\n";

    $qryZip = mysql_query($sq lZip);
    $rowZip = @mysql_fetch_ro w($qryZip);
    print(" <tr height='20'><td valign'top'><p
    style='margin-left:150'><font
    size='2'>".$row Zip[0]."</font></td></tr><br>\n");


    /*+------------------------------------------------------------------------------------+

    | Now, if there are any records, we'll step through getting the
    Office Phone Number. |
    | RJP 05/17/06
    |

    +-------------------------------------------------------------------------------------+*/

    $sqlPhone = "SELECT sub_fld_value "
    ." FROM pf_submissions "
    ." WHERE sub_rec_id = '" .$row["sub_rec_id "]. "' "
    ." AND sub_fld_name = 'Office Phone'";
    //echo "sqlPhone=".$sq lPhone."<br>\n" ;

    $qryPhone = mysql_query($sq lPhone);
    $rowPhone = @mysql_fetch_ro w($qryPhone);
    print(" <tr height='20'><td valign='top'><p
    style='margin-left:150'><font
    size='2'>".$row Phone[0]."</font></td></tr><br>\n");


    /*+------------------------------------------------------------------------------------+

    | Now, if there are any records, we'll step through getting the
    Website. RJP 05/17/06 |

    +-------------------------------------------------------------------------------------+*/

    $sqlWeb = "SELECT sub_fld_value "
    ." FROM pf_submissions "
    ." WHERE sub_rec_id = '" .$row["sub_rec_id "]. "' "
    ." AND sub_fld_name = 'Website Address'";
    //echo "sqlWeb=".$sqlW eb."<br>\n";

    $qryWeb = mysql_query($sq lWeb);
    $rowWeb = @mysql_fetch_ro w($qryWeb);
    print(" <tr height='20'><td valign='top'><p
    style='margin-left:150'><font
    size='2'>".$row Web[0]."</font></td></tr><br>\n");






    print(" </tr>\n");
    }

    //below this is the function for no record!!
    if (!$variable1)
    {
    print ("$XX");
    // echo " </tr>\n";
    }
    //end

    ?>


    </table>

    </table>

    </div>
    </body>

    </html>

  • Marcin Dobrucki

    #2
    Re: Desperate help needed on tables in .php



    Ladysniper@gmai l.com wrote:[color=blue]
    > DESPERATE doesn't begin to describe it.
    >
    > Can someone PLEASE tell me what is WRONG with this code?[/color]

    Without even going into the php, IMHO you need to tidy up the HTML
    that the code generates:

    <a href="/directory.htm"> <font color="#990000" >Member
    Directory</font></a><font color="#990000" >&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;
    </font>

    5 non breaking spaces in a shade of red? Surely, there is better
    ways to space things. I'd also suggest using some basic CSS for the
    table layouts instead of trying to give all cells own parameters.

    Lastly, try some html table generators. Yours is broken, eg:

    <tr height='20'><td valign'top'><p style='margin-left:150'><font
    size='2'>AZ</font></td></tr><br>

    <tr height='20'><td valign'top'><p style='margin-left:150'><font
    size='2'>85259</font></td></tr><br>

    At least '=' is missing here.

    /Marcin

    Comment

    • Geoff Berrow

      #3
      Re: Desperate help needed on tables in .php

      Message-ID: <1148875699.928 003.240630@i40g 2000cwc.googleg roups.com> from
      Ladysniper@gmai l.com contained the following:
      [color=blue]
      >Warning...lo ng coding....[/color]

      Gulp! That is one messy bit of code. Deprecated code, nested tables,
      no CSS. Ugh!

      Your database queries (which I'm sure can be optimised) are outputting
      something like this

      print(" <tr height='20'><td valign='top'><p
      style='margin-left:150'><font
      size='2'>".$row Name[0]."</font></td></tr><br>\n");

      For starters, that's a single column. It will never line up with a multi
      column header

      Frankly I wouldn't even try to start fixing this. It needs to be
      rewritten from scratch.


      --
      Geoff Berrow (put thecat out to email)
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • Erwin Moller

        #4
        Re: Desperate help needed on tables in .php

        Ladysniper@gmai l.com wrote:
        [color=blue]
        > DESPERATE doesn't begin to describe it.
        >
        > Can someone PLEASE tell me what is WRONG with this code?
        >
        > Now..a bit of background. It is a search results page for
        > http://www.azsoma.info/directory.htm. (use Scottsdale for the city)
        >
        > If you go look, you see that the search results post (I do have my
        > table borders up for debugging) but it doesn't line up with the table
        > above it...the whole scroll background doesn't show up and I cannot get
        > my results to have a space between them. And on top of it...they want
        > an inline frame! I haven't even attempted that...at all....
        >
        > Please...can someone help me. Hell, I'll pay someone if I have to...be
        > glad to...but this page needs to be done for the client....
        >
        > Warning...long coding....
        >
        > Thank you in advance....plea se, if someone could/would help me....[/color]

        <snipped code>

        Hi,

        Please try to be nice to this group.
        Instead of expecting from the readers to wrestle through many many unrelated
        lines of (broken) HTML, you might consider to strip it down to your
        coreproblem, and post that.

        A possible healthy side effect: When you strip the code down the problem,
        you often see what is wrong yourself because you are not subtracted by
        noise.)

        Of course, if you are lucky a friendly soul will answer you anyway.
        Your chances to get an answer are just better if you keep your question to
        the point.

        Regards,
        Erwin Moller

        Comment

        • David Haynes

          #5
          Re: Desperate help needed on tables in .php

          Ladysniper@gmai l.com wrote:[color=blue]
          > DESPERATE doesn't begin to describe it.
          >
          > Can someone PLEASE tell me what is WRONG with this code?
          >
          > Now..a bit of background. It is a search results page for
          > http://www.azsoma.info/directory.htm. (use Scottsdale for the city)
          >
          > If you go look, you see that the search results post (I do have my
          > table borders up for debugging) but it doesn't line up with the table
          > above it...the whole scroll background doesn't show up and I cannot get
          > my results to have a space between them. And on top of it...they want
          > an inline frame! I haven't even attempted that...at all....
          >
          > Please...can someone help me. Hell, I'll pay someone if I have to...be
          > glad to...but this page needs to be done for the client....
          >
          > Warning...long coding....
          >
          > Thank you in advance....plea se, if someone could/would help me....[/color]


          Wow! a lot of things could be improved on this page.

          1. Use a stylesheet.

          2. Dump the boxed comments especially when they state the obvious. (i.e.
          Now, if there are any records, we'll set through getting the xxx.)

          3. Since the only difference in a bunch of these is the xxx value, make
          it a function.

          function showInTable($su b_fld_name) {
          $sql = "select sub_fld_value "
          ."from pf_submissions "
          ."where sub_rec_id = '{$row['sub_rec_id']' "
          ."and sub_fld_name = '$sub_fld_name' ";

          $result = mysql_query($sq l);
          while( $row = @mysql_fetch_ro w($result) {
          ?>
          <tr height="20">
          <td valign="top">
          <p style="margin-left:150"> // stylesheets would be better here
          <font size="2">
          <?php echo $row[0];?>
          </font>
          </p>
          </td>
          </tr>
          <?php
          }
          $mysql_free_res ult($result);
          }

          This reduces your inner loop to something like:
          foreach( array('Full Name', 'Office Address', 'Office City', ...) as
          $field_name ) {
          showInTable($fi eld_name);
          }

          4. Remove the silly 1=1 test use a boolean flag to know whether this is
          the first entry (i.e. the where)

          5. You don't close your <form>

          6. Since both your outer table and inner table have width 800, I don't
          understand what you want the outer table to do.

          7. $variable1 is never set

          8. The <br> at the end of each table row will not cause double spacing.
          Either set double spacing up in the style sheet (preferred) or alter the
          showInTable function to emit an empty row (<tr><td>&nbsp; </td></tr>)
          after each populated row.

          That's probably enough to get you started.

          -david-


          Comment

          • Ladysniper@gmail.com

            #6
            Re: Desperate help needed on tables in .php

            Okay, I want to thank everyone who answered me. For the record, I
            didn't actually write the .php code for that search results page. I'm
            just trying to get the .html part to work, with the .php. The guy who
            wrote it... I told him the tables didn't line up right..he said it was
            in the .html code...and I've been looking for DAYS now! I felt it was
            in the .php code...somewher e....

            Question...how do I embed the .php in a style sheet? See, I'm totally
            new at this. Though I'm learning (and I've taken the above pointers in
            hand! Thanks!) I still don't quite know enough to take what he wrote
            and make it work. (sighs)..

            Okay, I'll try to work from here and see what I can do with it..and
            I'll try to clean up that code some! I found it annoying to work with
            also, but not knowing that much about .php, I didn't know if I could
            take the comments out, nor can I find where the error is to just post
            the problem.... etc....

            Thanks! You guys are awesome!!

            Comment

            • Kimmo Laine

              #7
              Re: Desperate help needed on tables in .php

              <Ladysniper@gma il.com> wrote in message
              news:1148906348 .769964.314370@ u72g2000cwu.goo glegroups.com.. .
              [color=blue]
              > Question...how do I embed the .php in a style sheet? See, I'm totally
              > new at this. Though I'm learning (and I've taken the above pointers in
              > hand! Thanks!) I still don't quite know enough to take what he wrote
              > and make it work. (sighs)..[/color]


              It works just the opposite. You embed the stylesheet into the php, not vice
              versa. :)
              place the following tag into your php sourcecode somewhere in the
              <head></head> section: <link rel="stylesheet " type="text/css"
              href="mystyle.c ss" /> and write the css-rules into <mystyle.css> . There are
              a few other ways to embed a stylesheet (style-tag, import) but that's the
              basic case.



              --
              "ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
              spam@outolempi. net | Gedoon-S @ IRCnet | rot13(xvzzb@bhg byrzcv.arg)


              Comment

              • william.clarke@gmail.com

                #8
                Re: Desperate help needed on tables in .php

                Here a link you may find very useful for learning CSS:

                W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.


                Comment

                Working...