PHP messing up my HTML..

Yes, php´s die()/exit() functions they end up the process of the current script! So what is below that code is not being loaded, even the html!

Use can use a simple print/echo and an aditional else/elseif for the sucess case!

Gesf
 
Something like:
Code:
<?php

if(isset($_POST['submit'])){

  if((!isset($_POST['user_input'])) || ($_POST['user_input'] == "")){
      print ("Enter a search term...this will be empty");
  }
  else{
      print ("Thanks, here goes your search result...");
  }

}

?>
 
Yep, your while loop must be inside the 'success' if statement! Outside, it will always run!

So try this:
Code:
<?php 
$connect = @mysql_connect("localhost", "JkasdfJSDF", "453609743987456") or die("could not connect to server"); 

$db_select = @mysql_select_db("database12") or die("could not select the database"); 

$SQL = "SELECT * FROM itemsearch WHERE itemname LIKE \"%$user_input%\""; 

$result = @mysql_query($SQL) or die("Could not run query"); 

if(isset($_POST['submit'])){ 

  if((!isset($_POST['user_input'])) || ($_POST['user_input'] == "")){ 
      print ("Enter a search term...this will be empty"); 
  } 
  else{ 
      while($row = mysql_fetch_array($result)) { 
          echo("<tr>"); 
          echo("<td class='cntbxleft'>"); 
          $url = ("$row[url]"); 
          echo("<a class='bluetu' href='$url'>$row[itemname]</a></td>"); 
          echo("<td class='cntbxmid'>$row[str]</td>"); 
          echo("<td class='cntbxmid'>$row[agi]</td>"); 
          echo("<td class='cntbxmid'>$row[sta]</td>"); 
          echo("<td class='cntbxmid'>$row[int]</td>"); 
          echo("<td class='cntbxmid'>$row[wis]</td>"); 
          echo("<td class='cntbxright'>$row[effect_one]  "); 
          echo("</tr>"); 
      }
   } 
}

?>
 
ARG! lol I did that, now it looks perfect, but the search itself doesnt work. =(...Any more ideas..heh...Thanks :help:
 
Ok, i saw you´ve added thing to the the 'search page', so i don´t know what you´ve done!

Please show me what changes you´ve done (php)!

But before that, please tell me:
Code:
if(isset($_POST['submit']))
Is your form submit button named submit !??
And... are you using post method in your form !?

Gesf
 
Yes, it worked fine before i changed it (besides the looks). I just copied and pasted your PHP, and of course changed the DB access stuff.
 
By the way, when you go to the page, try searching: short
You will see how the page "comes together".
 
Seems to work fine!
My guess you´re using the code for the form and result in only one html table, right !? That´s why when we make an empty search the table isn´t printed at all!

Put it in separated tables and open/close the one in the while loop!

Code:
<?php
...
  while($row = mysql_fetch_array($result)) { 
          echo("<table><tr>");                             // Changed line
          echo("<td class='cntbxleft'>"); 
          $url = ("$row[url]"); 
          echo("<a class='bluetu' href='$url'>$row[itemname]</a></td>"); 
          echo("<td class='cntbxmid'>$row[str]</td>"); 
          echo("<td class='cntbxmid'>$row[agi]</td>"); 
          echo("<td class='cntbxmid'>$row[sta]</td>"); 
          echo("<td class='cntbxmid'>$row[int]</td>"); 
          echo("<td class='cntbxmid'>$row[wis]</td>"); 
          echo("<td class='cntbxright'>$row[effect_one]  "); 
          echo("</tr></table>");                          // Changed line
      } 
...
?>

Gesf
 
Try use it, cos if I'm type one space char I got the list of somthing:
Code:
if (!isset(trim($_POST['user_input']))){ die("Enter a search term...this will be empty"); }
or
Code:
$user_input = trim($_POST['user_input']);
if( (!isset($user_input)) || ($user_input == "") ){ die("Enter a search term...this will be empty"); }
or
Code:
$user_input = trim($_POST['user_input']);
if (empty($user_input)) { die("Enter a search term...this will be empty"); }
 
Back
Top