Page not right, when PHP runs it's 100%

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webandwe
    New Member
    • Oct 2006
    • 142

    Page not right, when PHP runs it's 100%

    Hi,

    I have a normal table with 3 rows.

    In the middle row I added antoher table with my php search script (search in the database).

    If you view the page the first time the 3rd row footer is gone and when you press the search button the results come up and the page display 100%.

    Does anyone know what might be causing this and what I should look for.

    Table HTML are all perfect and no bad or borken coding.
    Last edited by webandwe; Jul 23 '08, 08:35 AM. Reason: ?????????
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    You might need to post the relevant code ...

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      You claim the HTML is perfect and yet you seem to be missing a row... That doesn't seem possible.

      Post the code please and we can try to help spot the problem.
      It's hard to debug that what you can not see :)

      Comment

      • webandwe
        New Member
        • Oct 2006
        • 142

        #4
        Sorry about the long code....



        [PHP] <?php include("pass.p hp"); ?> [/PHP]

        [HTML]
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
        <html><head><ti tle>Agri Bonus</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link href="../images/agridb.css" rel="stylesheet " type="text/css">
        </head>

        <body>
        <table width="678" border="0" align="center" cellpadding="0" cellspacing="0" >
        <tr>
        <td bgcolor="#33669 9"><img src="../images/AB_BOTTOM.jpg" width="140" height="60"></td>
        </tr>
        <tr>
        <td height="18" bgcolor="#D2E1F 0">
        <p align="center"> <a href="admin.php ">Admin</a> | <a href="admin-view-form.php">View a Membership</a> | <a href="admin-update-form.php">Updat e</a> |<a href="admin-dform.php"> Delete</a>| <a href="search.ph p">Search by Memberhip No </a>|<a href="globalsea rch.php"> Global Search </a>|<a href="view.php" > View All Entries</a>| <a href="logout.ph p">Logout</a> </p>
        </td>
        </tr>
        <tr>
        <td height="280" align="center" valign="top" bgcolor="#FFFFF F">
        <table width="90%" border="0" cellspacing="0" cellpadding="0" >
        <tr>
        <td height="46"><di v align="center"> <strong>Searc h for a Membership by a Membership Number</strong></div></td>
        </tr>
        <tr>
        <td><div align="center"> <form name="form" action="search. php" method="get">

        <input name="q" id="q" type="text">

        <input type="submit" name="Submit" value="Search" />
        </form>

        [/HTML]

        [PHP]

        <?php

        // Get the search variable from URL
        $var = @$_GET['q'] ;
        $trimmed = trim($var); //trim whitespace from the stored variable

        // rows to return
        $limit=10;

        // check for an empty string and display a message.
        if ($trimmed == "")
        {
        echo "<p>Please enter a search term.</p>";
        exit;
        }

        // check for a search parameter
        if (!isset($var))
        {
        echo "<p>We dont seem to have a search parameter!</p>";
        exit;
        }

        include("databa se.php");

        // Build SQL Query
        $query = "select * from information where a1 like \"%$trimmed%\"" ; // EDIT HERE and specify your table and field names for the SQL query

        $numresults=mys ql_query($query );
        $numrows=mysql_ num_rows($numre sults);

        // If we have no results, offer a google search as an alternative

        if ($numrows == 0)
        {
        echo "<h4>Result s</h4>";
        echo "<p>Sorry, your search: &quot;" . $trimmed . "&quot; returned zero results</p>";

        // google
        echo "No Results was found, please try again";
        }

        // next determine if s has been passed to script, if not use 0
        if (empty($s)) {
        $s=0;
        }

        // get results
        $query .= " limit $s,$limit";
        $result = mysql_query($qu ery) or die("Couldn't execute query");

        // display what the person searched for
        echo "<p>You searched for: &quot;" . $var . "&quot;</p>";

        // begin to show results set
        echo "Results <br/>";
        $count = 1 + $s ;

        // now you can display the results returned
        while ($row= mysql_fetch_arr ay($result)) {
        echo "$count.)&nbsp; $title" ;
        echo("<table width=\"670\" border=\"0\" align=\"center\ " cellpadding=\"2 \" cellspacing=\"2 \" >
        <tr>
        <td height=\"31\">< span class=\"style1\ ">Registerd ed:</span> <span class=\"style2\ ">$row[a2]</span></td>
        <td colspan=\"2\">< span class=\"style1\ ">Last Update:</span> $row[b2]</td>
        </tr>
        <tr>
        <td width=\"283\">A griBonues Lidnr./ Memership no </td>
        <td colspan=\"2\"></td>
        </tr>
        <tr>
        <td width=\"283\">W agwoord / Password </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a3]</td>
        </tr>
        <tr>
        <td>Titel / Title</td>
        <td colspan=\"2\" class=\"style2\ ">$row[a4]</td>
        </tr>
        <tr>
        <td>Voorletter( s)/Initial(s):</td>
        <td colspan=\"2\" class=\"style2\ ">$row[a5]</td>
        </tr>
        <tr>
        <td>Noemnaam/ First Name: </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a6]</td>
        </tr>
        <tr>
        <td>Van / Surname</td>
        <td colspan=\"2\" class=\"style2\ ">$row[a7]</td>
        </tr>
        <tr>
        <td>ID Nr: </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a8]</td>
        </tr>
        <tr>
        <td>Besigheidsn aam / Business Name </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a9]</td>
        </tr>
        <tr>
        <td>Plaas naam / Farm Name </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a10]</td>
        </tr>
        <tr>
        <td>E-Pos / E-mail</td>
        <td colspan=\"2\" class=\"style2\ ">$row[a11]</td>
        </tr>
        <tr>
        <td>Taalvoorkeu r / Preferred Language </td>
        <td colspan=\"2\">< span class=\"style2\ ">$row[a12] </span>Other:
        <span class=\"style2\ ">$row[a13]</span></td>
        </tr>
        <tr>
        <td>Posadres / Postal Address </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a14]</td>
        </tr>
        <tr>
        <td>Telephone :</td>
        <td colspan=\"2\" class=\"style2\ ">$row[a15]</td>
        </tr>
        <tr>
        <td>Fax:</td>
        <td colspan=\"2\" class=\"style2\ ">$row[a16]</td>
        </tr>
        <tr>
        <td>Sel / Cell No </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a17]</td>
        </tr>
        <tr>
        <td>Do you want sms text to you </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a18]</td>
        </tr>
        <tr>
        <td>Landrosdist ik / Magisterial distict </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a19]</td>
        </tr>
        <tr>
        <td>Eskom Paalnr/pole no </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a20]</td>
        </tr>
        <tr>
        <td>GPS koordinaat / co-ordinate </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a21]</td>
        </tr>
        <tr>
        <td colspan=\"3\">I s jy 'n ladnbou boer, Are you an Agricultural Producer (Farmer)
        <span class=\"style2\ ">$row[a22]</span></td>
        </tr>
        <tr>
        <td>Aantal Arbeiders / No workers </td>
        <td colspan=\"2\" class=\"style2\ ">$row[a23]</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td colspan=\"2\">& nbsp;</td>
        </tr>
        <tr>
        <td colspan=\"3\">< div align=\"center\ ">
        <p><strong>Gews produksie / Crop Production <br>
        </strong>Lys slegs 3... </p>
        </div></td>
        </tr>
        <tr>
        <td><strong>1 . Somergraan /Summer grain: </strong></td>
        <td class=\"style2\ ">$row[a24]</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td width=\"154\">H ectare</td>
        <td width=\"209\">I nsetverskaffers / suppliers </td>
        </tr>
        <tr>
        <td class=\"style2\ ">1.1
        $row[a25]</td>
        <td width=\"154\" class=\"style2\ ">$row[a26]</td>
        <td width=\"209\" class=\"style2\ ">$row[a27]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">1.2
        $row[a28]</td>
        <td class=\"style2\ ">$row[a29]</td>
        <td class=\"style2\ ">$row[a30]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">1.3
        $row[a31]</td>
        <td class=\"style2\ ">$row[a32]</td>
        <td class=\"style2\ ">$row[a33]</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td><strong>2 . Wintergraan/ Winter grain </strong></td>
        <td class=\"style2\ ">$row[a34]</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>Hectare</td>
        <td>Insetverska ffers </td>
        </tr>
        <tr>
        <td class=\"style2\ ">2.1
        $row[a35]</td>
        <td class=\"style2\ ">$row[a36]</td>
        <td class=\"style2\ ">$row[a37]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">2.2
        $row[a38]</td>
        <td class=\"style2\ ">$row[a39]</td>
        <td class=\"style2\ ">$row[a40]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">2.3
        $row[a41]</td>
        <td class=\"style2\ ">$row[a42]</td>
        <td class=\"style2\ ">$row[a43]</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td><strong>3 . Oliesade / Oil seeds: </strong></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>Hectare</td>
        <td>Insetverska ffers </td>
        </tr>
        <tr>
        <td class=\"style2\ ">3.1
        $row[a44]</td>
        <td class=\"style2\ ">$row[a45]</td>
        <td class=\"style2\ ">$row[a46]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">3.2
        $row[a47]</td>
        <td class=\"style2\ ">$row[a48]</td>
        <td class=\"style2\ ">$row[a49]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">3.3
        $row[a50]</td>
        <td class=\"style2\ ">$row[a51]</td>
        <td class=\"style2\ ">$row[a52]</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td><strong>4 . Groente / Vegtables: </strong></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>Hectare</td>
        <td>Insetverska ffers </td>
        </tr>
        <tr>
        <td class=\"style2\ ">4.1
        $row[a53]</td>
        <td class=\"style2\ ">$row[a54]</td>
        <td class=\"style2\ ">$row[a55]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">4.2
        $row[a56]</td>
        <td class=\"style2\ ">$row[a57]</td>
        <td class=\"style2\ ">$row[a58]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">4.3
        $row[a59]</td>
        <td class=\"style2\ ">$row[a60]</td>
        <td class=\"style2\ ">$row[a61]</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td><strong>5 . Vrugte &amp; Neute / Fruits &amp; Nuts </strong></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>Hectare</td>
        <td>Insetverska ffers </td>
        </tr>
        <tr>
        <td class=\"style2\ ">5.1
        $row[a62]</td>
        <td class=\"style2\ ">$row[a63]</td>
        <td class=\"style2\ ">$row[a64]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">5.2
        $row[a65]</td>
        <td class=\"style2\ ">$row[a66]</td>
        <td class=\"style2\ ">$row[a67]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">5.3
        $row[a68]</td>
        <td class=\"style2\ ">$row[a69]</td>
        <td class=\"style2\ ">$row[a70]</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td colspan=\"3\">< div align=\"center\ "><strong>Diere produksie</strong></div></td>
        </tr>
        <tr>
        <td>6. Beeste / Cattle: </td>
        <td class=\"style2\ ">$row[a71]</td>
        <td>Hoeveel / Quantity:
        <span class=\"style2\ ">$row[a72]</span></td>
        </tr>
        <tr>
        <td>7. Skape / Sheep </td>
        <td class=\"style2\ ">$row[a73]</td>
        <td>Hoeveel / Quantity:
        <span class=\"style2\ ">$row[a74]</span></td>
        </tr>
        <tr>
        <td>8. Hoenders / Chickens </td>
        <td class=\"style2\ ">$row[a75]</td>
        <td>Hoeveel / Quantity:
        <span class=\"style2\ ">$row[a76]</span></td>
        </tr>
        <tr>
        <td>9. Varke / Pigs: </td>
        <td class=\"style2\ ">$row[a77]</td>
        <td>Hoeveel / Quantity:<span class=\"style2\ "> $row[a78]</span></td>
        </tr>
        <tr>
        <td>10. Wild / Game </td>
        <td class=\"style2\ ">$row[a79]</td>
        <td>Hoeveel / Quantity:
        <span class=\"style2\ ">$row[a80]</span></td>
        </tr>
        <tr>
        <td>11. Ander / Other </td>
        <td class=\"style2\ ">$row[a81]</td>
        <td>Hoeveel / Quantity:
        <span class=\"style2\ ">$row[a82]</span></td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td height=\"18\" colspan=\"3\">< div align=\"center\ "><strong>L ys slegs u drie Grootste insetverskaffer s / List only your three main input suppliers </strong></div></td>
        </tr>
        <tr>
        <td><div align=\"center\ " class=\"style2\ ">
        $row[a83]
        </div></td>
        <td><div align=\"center\ " class=\"style2\ ">
        $row[a84]
        </div></td>
        <td><div align=\"center\ " class=\"style2\ ">
        $row[a85]
        </div></td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td>Kooperasi e / Landboubesighei d<br>
        Co-op / Agricultural Business </td>
        <td colspan=\"2\">< div align=\"center\ ">Lidnr. / Rek.nr. / folionr.<br>
        Membership no / Acc no. / Folio </div></td>
        </tr>
        <tr>
        <td class=\"style2\ ">1.
        $row[a86]</td>
        <td class=\"style2\ ">$row[a87]</td>
        <td class=\"style2\ ">$row[a88]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">2.
        $row[a89]</td>
        <td class=\"style2\ ">$row[a90]</td>
        <td class=\"style2\ ">$row[a91]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">3
        $row[a92]</td>
        <td class=\"style2\ ">$row[a93]</td>
        <td class=\"style2\ ">$row[a94]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">4
        $row[a95]</td>
        <td class=\"style2\ ">$row[a96]</td>
        <td class=\"style2\ ">$row[a97]</td>
        </tr>
        <tr>
        <td class=\"style2\ ">5
        $row[a98]</td>
        <td class=\"style2\ ">$row[a99]</td>
        <td class=\"style2\ ">$row[a100]</td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td colspan=\"3\">< div align=\"center\ "><strong>A gri will graag help / Agri want's to help </strong></div></td>
        </tr>
        <tr>
        <td colspan=\"3\">< div align=\"center\ " class=\"style2\ ">
        $row[a101]
        </div></td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
        </table>");
        $count++ ;
        }

        $currPage = (($s/$limit) + 1);

        //break before paging
        echo "<br />";

        // next we need to do the links to other results
        if ($s>=1) { // bypass PREV link if s is 0
        $prevs=($s-$limit);
        print "&nbsp;<a href=\"$PHP_SEL F?s=$prevs&q=$v ar\">&lt;&lt;
        Prev 10</a>&nbsp&nbsp;" ;
        }

        // calculate number of pages needing links
        $pages=intval($ numrows/$limit);

        // $pages now contains int of pages needed unless there is a remainder from division

        if ($numrows%$limi t) {
        // has remainder so add one page
        $pages++;
        }

        // check to see if last page
        if (!((($s+$limit)/$limit)==$pages ) && $pages!=1) {

        // not last page so give NEXT link
        $news=$s+$limit ;

        echo "&nbsp;<a href=\"$PHP_SEL F?s=$news&q=$va r\">Next 10 &gt;&gt;</a>";
        }

        $a = $s + ($limit) ;
        if ($a > $numrows) { $a = $numrows ; }
        $b = $s + 1 ;
        echo "<p>Showing results $b to $a of $numrows</p>";

        ?>

        [/PHP]

        [HTML]

        </div></td>
        </tr>
        </table>
        </td>
        </tr>
        <tr>
        <td bgcolor="#33669 9"><div align="right">< img src="../images/AB_BOTTOM.jpg" width="140" height="60"></div></td>
        </tr>
        </table>
        </body>
        </html>

        [/HTML]

        Comment

        • webandwe
          New Member
          • Oct 2006
          • 142

          #5
          Just give me a second while I check whats up with the tags...And won't color my code

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #6
            Lines 14 and 21 of your PHP code.

            Assuming that all that code is on one page (search.php).
            The exit calls would stop the entire script, including any following HTML code.

            Try removing those two lines and re-designing the flow of the PHP code so that the rest of the code is dependent on the existence and validity of the search parameter.

            Comment

            Working...