Hi Banal,
I am trying to do it the SilverStripe method now, because I want to code to be clean and I want to output to be shown in the content div and not in the same box on the right.
When I do this:
public function IncludeDealerLocator() {
session_start();
require_once(Director::baseFolder() . '/test/dbconnect.php');
if ($_POST['address_submit'] == "1")
{
if ((strlen($_POST['postcode']) == "6") && (substr($_POST['postcode'], 0, 4) >= "1000") && (substr($_POST['postcode'], 0, 4) <= "9999") && (eregi("([a-z])", substr($_POST['postcode'], 4, 2))))
{
$pc = $_POST['postcode'];
$query1 = "SELECT OW, NZ FROM hbt_postcodes WHERE postcode = '$pc'";
$result1 = mysql_query($query1) or die('Fout : ' . mysql_error());
while($row = mysql_fetch_array($result1, MYSQL_ASSOC))
{
$pc1 = $row['postcode'];
$OW = $row['OW'];
$NZ = $row['NZ'];
print "<div class=groen>Ingegeven postcode: $pc</div>";
print "<br>";
}
$OWp = $OW + (10*0.0146);
$OWm = $OW - (10*0.0146);
$NZp = $NZ + (10*0.009);
$NZm = $NZ - (10*0.009);
$query2 = "SELECT * FROM hbt_postcodes AS p, Dealer AS d WHERE d.postcode=p.postcode AND p.nz BETWEEN $NZm AND $NZp AND p.ow BETWEEN $OWm AND $OWp";
$result2 = mysql_query($query2) or die('Fout : ' . mysql_error());
$aantal = mysql_num_rows($result2);
print ("Er werd(en) $aantal record(s) gevonden<br><br>");
while($row2 = mysql_fetch_array($result2, MYSQL_ASSOC))
{
$naam2 = $row2['naam'];
$adres2 = $row2['adres'];
$postc2 = $row2['postcode'];
$plaat2 = $row2['plaats'];
$telef2 = $row2['telefoon'];
$web2 = $row2['website'];
print "<div class=vetrood>$naam2</div>";
print "<div class=groen>$adres2, $postc2 $plaat2, $telef2";
if ($web2 !='') { print ", <a href=\"http://$web2\">$web2</a>"; }
print "</div><br />";
}
}
} elseif ($_POST['plaats_submit'] == "1") { // ZOEKEN OP PLAATSNAAM
$plaats = $_POST['plaats'];
$query = "SELECT * FROM Dealer WHERE plaats LIKE '%". $_POST['plaats'] . "%'";
$result = mysql_query($query) or die ("Fout: ". mysql_error());
$aantal = mysql_num_rows($result);
print "<div class=groen>Ingegeven postcode: $plaats</div>";
print "<br>";
print ("Er werd(en) $aantal record(s) gevonden<br><br>");
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$naam = $row['naam'];
$adres = $row['adres'];
$postc = $row['postcode'];
$plaat = $row['plaats'];
$telef = $row['telefoon'];
$web = $row['website'];
print "<div class=vetrood>$naam</div>";
print "<div class=groen>$adres, $postc $plaat, $telef";
if ($web !='') { print ", <a href=\"http://$web\">$web</a>"; }
print "</div><br />";
}
} else {
print "<div><p>Zoek op postcode:</p></div>";
print "<div><form method=\"post\">";
print "<input type=\"hidden\" name=\"address_submit\" value=\"1\">";
print "<p><input type=\"text\" name=\"postcode\" maxlength=\"6\"></p></div>";
print "<div><input type=\"submit\" value=\"Zoek\">\n";
print "</form>\n</div>";
print "<p>Zoek op plaats:</p>";
print "<form method=\"post\">\n";
print "<input type=\"hidden\" name=\"plaats_submit\" value=\"1\">\n";
print "<p><input type=\"text\" name=\"plaats\" maxlength=\"50\"><br>\n</p>";
print "<input type=\"submit\" value=\"Zoek\">\n";
print "</form>\n";
}
}
The dealer locator is just at the top of the page and not even in it's div where the variable is.
So I need to do something like:
$output = all the code above
return $output=>renderWith ('Page')
or how does this work?
I want to search forms at the right side of the page in my div,
and the output must be in the middle (content div)