Jump to content

just put class name and function


mrjameer

Recommended Posts

hi

i have a script for displaying the records from mysql table along with checkboxes to delete the multiple records from table.what i want is i want to put the code inside one class and one function.that's all.but when i put the code in class & function the record is not deleting but when i remove the class & function the record is deleting.any of your help will be appreciated.
here is my code
view.html.php
[code=php:0]
<?php
//class viewclients_html
//{
//function viewclients()
//{
include 'db.php';
mysql_connect($host,$username,$password);
mysql_select_db($db) or die("Unable to select database");

$sql="SELECT * FROM host ORDER BY date DESC";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

?>
<center><table width="700" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><font color="navy"><form name="form1" method="post" action=""><br><center><b>
<u><font color="magenta">CLIENTS</font></u></b></center><br><br>
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>

<td bgcolor="lightgreen" align="center"><font color="navy">#</font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>Id</strong></font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>Name</strong></font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>Email</strong></font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>Phone</strong></font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>Country</strong></font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>City</strong></font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>Message</strong></font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>Date</strong></font></td>

</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<font color="navy">
<tr  class="odd" onmouseover="over(this);" onmouseout="out(this);">
<td align="center"><font color="navy"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></font></td>
<td><font color="navy"><? echo $rows['id']; ?></font></td>


<td><font color="navy"><? echo $rows['name']; ?></font></td>
<td><font color="navy"><? echo $rows['email']; ?></font></td>
<td><font color="navy"><? echo $rows['phone']; ?></font></td>
<td><font color="navy"><? echo $rows['country']; ?></font></td>
<td><font color="navy"><? echo $rows['city']; ?></font></td>
<td><font color="navy"><? echo $rows['message']; ?></font></td>
<td><font color="navy"><? echo $rows['date']; ?></font></td>
</tr></font>
<?php
}
?>
<tr>
<td colspan="5" align="center" ><input name="delete" type="submit" id="delete" value="Delete"></font></td>
</tr></table></center>
<?
// Check if delete button active, start this
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM host WHERE id='$del_id'";
$result = mysql_query($sql);
}

// if successful redirect to checkdelete1.php
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=viewclients.php\">";
}
}
mysql_close();
//}} class & function close
?>
</table>
</form>
</font></td>
</tr>
</table></center>
<style type="text/css">
<!--
tr.odd{background-color:white;}
tr.even{background-color:red;}
-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
function over(row)
{
    row.oldBackgroundColor = row.style.backgroundColor;
    row.style.backgroundColor = 'pink';
}
function out(row)
{
    row.style.backgroundColor = row.oldBackgroundColor;
}
//-->
</script>

[/code]
iam accessing the function in another script as follows
view.php
<?php
require_once( $mainframe->getPath( 'front_html' ) );

viewclients_HTML::viewclients();
?>
Link to comment
https://forums.phpfreaks.com/topic/35408-just-put-class-name-and-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.