Jump to content

Archived

This topic is now archived and is closed to further replies.

Renlok

php screwed up

Recommended Posts

I have a problem with layout i tryed putting all search quesy results into one table which has allternating colours, the first entry come out ok but the rest come out in a mess accros the page.
[code]<?php
  @ $db = mysqli_connect();
  if (mysqli_connect_errno())
  {
  echo 'Error: Could not connect to database. Please try again later.';
  exit;
  }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html><!-- InstanceBegin template="/Templates/Template.dwt.php" codeOutsideHTMLIsLocked="false" -->

<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>WeLink - Linking the Net.</title>
<!-- InstanceEndEditable -->
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">

<meta name="description" content="WeLink Main Page A Link Engine">

<meta name="keywords" content="we, link, we link, welink, ejam, links, search, new, ultamate, Arts, Fine Art, Music, Lessons, Sheet music, Tabs, Theatre, Business and Finance, Banking, Online Banking, Collections, Fantasy, Models,            Warhammer, Stamps, E-commerce, Fashion and Clothing, HomeWare, Auction Houses, Entertainment, Gaming, Game Communities, Game Sales, Flash Games, Web Games, Movies, Feature Films, Flash Movies, Knowledge, General Knowledge, Encyclopedic Knowledge, Nature, Gardening, Technology, Computing, Programming Languages,            Tutorials, Free scrips, Electronics, Phones, Travel, Cars, Suppliers, Travel Agencies, questions, question, mp3, cars, holidays, jobs, games, dating, music, web hosting, shopping, xbox, web designers, moblie phones, UK">

<style type="text/css"><!--

body {

background-color: #2e90cf;

}

.style1 {

color: #FFFFFF;

font-family: comic sans MS;

}

--></style>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body>
<table width="100%" border="0">
  <!--DWLayoutTable-->
  <tr>
    <td height="80" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="759" height="40" valign="top"><p>WeLink<br>
              'ReLinking The Net'</p></td>
        </tr>
        <tr>
          <td height="37" valign="top"><div><span style="background-color: rgb(255, 255, 255);"><a href="http://capersofkilwinning.co.uk/Game/phpBB-2.0.21/phpBB2/index.php"><font size="2">http://capersofkilwinning.co.uk/Game/phpBB-2.0.21/phpBB2/index.php</font>
              <br>
              </a> <font size="2"> The Forums.</font></span></div></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td height="24" colspan="2" valign="top"><a href="http://welink.ej.am">Search</a>
      &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://welink.ej.am/newsite.html">Add
      Site</a>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://welink.ej.am/question.php">Ask
      a Question</a> &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://welink.ej.am/categories.php">The
      Categories</a></td>
  </tr>
  <tr> <!-- InstanceBeginEditable name="Main" -->
    <td width="100%" height="389" valign="top"><div>
        <p>&nbsp; </p>
        <h1>WeLink Search Results </h1><br>
<center><style type="text/css">
        td.datacellone {
background-color: #BEDDF1; color: black;
        }
        td.datacelltwo {
background-color: #80BBE3; color: black;
        }
        </style>
<table>
        <tr>
            <td class="datacelltwo">Site Name</td>
            <td class="datacellone">URL</td>
            <td class="datacelltwo">Description</td>
            <td class="datacellone">Keywords</td>
            <td class="datacelltwo">Date Added</td>
            <td class="datacellone">Rating</td>
            <td class="datacelltwo">Rate site.</td>
        </tr>
<?php
$searchtype=$_POST['searchtype'];
$searchterm=$_POST['searchterm'];
$date=$_POST['date'];
$searchterm= trim($searchterm);

if (!$searchtype || !$searchterm)
{
echo 'You have not entered search details. Please go back and try again.';
exit;
}

if (!get_magic_quotes_gpc())
{
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
$date = addslashes($date);
}

$query = "select * from link where ".$searchtype." like '%".$searchterm."%'";
$result = $db->query($query);

$num_results = $result->num_rows;

echo '<p>Numbers of Links found '.$num_results.'</p>';

if ($num_results == 0)
{
echo 'There is no enteries containing you search word. Please feel free to add a site to our database <a href="http://welink.ej.am/newsite.html">http://welink.ej.am/newsite.html</a>';
}
for ($i=0; $i <$num_results; $i++)
{
$row = $result->fetch_assoc();
?>
        <tr>
            <td class="datacelltwo"><?php echo htmlspecialchars(stripslashes($row['siteName'])) ?></td>
            <td class="datacellone"><?php echo '<a href="'.stripslashes($row['url']).'">'.stripslashes($row['url']) ?></a></td>
            <td class="datacelltwo"><?php echo stripslashes($row['discription']) ?></td>
            <td class="datacellone"><?php echo stripslashes($row['keywords']) ?></td>
            <td class="datacelltwo"><?php echo stripslashes($row['timeEdited']) ?></td>
        <td class="datacellone">
        <?php
        $URL = ($row['url']);
        $rate_query = "SELECT AVG(ratingValue) FROM rating WHERE URL = '$URL'";
        $rate_result = $db->query($rate_query);
        $row = $rate_result->fetch_row();
        $avg = $row[0];
        echo $avg.'</td><td class="datacelltwo">';
        echo '<form name="'.$URL.'" form action="rate.php" method="post" target="_blank" form>'.
        '<select name="rate">'.
            '<option value="1">1</option>'.
            '<option value="2">2</option>'.
            '<option value="3">3</option>'.
            '<option value="4">4</option>'.
            '<option value="5">5</option>'.
            '<option value="6">6</option>'.
            '<option value="7">7</option>'.
            '<option value="8">8</option>'.
            '<option value="9">9</option>'.
            '<option value="10">10</option>'.
        '</select>'.
        '<input name="url" type="hidden" value="'.$URL.'" size="13" maxlength="125">'.
      '<input type="submit" value="Submit">'.
    '</form>';
?>
</td></tr></table></center>
<?php
}
mysqli_free_result($result);
$db->close();

?>
        <p><br>
        <hr>
        <br>
        <p> If theres any errors with the data tell me via the forums or send
          me an email addressed to <i>admin@welink.ej.am</i> containing the site
          name and url and anyupdates/changes that you think [/code]

Share this post


Link to post
Share on other sites
I followed your link. Then I did a "show source". Your genereated HTML is filled with errors. If you generate correct HTML, your page will be correct. There are a lot of openning [nobbc]<tr>[/nobbc] tags with no closing [nobbc]</tr>[/nobbc] tags.

As for your date() question, the first argument to the date() function needs to be a string:
[code]<?php date('Y-m-d'); ?>[/code]

Ken

Share this post


Link to post
Share on other sites
and theres nothing wrong with my html tags i just loads wrong read the code above

Share this post


Link to post
Share on other sites
now ive sorted out the html by moving the '}' bracket at the end.
the query near the end wont work still though

Share this post


Link to post
Share on other sites

×

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.