homepage Welcome to WebmasterWorld Guest from 54.242.200.172
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Need code help in creating filters using Mysql DB data : urgent
nani nisha06




msg:4496162
 8:08 am on Sep 17, 2012 (gmt 0)

HI Friends,

I am planning to creat a multiple filters like.

by date,
by row,
by field


Initially I have started writing a code to execute Mysql command using PHP but as I am starter with PHP and still need to learn lot this pls help on below code.

<?php session_start(); ?>
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name=""; // Table name
$pagelimit = 10;
$offset = @$_POST['cPage']?@(($_POST['cPage']-1)*$pagelimit):0 ;
// Connect to server and select databse.
require_once('classes/tc_pageNav.php'); //include pageNav class
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$date=$_POST['from:'];
$date=$_POST['to:'];
$data = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM $tbl_name where Outage Start Time:='$date' and Outage Start Time:='$date2' LIMIT $offset, $pagelimit ")
or die(mysql_error());
$res = mysql_fetch_array(mysql_query("select FOUND_ROWS()"));
$totalRecords = $res[0];
$page_nav = new tc_pageNav($totalRecords);
$page_nav->setPerPage($pagelimit);

$page_nav->calculate();

?>
<div id="templatemo_main" color="#2EFEF7">
<table border= "3">
<tr>
<th>S NO:</th>
<td>Client Name:</td>
<td>WC Incident ID:</td>
<td>O2 Incident ID:</td>
<td>Supplier Name:</td>
<td>Vendor Incident ID:</td>
<td>Priorities:</td>
<td>Incident Title:</td>
<td>Incident Description:</td>
<td>Identified Party:</td>
<td>Month:</td>
<td>Outage Start Time:</td>
<td>Outage End Time:</td>
<td>Time the issue notified :</td>
<td>Time notification was sent:</td>
<td>Root Cause:</td>
<td>Resolution:</td>
<td>Status:</td>
<td>SLA Status:</td>
<td>Communication With in SLA:</td>
<td>Service Impacted:</td>
<td>Vendor Name:</td>
<td>Root Cause Type:</td>
<td>Change Related:</td>
<td>Change Number:</td>
<td>User Name:</td>
</tr>
</color>
</div> <!-- end of main -->
<?php
while($info = mysql_fetch_array( $data ))
{ ?>
<tr>
<td><?=$info['S NO:']?></td>
<td><?=$info['Client Name:']?></td>
<td><?=$info['WC Incident ID:']?></td>
<td><?=$info['O2 Incident ID:']?></td>
<td><?=$info['Supplier Name:']?></td>
<td><?=$info['Vendor Incident ID:']?></td>
<td><?=$info['Priorities:']?></td>
<td><?=$info['Incident Title:']?></td>
<td><?=$info['Incident Description:']?></td>
<td><?=$info['Identified Party:']?></td>
<td><?=$info['Month:']?></td>
<td><?=$info['Outage Start Time:']?></td>
<td><?=$info['Outage End Time:']?></td>
<td><?=$info['Time the issue notified :']?></td>
<td><?=$info['Time notification was sent:']?></td>
<td><?=$info['Root Cause:']?></td>
<td><?=$info['Resolution:']?></td>
<td><?=$info['Status:']?></td>
<td><?=$info['SLA Status:']?></td>
<td><?=$info['Communication With in SLA:']?></td>
<td><?=$info['Comments:']?></td>
<td><?=$info['Service Impacted:']?></td>
<td><?=$info['Root Cause Type:']?></td>
<td><?=$info['Change Related:']?></td>
<td><?=$info['Change Number:']?></td>
<td><?=$info['User Name:']?></td>
</tr>
<?php } ?>
<tr> <td colspan = '34'> <?php echo $page_nav->printNavJump(); ?><td></tr>

</table>

<?php
?>


Is this the right one pls help me ?

 

coopster




msg:4537764
 8:52 pm on Jan 20, 2013 (gmt 0)

>> multiple filters

You can filter as you demonstrated, in your WHERE clause of your query. However, AND THIS IS A BIG WARNING, never trust user-supplied input, including raw $_POST superglobals. You really should be checking your data for valid type and expected values and after that you should be using the "real_escape" features provided by your database API. More information can be found in the online PHP manual for Security as well as the MySQLi functions.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved