Jump to content

php and mysql search


chriscloyd

Recommended Posts

heres my problem my code its not returning any thing at all

here my code to show the search

<?php
switch($_GET['p']) {
case "searchnews":
$keyword = $_POST['keyword'];
$get_like_news = mysql_query("SELECT * FROM cegl_news WHERE username LIKE '%".$keyword."%' AND subject LIKE '%".$keyword."%' AND date LIKE '%".$keyword."%' AND message LIKE '%".$keyword."%'") or die(mysql_error());
?>
<fieldset><legend><strong>Search - Looking For <?php echo $keyword; ?></strong></legend>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25%" class="teams">News Title</td>
<td class="teams">Author</td>
<td class="teams">Date</td>
<td width="15%" class="teams">Commands</td>
</tr>
<?php
while ($news = mysql_fetch_array($get_like_news)) {
?>
<tr>
<td width="20%" height="25" class="teams"><?php echo $news['subject']; ?></td>
<td width="20%" height="25" class="teams"><div align="left"><?php echo $news['username']; ?></div></td>
<td width="20%" height="25" class="teams"><?php echo $news['date']; ?></td>
<td width="15%" height="25" class="teams"><form name="form1">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option selected>Commands</option>
<option value="admin.php?p=editnews&id=<?php echo $news['news_id']; ?>">Edit</option>
<option value="admin.php?p=movenews&id=<?php echo $news['news_id']; ?>">Move News</option>
<option value="admin.php?p=deletenews&id=<?php echo $news['news_id']; ?>">Delete</option>
</select>
</form></td>
</tr>
<?
}
?>
</table>
</fieldset>
<?php
break;
}
?>

 

heres the form that submitting the search

 

<html>
<form name="form1" method="post" action="admin.php?p=searchnews">
<table class="teamlinks"  width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="7%">Search</td>
<td width="60%"><input name="keyword" type="text" id="keyword"></td>
<td width="33%"><input type="submit" name="Submit" value="Search"></td>
</tr>
</table>
</form>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.