how to prompt search query into a dynamic iframe - php

hi there i am creating a data grid which loads data from the database and i had even created a search box which prompts the search queries when a user inputs a value into it but now i want to show my search query into the same iframe which is loading the file of data table and when the search box is empty it should show the data table and if a user enters a query it should load the query into it here is my script
<div style="float: right; border: 1px; padding-right: 20px;">
<div class="search">
<input type="text" name="s" maxlength="64" placeholder="Search" id="inputString" onkeyup="lookup(this.value);" />
<img src="images/srch.png" id="srch_btn"/>
</div>
</div>
</div>
</div>
</div>
<table border="0" width="100%" class="myclass" height="30px">
<tr>
<td width="80px" align="center"><font color="black" size="3px">Sr No.</font></td>
<td width="80px" align="center"><font color="black" size="3px">Br No.</font></td>
<td width="180px" align="center"><font color="black" size="3px">Name</font></td>
<td width="200px" align="center"><font color="black" size="3px">Address</font></td>
<td width="120px" align="center"><font color="black" size="3px">City</font></td>
<td width="80px" align="center"><font color="black" size="3px">Pin</font></td>
<td width="80px" align="center"><font color="black" size="3px">Mobile</font></td>
<td width="120px" align="center"><font color="black" size="3px">Email</font></td>
<td width="80px" class="myclass" align="center"><font color="black" size="3px">Actions</font></td>
</tr>
</table>
<div id="suggestions">/****file that shows the search queries**/
<iframe src="record.php" width="1150" height="900" frameBorder="0"></iframe> /** File that loads the data table**/
</div>
here is my search script
$db = new mysqli('localhost', 'root', '', 'mdb');
if(!$db) {
// Show error if we cannot connect.
echo 'ERROR: Could not connect to the database.';
} else {
// Is there a posted query string?
if(isset($_POST['queryString'])) {
$queryString = $db->real_escape_string($_POST['queryString']);
if(strlen($queryString) >0) {
$query = $db->query("SELECT * FROM mdb WHERE (`name` LIKE '%" . $queryString . "%') OR (grno LIKE '%". $queryString ."%')
OR (`address` LIKE '%". $queryString ."%') OR (`city` LIKE '%". $queryString ."%') OR (pin LIKE '%". $queryString ."%')
OR (mobile LIKE '%". $queryString ."%') OR (`email` LIKE'%". $queryString ."%') ORDER BY vouchno LIMIT 8");
if($query) {
echo "<table width='100%'>";
echo "<tr>";
echo "<th align=left>Name</th>";
echo "<th align=left>Address</th>";
echo "<th align=left>City</th>";
echo "<th align=left>Pin</th>";
echo "<th align=right>Mobile</th>";
echo "<th align=left>Email</th>";
echo "</tr>";
while ($result = $query ->fetch_object()) {
echo "<tr>";
echo "<td><span class=\"category\">$result->name</span></td>";
echo "<td>$result->address</td>";
echo "<td>$result->city</td>";
echo "<td>$result->pin</td>";
echo "<td align=right>$result->mobile</td>";
echo "<td>$result->email</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=9>";
echo "<hr/>";
echo "</td>";
echo "<tr>";
$name = $result->name;
if(strlen($name) > 35) {
$name = substr($name, 0, 35) . "...";
}
$description = $result->address;
if(strlen($description) > 80) {
$description = substr($description, 0, 80) . "...";
}
}
echo "</table>";
echo '<span class="seperator"><strong>No Further Records Found</strong> </span><br class="break" />';
} else {
echo 'ERROR: There was a problem with the query.';
}
} else {
echo "record.php";
}
} else {
echo 'There should be no direct access to this script!';
}
}

I think now AJAX can help you I mean. why you don't do somthing like this instead of iframe?
check this
$('#div').load('someFile.php','params');
and for scrolling the div use this in CSS
CSS
#div{
width:500px;
height:300px;
overflow:scroll;
}
here the jsfiddle.

Related

Submit Buttons in while loop

my problem may be easy for experienced users, but I'm stucked on it. So, here's the problem. I have submit buttons in while loop, they draw, but they don't react on click. Here's my piece of code.
`<?php
$zap_cmember = count_query("SELECT * FROM `users` WHERE `clan` = '".$member['id']."' AND clan_stat != 'Призывник'");
while ($cmember = mysql_fetch_array($zap_cmember))
{
$zap_gold = mysql_result(mysql_query("SELECT SUM(gold) FROM klog WHERE name = '".$cmember['name']."'"), 0);
$zap_online = mysql_num_rows(count_query("SELECT * FROM `online` WHERE `id_session`='".$cmember['id_user']."'"));
if ($zap_online > 0)
{
$img_on = "<td align='center' valign='middle' ><img src='images/ico_online.png' alt='онлайн' class='png' ></td>";
}
else
{
$img_on = "<td align='center' valign='middle' ><img src='images/ico_offline.png' alt='оффлайн' class='png' ></td>";
}
$i = 'set';
echo '<tr>
<td width="141" height="25" align="left" valign="middle" >'.$cmember['name'].' ['.lvl($cmember['exp']).']</td>
<td align="center" valign="middle" ><span class="text_main_4">'.$cmember['clan_stat'].'</span></td>
<td align="center" valign="middle" ><span class="text_main_4">-</span></td>
<td align="center" valign="middle" ><span class="text_main_4">'.$zap_gold.'</span></td>
<td align="center" valign="middle" ><span class="text_main_4">'.$cmember['glory'].'</span></td>
'.$img_on.'';
if($boss)
{echo '<td align="center" id = "'.$i.'" valign="middle"><input type="submit" name="bSet" value="Назначить"></span></td>'; }
$i++;
$player = $cmember;
'</tr>';
if (isset($_POST['bSet']))
{
echo 'works';
count_query("UPDATE users SET clan_stat='Вождь' WHERE id_user='".$player['id_user']."'");
$time = date('j.n.y H:i');
count_query("INSERT INTO `message` (`time`, `to`, `text`, `metka`) VALUES ('".$time."', '".$player['name']."', 'Вас выбрали главой клана <a href=clan.php>".$clan['name']."</a>', '6')");
echo "<script>location.href='clan.php'</script>";
}
}
?>
`
You need to put everything that you want to submit to a <form id="yid">... </form>, after that to put on the button the onclick="javascript:$('#yid').submit()" and the yid= the particular id of the form you want the button to submit.

MYSQL Select query for displaying data on a table is not working

I want to display the data loaded from database after it is inserted using the function add_data() but it's not displaying the data on the table.
if(isset($_POST['btn_add_details'])) {
add_data();
include("db_PSIS.php");
$sql2="SELECT * FROM sample_barcode WHERE IDRec='".$row['IDRec']."'";
$result2=mysql_query($sql2);
if(!$result2) {
echo "<h1>Could not process query this time. Please try again later!</h1>";
}
else {
while($row2=mysql_fetch_array($result2)) {
echo "<form name='form2' method='POST'>";
echo "<table class='output' border=2 align=center>";
echo "<tr class='thcolor'>";
echo "<th>Parent</th>";
echo "<th>LOT Traveller No.</th>";
echo "<th>Datecode</th>";
echo "</tr>";
echo "<tr>";
echo "<td>".$row2['LotTraveller']."</td>";
echo "<td>".$row2['LotTraveller']."</td>";
echo "<td>".$row2['Datecode']."</td>";
echo "</tr>";
echo "</table>";
echo "</form>";
}
echo "<br><h1>Data successfully loaded!</h1>";
}
mysql_close($link);
}
?>
Here's the function for adding data on the database:
function add_data() {
include("db_PSIS.php");
$sql="INSERT INTO sample_barcode (LotTraveller, ShipmentLotNumber) VALUES ('".$_POST['traveller']."', '".$_POST['datecode']."')";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
mysql_close($link);
}
Here's the code for database connection:
<?php
$username="****";
$password="****";
$database="****";
$hostname="****";
$link=#mysql_connect($hostname,$username,$password)
or die ("...cannot connect database, using $username for $hostname");
mysql_query("set names 'utf8'"); //指定数据库字符集
mysql_select_db($database,$link);
?>
Here's the form input:
<table width="500" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<tr>
<th align="right">Parent Traveller: </th>
<td><input type="text" name="traveller" size="20" value="<?php if(empty($_POST['traveller'])) {echo ''; } else { echo $row2['LotTraveller']; } ?>"/></td>
</tr>
<tr>
<th align="right">Date Code: </th>
<td><input type="text" name="datecode" size="20" value="<?php if(empty($_POST['traveller'])) {echo ''; } else { echo $row2['ShipmentLotNumber']; } ?>" /></td>
</tr>
<tr>
<th align="right">Traveller 1: </th>
<td><input type="text" name="traveller1" size="20" /></td>
</tr>
<tr>
<th align="right">Date Code: </th>
<td><input type="text" name="datecode1" size="20" /></td>
</tr>
<tr>
<th align="right">Traveller 2: </th>
<td><input type="text" name="traveller2" size="20" /></td>
</tr>
<tr>
<th align="right">Date Code: </th>
<td><input type="text" name="datecode2" size="20" /></td>
</tr>
<tr>
<th align="right"> </th>
<td><input type="hidden" name="id" size="20" value="<?php if(empty($_POST['traveller'])) {echo ''; } else {echo $row2['IDRec'];} ?>"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="btn_add_details" id="btn_add_details" onClick="return check_submit();" value="Add the Detail(s)" onfocus="setStyle(this.id)"
style="color: #000000;
padding: 2px 5px;
border: 2px solid;
border-color: #7bf #07c #07c #4AA02C;
background-color: #09f;
font-family: Georgia, ..., serif;
font-size: 18px;
display: block;
height: 30px;
width: 200px;" /> </td>
</tr>
</table>
Since you stated that IDRec is your PK and is set to auto-increment, AND you are pulling records based on a single number... you will never get more than one result in your resultset.
Change this code block...
$sql2="SELECT * FROM sample_barcode WHERE IDRec='".$row['IDRec']."'";
$result2=mysql_query($sql2);
if(!$result2) {
echo "<h1>Could not process query this time. Please try again later!</h1>";
}
else {
while($row2=mysql_fetch_array($result2)) {
echo "<form name='form2' method='POST'>";
echo "<table class='output' border=2 align=center>";
echo "<tr class='thcolor'>";
echo "<th>Parent</th>";
echo "<th>LOT Traveller No.</th>";
echo "<th>Datecode</th>";
echo "</tr>";
echo "<tr>";
echo "<td>".$row2['LotTraveller']."</td>";
echo "<td>".$row2['LotTraveller']."</td>";
echo "<td>".$row2['Datecode']."</td>";
echo "</tr>";
echo "</table>";
echo "</form>";
}
echo "<br><h1>Data successfully loaded!</h1>";
}
mysql_close($link);
}
To this...
$sql2="SELECT * FROM sample_barcode WHERE IDRec=".$row['IDRec']."";
$result2=mysql_query($sql2);
$row2=mysql_fetch_assoc($result2); // added this line
if(!$result2) {
echo "<h1>Could not process query this time. Please try again later!</h1>";
}
else {
echo "<form name='form2' method='POST'>";
echo "<table class='output' border=2 align=center>";
echo "<tr class='thcolor'>";
echo "<th>Parent</th>";
echo "<th>LOT Traveller No.</th>";
echo "<th>Datecode</th>";
echo "</tr>";
echo "<tr>";
echo "<td>".$row2['LotTraveller']."</td>";
echo "<td>".$row2['LotTraveller']."</td>";
echo "<td>".$row2['Datecode']."</td>";
echo "</tr>";
echo "</table>";
echo "</form>";
echo "<br><h1>Data successfully loaded!</h1>";
}
mysql_close($link);
}
In the first line I removed the single quotes around your IDRec - this is an integer so single quotes are not needed.
Removed your while loop - you will only ever get one result so a loop is not needed.
Also, this doesn't appear to actually be a form so you can also remove your <form> </form> tags.
Finally, start learning pdo_mysql. my_sql has been deprecated. Anyone still using this code will wake up one day to find out that their website has magically stopped functioning.
EDIT
In your add_data function, change it to this...
function add_data() {
include("db_PSIS.php");
$sql="INSERT INTO sample_barcode (LotTraveller, ShipmentLotNumber) VALUES ('".$_POST['traveller']."', '".$_POST['datecode']."')";
$result=mysql_query($sql);
$sql="SELECT * FROM sample_barcode ORDER BY IDRec DESC"; // added this line
$result=mysql_query($sql); // added this line
$row=mysql_fetch_assoc($result); // changed this line from array to assoc
mysql_close($link);
}
This will get the result of the data you just entered. I added a query to get the data you need to display.

How do I hardcode a dynamic url to an image map?

I am working on a Zip Code search, and have successfully built the search. Now, I need to have the ability to click on an image map of a map, and hardcode an href to a dynamic URL
So for example, the search works well displaying contact information for a zip code in PA. But if I have an image map, I'd like the ability for it to display the same contact information if I click the image map of PA on the map image.
Here is the code I'm using to do the search, and at the bottom is the code I need help with for the image map.
<form action="search6.php" method="post">
<p><span class="orange16">Zip Code:</span>
<input type="text" name="search_name"> <input type="submit" value="Search" />
</p>
</form>
<br />
<table width="700" border="0">
<?php
if (isset($_POST['search_name'])) {
$search_name = $_POST['search_name'];
if (!empty($search_name)) {
if (strlen($search_name)>=5) {
$query = "SELECT * FROM `search4` WHERE `ZipCode` LIKE '%".mysql_real_escape_string($search_name)."%'";
$query_run = mysql_query($query);
if (mysql_num_rows($query_run)>=1) {
echo "<table width=700' border='0'>";
echo "<tr>";
echo "<td width='700' valign='top'><table width='100%' border='0'>";
echo "<tr>";
echo "<td><p><strong>Results found: </strong></p>";
while ($query_row = mysql_fetch_assoc($query_run)) {{
echo $query_row['ZipCode'].', ';
echo $query_row['ZipCity'].', ';
echo $query_row['ZipState'].'<br><br>';
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo '<span class="productdescription"><p>Office: </p></span></h2>';
echo $query_row['Office'].'<br>';
echo $query_row['Address1'].'<br>';
if(!empty($query_row['Address2'])) // This will skip if the field if it's empty
echo $query_row['Address2'].'<br>';
echo $query_row['City'].', ';
echo $query_row['State'].' ';
echo $query_row['Zip'].'<br>';
echo '<p><strong>Phone Number: </strong></p>';
echo $query_row['Phone'].'<br>';
echo '<p><strong>Fax Number: </strong></p>';
echo $query_row['Fax'].'<br><br>';
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
//BeginImage display result
$res=mysql_query("select * from Images");
{
echo "<td width='703' align='right' valign='top'>";?> <img src="<?php echo $query_row["Image"]; ?>"> <?php echo "</td>";
echo "</tr>";
}
//EndImage display result
echo ("<table width='700px' border='0' cellpadding='5' cellspacing='1'>
<tr>
<td width='13%' align='left' bgcolor='#C1DDF4'><p><strong>Service Type:</strong></p></td>
<td width='13%' align='left' bgcolor='#C1DDF4'><p><strong>Name:</strong></p></td>
<td width='13%' align='left' bgcolor='#C1DDF4'><p><strong>Phone:</strong></p></td>
<td width='13%' align='left' bgcolor='#C1DDF4'><p><strong>Email:</strong></p></td>
</tr>");
echo ("
<td align='left'><p><strong>Sales</strong></p></td>
<td align='left'><p>$query_row[SalesName]</p></td>
<td align='left'><p>$query_row[SalesPhone]</p></td>
<td align='left'><p><a href='mailto:$query_row[SalesEmail]'class='admin_links'>$query_row[SalesEmail]</p></a></td>
</tr>");
echo ("
<td align='left'><p><strong>Service</strong></p></td>
<td align='left'><p>$query_row[ServiceName]</p></td>
<td align='left'><p>$query_row[ServicePhone]</p></td>
<td align='left'><p><a href='mailto:$query_row[ServiceEmail]'class='admin_links'>$query_row[ServiceEmail]</p></a></td>
</tr>");
echo ("
<td align='left'><p><strong>Service Coordinator</strong></p></td>
<td align='left'><p>$query_row[ServiceCoorName]</p></td>
<td align='left'><p>$query_row[ServiceCoorPhone]</p></td>
<td align='left'><p><a href='mailto:$query_row[ServiceCoorEmail]'class='admin_links'>$query_row[ServiceCoorEmail]</p></a></td>
</tr>");
echo ("</table>");
}
}
}else{
echo 'No results found.';
}
}else{
echo 'Your search must be a 5-digit zip code.';
}
}
}
?>
</table>
This is the code for the Image map I need help with. I'd like to use the "CustClassID" data row for my value of lets say "23-LA".
<?php
$query = "SELECT * FROM search4 WHERE CustClassID = {$_GET['CustClassID']}";
echo ("<table width='600' border='0'>
<tr>
<td align='center'> <img src='images/greymap.png' border='0' usemap='#Map' />
<map name='Map' id='Map'>
<area shape='rect' coords='42,21,136,98' href='search6.php?CustClassID=23-LA' />
</map></td>
</tr>
</table>
");
?>
Basically, is there another way to get the same results as the search, by clicking on specific areas on the imagemap? Please point me in right direction.

Display query without character input

I'm having problems with a "google like" search engine .
When the page loads, it expects a character in the input box to display inside a div the results.
What can I do to display all the database contents without typing any character in the input box?
Below are the three files:
Index.html
<html>
<head>
<title></title>
</head>
<body>
Caută analizele în baza noastră de date.<br>Taxa de urgență este de 35 Ron
<p align ="right">
<input type="text" id="go" class="field" name="go" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Caută analiza dorită':this.value;" value="Caută analiza dorită"/>
<input type="submit" name="search" id="submit" value="Cauta" /><br/>
<div id="search_query"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/instant.js"></script>
</p>
</body>
</html>
Search.php
<?php
$conn = mysql_connect("localhost","user","pass");
mysql_select_db("db");
mysql_set_charset("UTF8", $conn);
if(isset($_POST['search_query'])){
$search_query = mysql_real_escape_string(htmlentities($_POST['search_query']));
$search_query_x = explode(",",$search_query);
foreach($search_query_x as $search_each){
#$x++;
if($x==1)
#$construct.="Den LIKE '%$search_each%'";
else
$construct.="AND Den LIKE '%s$search_each%'";
}
$construct ="SELECT * FROM biochimie1 WHERE $construct";
$run = mysql_query($construct) or die(mysql_error());
$foundnum = mysql_num_rows($run);
// Define $color=1
$color="1";
if ($foundnum==0){
echo "Ne pare rau dar nu există rezultate pentru <strong><font color='red'>$search_query</font></strong></br></br> Vă rugăm să verificați dacă ați scris corect";
}
else{
echo'<p align="center">';
echo "$foundnum \n";
echo ' rezultate găsite în urma căutării!</p>';
echo "<table id='table1' border='0'width='500'>
<tr>
<th width='150' align='center' valign='middle'>Denumire Analize</th>
<th width='50' align='center' valign='middle'>Preț</th>
<th width='100' align='center' valign='middle'>Zile de recoltare</th>
<th width='100' align='center' valign='middle'>Termen de eliberare a rezultatelor</th>
<th width='100' align='center' valign='middle'>Se poate lucra în regim de urgență</th>
</tr></table>";
while($runrows = mysql_fetch_assoc($run))
{
$NrCrt = $runrows ['NrCrt'];
$denanalize = $runrows ['Den'];
$pret = $runrows ['Pret'];
$rec = $runrows ['Rec'];
$rez = $runrows ['Rez'];
$obs = $runrows ['Obs'];
echo "<table border='0'>";
// If $color==1 table row color = #FFC600
if($color==1){
echo "
<tr bgcolor='#efefef'>
<td width='150' align='center' valign='middle'>$denanalize</td>
<td width='50' align='center' valign='middle'>$pret</td>
<td width='100' align='center' valign='middle'>$rec</td>
<td width='100' align='center' valign='middle'>$rez</td>
<td width='100' align='center' valign='middle'>$obs</td>
</tr>
</table>";
// Set $color==2, for switching to other color
$color="2";
}
// When $color not equal 1, use this table row color
else {
echo "<tr bgcolor='#eaeaea'>
<td width='150' align='center' valign='middle'>$denanalize</td>
<td width='50' align='center' valign='middle'>$pret</td>
<td width='100' align='center' valign='middle'>$rec</td>
<td width='100' align='center' valign='middle'>$rez</td>
<td width='100' align='center' valign='middle'>$obs</td>
</tr>";
// Set $color back to 1
$color="1";
}echo "
</table>";
}
}
}
else{
echo 'An ERROR has occured';
}
?>
and instant.js file
$('#go').keyup(function(){
var search_query=$(this).val();
$.post('search.php', {search_query: search_query},function(searchq){
$('#search_query').html(searchq);
});
});
Thank you all in advance.
It will work on load:
$(document).ready(function(){
var search_query=$(this).val();
$.post('search.php', {search_query: search_query},function(searchq){
$('#search_query').html(searchq);
});

member management by admin using php

Sorry for asking an implement my feature question type question last time. I am new to Stackoverflow.com and also to php that's why.
What I was trying to ask is:
I have made a admin account. Members have registration page so a member will register. When user registers in the database table I will have a field for which 0 value will be initialised which means he is not approved. In admin account I have code to get the list of members. The code is given below:
<h2><?php echo "User list"; ?></h2>
<table border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#f87820">
<td><img src="img/blank.gif" alt="" width="10" height="25"></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo "first name"; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo "lastname name"; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo "member id"; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="50" height="6"><br><b><?php echo "delete"; ?></b></td>
<td><img src="img/blank.gif" alt="" width="10" height="25"></td>
</tr>
<?php
}
$result=mysql_query("SELECT member_id,firstname,lastname,login FROM members ORDER BY firstname");
$i = 0;
while($row = mysql_fetch_array($result)) {
if ($i > 0) {
echo "<tr valign='bottom'>";
echo "<td bgcolor='#ffffff' height='1' style='background-image:url(img/strichel.gif)' colspan='6'></td>";
echo "</tr>";
}
echo "<tr valign='middle'>";
echo "<td class='tabval'><img src='img/blank.gif' alt='' width='10' height='20'></td>";
echo "<td class='tabval'><b>".$row['lastname']."</b></td>";
echo "<td class='tabval'>".$row['firstname']." </td>";
echo "<td class='tabval'>".$row['member_id']." </td>";
echo "<td class='tabval'><a onclick=\"return </span></a></td>";
echo "<td class='tabval'></td>";
echo "</tr>";
$i++;
}
?>
</table>
in this i wanna add tho more things in the table 1 to delete a member and 2 to have approved or denied option for that i made two functiom
below code is to delete
if($_REQUEST['action']=="del")
{
$memberId = mysql_real_Escape_string($_REQUEST['member_id']);
mysql_query("DELETE FROM members WHERE member_id=$memberId");
}
below one for approving members
But my problem is I don't know how to include a button or radio button in the table which can pass value delete or approve to these functions.
Please tell me how the syntax is to add this button so that for approving I can change the value 0 that I gave in the database to 1 so that member get approved.
Try this:
echo '<td><a href="http://yourwebsite/yourscriptname.php?action=del&member_id='
. htmlspecialchars($row['member_id']) . '">Delete</a>';
if ($row['approved'] == 0) {
echo ' <a href="http://yourwebsite/yourscriptname.php?action=approve&member_id='
. htmlspecialchars($row['member_id']) . '">Approve</a>';
}
echo '</td>';
And make sure ALL of your database values are being sent to the browser in htmlspecialchars().
On the flipside,
$member_id = 0;
if (isset($_GET['member_id'])) $member_id = intval($_GET['member_id']);
$action = '';
if (isset($_GET['action'])) $action = $_GET['action'];
$sql = '';
switch($action) {
case 'approve':
$sql = "UPDATE members SET approval = 1 WHERE member_id = $member_id";
break;
case 'delete':
$sql = "DELETE FROM member WHERE member_id = $member_id";
break;
}
if (!empty($sql) && !empty($member_id)) {
// execute the sql.
}
What I would do is to set up a form inside of the table.
?> <form name="deleteUser" id="deleteUser" method="post" action="">
<input type="hidden" name="member_id" id="member_id" value="<?php echo $row['member_id'] ?>
<input type="submit" name="action" id="action" value="del" />
</form><?php
I would insert that in between your <td> tag.
<td class='tabval'>INSERT HERE</td>";

Categories