I have created a page for search, and I'm having some problems.
The data is displayed on the page but I also use some fields on the form for a specific field, so when I enter the data in those fields and hit search, it shows the search field on the top of the display page with the rest of the data, but I want only the data which belongs to my search.
CODE:
<?php
include('connect.php');
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include('include/head.php')?>
</head>
<body>
<div id="header-wrapper">
<div id="header">
<div id="menu">
<ul>
<?php include('include/menu.php') ?>
Logout
</ul>
</div>
</div>
</div>
<div id="logo">
<?php include('include/logo.php'); ?>
</div>
<div id="wrapper">
<div id="page">
<div id="page-bgtop">
<div id="content">
<div class="post">
<div class="entry-image">
<?php
$q=mysql_query("SELECT count( php ) AS ph, count( dotnet ) AS dot, count( design ) AS des FROM candidate");
while($row=mysql_fetch_array($q))
{
?>
<form name="" method="post">
<table border="1" cellpadding="10" cellspacing="1" width="280" height="200">
<th colspan="5" bgcolor="orange" >Total Number of Resume by skills</th>
<tr>
<th><B>PHP</B></th>
<th><B>DOTNET</B></th>
<th><B>DESIGN</B></th>
</tr>
<td><?php echo "$row[ph]"; ?></td>
<td><?php echo "$row[dot]"; ?></td>
<td><?php echo "$row[des]"; ?></td>
</table>
</form>
<?php
}
?>
</div>
<h2 class="title">Welcome to Resume </h2>
<div class="entry">
<p>
<form name="search" method="post" action="searchview.php">
<table>
<tr>
Id: <input type="text" name="id" /></br></br>
Name:<input type="text" name="name" /><br/></br>
Expected Salary:<input type="text" name="es" /><br/></br>
Skill Rate: <input type="text" name="sr" /><br/> </br>
Salary:<input type="text" name="cs" /></br></br>
<input type="submit" name="submit" value="seach" /><input type="reset" name="reset" value="reset" />
</tr>
</table>
</form>
</p>
</div>
</div>
<div class="post" >
<?php
$query=mysql_query("select * from candidate");
while($row=mysql_fetch_array($query))
{
$sno=$row['id'];
$image=$row['image'];
$name=$row['fname'];
$es=$row['es'];
$sr=$row['sr'];
$cs=$row['cs'];
?>
<form name="view" method="post" action="searchview.php" >
<table border="1" cellpadding="30" class="centered" width="20" >
<tr>
<th width="150">S.NO</th>
<th width="150">IMAGE</th>
<th width="150">NAME</th>
<th width="150">EXPECTED SALARY</th>
<th width="150">SKILL RATE</th>
<th width="150">SALARY</th>
<th width="150">ACTION</th>
</tr>
<td><?php echo "$row[id]"; ?></td>
<td><div class="rightdiv1a"><img src="<?php echo 'img/'.$row['image']; ?>" style="height:120px; width:145px; "></div></td>
<td><?php echo "$row[fname]"; ?></td>
<td><?php echo "$row[es]"; ?></td>
<td><?php echo "$row[sr]"; ?></td>
<td><?php echo "$row[cs]"; ?></td>
<td><img alt='view' title='view' src='images/view.png' width='15px' height='15px' hspace='20' /></td>
<td><img alt='Edit' title='Edit' src='images/edit.png' width='15px' height='15px' hspace='20' /></td>
<td><a onclick="return confirm('Would you like to delete?');" href="delete.php?id=<?php echo "$row[id]"; ?>"><img alt='delete' title='delete' src='images/delete.png' width='15px' height='15px' hspace='20' /></a></td>
</table>
</form>
<?php
}?>
</div>
</div>
</div>
</div>
</div>
<div id="footer-bgcontent">
<div id="footer">
<?php// include('include/footer.php');?>
</div>
</div>
</body>
</html>
<?php// } ?>
This code displays the data now but I want to filter the data and only show the results which belongs to my search, and have the rest disappear.
Here are some screenshots of my form:
pls help,
thanks in advance..
If I understand the question correctly, you want to display the search results, but no longer show the search form. If this is the case, then move your second "post" div to the top and wrap it in an if:
if (!empty($_POST)) {
// Process POST results here:
...
die(); // end processing so the form doesn't display again
}
Related
I have popup it works normal i need to use method post to get my value from the input balise but the problem is when i do form the popup window displays in just a second then hide again and I need to click two time becausethe first time i got just the last result
<div class="List_modify">
<table class="list">
<thead class="topBar">
<tr>
<th>Prenom</th>
<th>Nom</th>
<th>CIN</th>
<th>Emails</th>
<th>Références</th>
<th>Photos</th>
<th>Niveau</th>
<th class="button_editer" style="vertical-align:middle"><span>Editer</span></th>
</tr>
</thead>
<?php $requet = "select * from Etudiants";
$resultat = mysqli_query($connecte, $requet);
while ($r = mysqli_fetch_array($resultat)) {
?>
<tbody class="container">
<tr>
<td>
<?php echo $r['Prenom']; ?>
</td>
<td>
<?php echo $r['Nom']; ?>
</td>
<td>
<?php echo $r['CIN']; ?>
</td>
<td>
<?php echo $r['Emails']; ?>
</td>
<td>
<?php echo $r['Matricule']; ?>
</td>
<td> <img src="image/<?php echo $r['Photo']; ?> " style="width: 150px; height:150px;"></td>
<td>
<?php echo $r['Niveau']; ?> </td>
<td>
<form method="POST" action="">
<input type="hidden" name="id" value="<?php echo $r['Id_Etudiant']; ?>">
<button class=" button" onclick="show()" style="vertical-align:middle" type="submit" name="submit"><span>Editer<i class=" fas fa-user-edit"></i></span>
</button>
</form>
</td>
</tr>
</tbody>
<?php } ?>
</table>
</div>
<div class="background_page_modify" id="page_modify" onclick="hide()">
<div class="page_etudiant" onclick="event.stopPropagation()">
<div class="closebtn" id="closebtn" onclick="hide()">
<div class="circle"> +</div>
</div>
<div class="etudiant_box">
<?php
if (isset($_REQUEST['submit'])) {
$checkid = $_REQUEST['id'];
echo $checkid;
}
?>
</div>
</div>
</div>
https://www.dropbox.com/s/e89hjxrogghll9a/1.jpg?dl=0
https://www.dropbox.com/s/sjqfsuwj9mlpc2o/2.jpg?dl=0
see the link above for the image. the image show the process
if i click my selected tables, it cannot select the correct data. here is my code. Thank you for the Help
<table id="example2" class="table table-bordered table-hover">
<thead>
<tr>
<th>Code</th>
<th>Date of Request</th>
<th>Requestor Name</th>
<th>Form Type</th>
<th>Request Type</th>
<th>Details</th>
<th>Date Needed</th>
<th>Action</th>
</tr>
</thead>
<?php
$req1 = mysql_query('select * from mainviewrequestor where username="'.$_SESSION['username'].'" and req_dateapprove IS NULL');
while($dn1 = mysql_fetch_array($req1))
{
?>
<tr>
<td><?php echo date($dn1['req_code']); ?></td>
<td><?php echo date($dn1['req_date']); ?></td>
<td class="left"><?php echo htmlentities($dn1['empname'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($dn1['form_name'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> <?php echo $dn1['itrf_type']?></td>
<td> <?php echo $dn1['itrf_details']?></td>
<td> <?php echo $dn1['req_dateneeded']?></td>
<td class="left"><button type="submit" class="btn btn-primary" name="approved">View</button>
<button type="submit" class="btn btn-primary" name="btn-sub2">DisApproved</button></td>
</tr>
<?php
}
if(intval(mysql_num_rows($req1))==0)
{
?>
<tr>
<td colspan="4" class="center">You have no unread message.</td>
</tr>
<?php
}
?>
</table>
<br />
<?php
}
?>
</table>
</div><!-- /.box-body -->
</div><!-- /.box -->
</div><!-- /.col -->
</div><!-- /.row -->
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<?php
$req1 = mysql_query('select * from mainviewrequestor2');
while($dn1 = mysql_fetch_array($req1))
{
?>
<!--Pop-up modal Code-->
<div class = "modal fade" id="proceed" role="dialog">
<div class = "modal-dialog modal-lg">
<div class = "modal-content">
<div class = "modal-header">
<h4>REQUEST TABLES</h4>
<h2>------------------------------------------------------------------------------------------</h2>
<div class="content">
<form>
<label>Date Created: </label><input type="text" name="req_date" id="req_date" value="<?php echo ($dn1['req_date']); ?>" /><br />
<label>Request By: </label><input type="text" name="empname" id="empname" value="<?php echo ($dn1['empname']) ?>" /><br />
<label>Form Name: </label><input type="text" name="form_name" id="form_name" value="<?php echo $dn1['form_name']?>" /><br />
<label>Request Type: </label><input type="text" name="itrf_type" id="itrf_type" value="<?php echo $dn1['itrf_type']?>" /><br />
<label>Details: </label><input type="text" name="itrf_details" id="itrf_details" value="<?php echo $dn1['itrf_details']?>" /><br />
<label> Date Needed:</label><input type="text" name="req_dateneeded" id="req_dateneeded" value="<?php echo $dn1['req_dateneeded']?>" /><br />
<button type="submit" class="btn btn-primary" name="req_code">Approved</button>
<button type="submit" class="btn btn-primary" name="update2">Disapproved</button>
</form>
</div>
<?php
}
?>
You need to replace the #proceed id on each modal element, and h ref element, so that they correspond
For your table
<a href="#proceed-<?php echo $req1['id'];?>" data-toggle="modal">
For your modal
while($dn1 = mysql_fetch_array($req1))
{?>
<div class = "modal fade" id="proceed-<?php echo $dn1['id'];?>" role="dialog">
Although this is a rather ugly way of choosing to do things.
I would instead only create one modal, and pass the ID to an ajax function to load the said form. But thats just me, and thats a whole other topic.
But this should fix your issue.
I make search form and I'm using it as ajax searchform.
I have problems in html(data), when I put the html(data) it will display the loading image and the table too it will double here's my code:
$(document).ready(function(){
$("#loading").hide();
<?php $type_temp = (!empty($type)) ? 'company/' .$type:'company';?>
$("#search_id").click(function(){
$("#loading").show();
$.post("<?php echo url_for('/AdmSys_dev.php/' .$type_temp); ?>", $("#send_search").serialize(), function(data){
$(".result").html(data);
});
});
});
How will I put the result into the page?
heres my html code below
<div id="sf_admin_content">
<h2>Company</h2><br />
<div style="margin-bottom:20px;">
<form id="send_search" action="" method="get">
<input type="text" name="search" placeholder="Search: " value="<?php echo $search; ?>" />
<input id="search_id" type="button" value="Search" />
</form>
</div>
Add
<div id="loading" style="margin-left:186px; margin-top:30px;">
<img alt="" src="/images/preloader_transparent.gif" />
</div>
<table class="location" cellspacing="0" style="width:500px;">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Description</th>
<th>Photo</th>
<th>Option</th>
</tr>
</thead>
<tbody class="result">
<?php foreach($company as $x => $companies): ?>
<tr id="company<?php echo $companies->getId(); ?>" class="<?php echo ($x&1) ? 'even':'odd'; ?>">
<td align="right"><?php echo $companies->getId(); ?></td>
<td><?php echo $companies->getName(); ?></td>
<td><?php echo $companies->getDescription(); ?></td>
<td><img alt="" src="/uploads/company/<?php echo $companies->getImageFull(); ?>" /></td>
<td align="right">
<a href="<?php echo url_for('company/edit?id=' .$companies->getId() )?>">
<img alt="edit" src="/images/pencil.png" />
</a>
<a href="#delete" title="delete" onclick="return goDelete(<?php echo $companies->getId(); ?>)">
<img alt="delete" src="/images/delete.png" />
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
$type_temp = (!empty($type))?'company/'.$type:'company';
$data = array(
'maxPerPage' => $company->getmaxPerPage(),
'lastPage' => $company->getlastPage(),
'nbResults' => $company->getnbResults(),
'curPage' => $curPage,
'linkPage' => '/AdmSys.php/company'.$type_temp. '?search'.$search
);
include_partial('event/pager',$data); ?>
</div>
as youve notice i put the class results in the <tbody class="result></tbody>
I'm trying to put a link around data in a table. So if the user clicks on the link it will bring them to the edit page for that item. Every time I put the code in the data will disappear from the table. Here is the code for my page I'm working on:
I'm trying to put clickable data at the start of the table code
<?php include '../view/header.php'; ?>
<div id="main">
<h1>Product List</h1>
<div id="content">
<!-- display a table of products -->
<h2><?php echo $name; ?></h2>
<table>
<tr>
<th>Code</th>
<th>Name</th>
<th class="right">Version</th>
<th> </th>
</tr>
<?php foreach ($products as $product) : ?>
<tr>
<td> <a href="?action=view_product&product_id=<?php echo $product['productCode']; ?>"</a></td>
<td><?php echo $product['name']; ?></td>
<td class="right"><?php echo $product['version']; ?></td>
<td><form action="." method="post">
<input type="hidden" name="action"
value="delete_product" />
<input type="hidden" name="productCode"
value="<?php echo $product['productCode']; ?>" />
<input type="submit" value="Delete" />
</form></td>
</tr>
<?php endforeach; ?>
</table>
<p>Add Product</p>
</br>
</div>
</div>
<?php include '../view/footer.php'; ?>
May not be the issue, but I don't see a closing anywhere for the:
<a href="?action=view_product&product_id=<?php echo $product['productCode']; ?>
You don't have any closing </a> tag and nothing between the opening <a> tag and where the closing tag should be. Here is the problem:
<td> <a href="?action=view_product&product_id=<?php echo $product['productCode']; ?>"></td>
This should be something like:
<td><?php echo $product['productCode']; ?></td>
you are missing the closing tag for your anchor. It should be:
<td> <?php echo $product['productCode']; ?></td>
How do I create a jQuery hover to show a div when the mouse is over like twitter repla retweet and favorite?
Here is my HTML:
<div style="display:none;" id="blab">
<?php echo $blab_id; ?>
</div>
<a href="blab.php?id=<?php echo $blab_id; ?>">
<div class="blab_body" id="hover" value="Hide">
<table>
<tr>
<td valign="top">
<img src="<?php echo $profile_pic_info; ?>" class="blab_image" width="50" height="50" />
</td>
<td> </td>
<td>
<table>
<tr>
<td valign="top">
<a href="profile.php?id=$mem_id">
<strong><?php echo $added_fullname; ?></strong>
</a>
<?php echo $added_to_fullname; ?>
</td>
</tr>
<tr>
<td>
<?php echo $blab_body; ?>
</td>
</tr>
<tr>
<td>
<text style="color:gray;">
<?php echo $blab_date; ?>|<?php echo $device; ?>
</text>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div style="background:#000; display:none;" id="id"> </div>
</div>
</a>
<hr />
and here is my JavaScript code:
$('#id').hide();
$('#hover').hover(function () {
var blab_id = $('#blab').text();
$('#id').show();
}, function () {
$('#id').hide();
});
It shows the div for the first one only.
You can only use a certain ID once on the whole page! If you insert more than one copy of this div on the page, your HTML code becomes invalid. That's why jQuery only attaches the event handler to the first element.
The solution is to use class="hover_enabled" instead of id="hover" as it is allowed to add the same class to multiple elements. Here is how you would do it in jQuery:
$('.hover_enabled').hover(function() { ...
The same thing applies to #id.