sorry for my code but this is only a practice code, i m trying to remove user access links, i displayed all the links that corresponds to the selected user access here's the code and database
Select user levels
<p class="left"><b>User Level Information</b></p><br>
<table class="left">
<tr>
<td id="TD3"><B>User Level ID</B></td>
<td id="TD3"><B>User Level Name</B></td>
</tr>
<?php
$employee = mysql_query("SELECT * FROM cms_userlevels ORDER BY `cms_userlevels`.`user_level` ASC ");
while($row1 = mysql_fetch_array($employee)){
?>
<tr>
<td id="TD3"><?php echo $row1['user_level']; ?></td>
<td id="TD3"><?php echo "<a href='manageuserlevels.php?id=".$row1['user_level']."'>"; ?> <?php echo $row1['user_type']; ?> </a></td>
</tr>
<?php } ?>
</table>
Selected User level
if(isset($_POST['Update']))
{
if(isset($_POST['delete']))
{
$delete1= mysql_query("DELETE FROM cms_userlevels where PROGRAM_ID = '$userId'");
header('location:manageuserlevel.php');
}
else
{
$update = mysql_query("UPDATE cms_program set
PROGRAM_TITLE='$_POST[progti]',
PROGRAM_DESCRIPTION='$_POST[progde]'
where
PROGRAM_ID='$userId'");
}
}
?>
<?php
$userId = $_GET['id'];
$sql = mysql_query("select * from cms_userlevels where user_level='$userId'");
$row2 = mysql_fetch_array($sql);
echo "
<center>
<table class='left'>
<form method='post' action='managemanageuserlevels.php?id=". $userId. "'>
<tr>
<td id='TD4'>User Level ID </td>
<td id='TD4'><input type='text' name='usertype' value='".$row2['user_type']."'></td>
</tr>
<tr>
<td colspan='2'><center><input type='submit' name='submit' value='Update'></td>
</tr>
</form>
</table>";
?>
<table class="left">
<tr>
<td>Remove Access:</td></tr>
<?php
$haslevel = mysql_query("select * from cms_userlevels, cms_level_page_matches, cms_pages
WHERE cms_userlevels.user_level = '$userId'
AND cms_level_page_matches.page_id = cms_pages.id");
while($getlevel = mysql_fetch_array($haslevel)){
$showhaslevel1 = $getlevel['id'];
$showhaslevel2 = $getlevel['page_title'];
?>
<tr><td>
<input type="checkbox" name="checkbox[]" value="<? echo $showhaslevel1; ?>"><?php echo $showhaslevel2; ?></td></tr>
<?php } ?>
the tables used
cms_userlevels
user_level user_type
1 Admin
2 Student
user_pages
id page name
1 page1.php
2 page2.php
user_level_page_matches
id user_level page_id
1 1 1
2 2 2
Related
<?php include("header.php"); ?>
<?php
if (#$_POST['delete']=="Delete"){
$count=count($_POST['delbx']);
for($i=0;$i<$count;$i++){
$delete = "DELETE FROM admin WHERE a_id='".$_POST['delbx'][$i]."'";
$resulty = mysqli_query($conn, $delete) or die(mysql_error());
$select_delete = "SELECT `a_image` FROM admin WHERE a_id='".$_POST['delbx'][$i]."'";
$resultrowdy = $conn->query($select_delete);
$rowdy = $resultrowdy->fetch_assoc();
$path="admin/".$rowdy['a_image'];
echo $path;
unlink($path);
echo '<script>window.location="view_user.php"</script>';
}
} ?>
<div class="table-responsive">
<table class="table">
<caption>All Users</caption>
<?php
$sql = "SELECT a_id, a_name, a_phone, a_password, a_role, a_mail, a_image FROM admin";
$result = $conn->query($sql);
if ($result->num_rows > 0) {?>
<thead>
<tr>
<th><form action="view_user.php" method="post"><input name="delete" type="submit" id="delete" value="Delete"></th><th>S. No.</th> <th>Name</th> <th>Phone No.</th> <th>Mail Id</th> <th>Role</th> <th>Password</th> <th>Image</th>
</tr>
</thead>
<?php
while($row = $result->fetch_assoc()) { ?>
<tbody>
<tr>
<th scope="row">
<?php echo $row["a_id"]; ?>
</th>
<td align="center" bgcolor="#FFFFFF">
<input name="delbx[]" type="checkbox" id="delbx[]" value="<?php echo $row["a_id"]; ?>" />
</td>
<td>
<?php echo $row["a_name"]; ?>
</td>
<td>
<?php echo $row["a_phone"]; ?>
</td>
<td>
<?php echo $row["a_mail"]; ?>
</td>
<td>
<?php echo $row["a_role"]; ?>
</td>
<td>
<?php echo $row["a_password"]; ?>
</td>
<td>
<img src="admin/<?php echo $row["a_image"]; ?>" width="60" height="40">
</td>
<th>
Edit
</th>
</tr>
</tbody>
<?php
}
} else {
echo "0 results";
}?>
</table>
</form>
</div>
<?php include("footer.php"); ?>
The code I mention is not deleting the multiple images from the source folder but deleting the multiple data from database whereas I am trying to delete images from the source folder along with data please help thanks in advance
One of the problem is you are deleting the row and trying to select image column from the deleted row.. dont use user supplied variables directly in your query
your code should be
for($i=0;$i<$count;$i++){
$select_delete = "SELECT `a_image` FROM admin WHERE a_id='".$_POST['delbx'][$i]."'";
$resultrowdy = $conn->query($select_delete);
$rowdy = $resultrowdy->fetch_assoc();
$delete = "DELETE FROM admin WHERE a_id='".$_POST['delbx'][$i]."'";
if(mysqli_query($conn, $delete)){
$path="admin/".$rowdy['a_image'];
unlink($path);
echo '<script>window.location="view_user.php"</script>';
}
}
Hi guys i currently have a address book that displays the information like this:
Extension Name Department Email Cellphone
1 jurgen home 1# 1
2 dawn work 2# 2
3 mike away 3# 33
Is there a way to display the information by Department? such as this: Where it shows the users under each department that they fall under, basically grouping them? be gentle :) im new to coding :D
Extension Name Email Cellphone
ALPINE DEALER PRINCIPAL
7813 Garth 123#alpinemotors.co.za 2
7898 Sam 3653#alpinemotors.co.za 4
AFTER-SALES DIRECTOR
7709 Bruce 6342#alpinemotors.co.za 3
Heres my code for the view.php page (on a side note i made a search bar but dont know how to code it to search the names field actively, so as they type in the search bar, the tables filter without having to press enter)
default:
$sql ="SELECT * FROM address ORDER BY name ASC";
$data = mysql_query($sql);
?>
<h2>Alpine VW Extension List</h2>
<table class="tableStyleClass">
<tr>
<th width="100">Extension</th>
<th width="100">Name</th>
<th width="200">Department</th>
<th width="200">Email</th>
<th width="200">Cellphone</th>
<th width="200" colspan="2">Admin</th>
</tr>
<td colspan="5" align="right"><?php if($disable!=1){?><div align="right <a href="<?=$_SERVER['PHP_SELF'];?>?mode=add"?mode=add>Add Contact</a><?php }else{?>Contact Book is Full<?php } ?></div></td>
<?php
$rowColor = 0;
while($info = mysql_fetch_array( $data )){
if($rowColor==0){
?>
<tr class="oddClassStyle">
<?php
$rowColor =1;
}elseif($rowColor==1){
?>
<tr class="evenClassStyle">
<?php
$rowColor = 0;
}
?>
<td><?=$info['Ext'];?></td>
<td><?=$info['name'];?></td>
<td><?=$info['department'];?></td>
<td><?=$info['email'];?></td>
<td><?=$info['phone'];?></td>
<td><a href="<?=$_SERVER['PHP_SELF'];?>?id=<?=$info['id'];?>&name=<?=$info['name'];?>&phone=<?=$info['phone'];?>&email=<?=$info['email']; >&mode=edit" >Edit </a></td>
<td>Remove</td>
</tr>
<?php
}
?>
</table>
<?php
break;
(THE ABOVE CODE WAS FIXED FROM ANSWERS BELOW)
Ok now that i have that sorted my edit button doesnt seem to work. it supposed to display the current info and then once edited, you click the edit button and it changes the information for that user.
Here is the code i was using previously:
case 'edit':
?>
<h2>Editing: <?=$_GET['name'];?></h2>
<form name="form1" action="<?=$_SERVER['PHP_SELF'];?>?mode=edited" method="post">
<table width="399" class="tableStyleClassTwo">
<tr><td width="87">Name:</td>
<td width="551"><div align="left">
<input type="text" value="<?=$_GET['name'];?>" name="name" />
</div></td></tr>
<tr><td>Phone:</td><td><div align="left">
<input type="text" value="<?=$_GET['phone'];?>" name="phone" />
</div></td></tr>
<tr><td>Email:</td><td><div align="left">
<input type="text" value="<?=$_GET['email'];?>" name="email" />
</div></td></tr>
<tr><td>Extension:</td><td><div align="left">
<input type="text" value="<?=$_GET['Ext'];?>" name="Ext" />
</div></td></tr>
<tr><td colspan="2" align="center">Back |<input name="Submit" type="submit" value="Save Changes" /></td></tr>
<input type="hidden" name="mode" value="edited">
<input type="hidden" name="id" value="<?=$_GET['id'];?>">
</table>
</form>
<?php
break;
case 'edited':
$name = $_POST['name'];
$phone = $_POST['phone'];
$department = $_POST['department'];
$email = $_POST['email'];
$Ext = $_POST ['Ext'];
$id = $_POST['id'];
$sql = "UPDATE address SET name = '" . $name ."', phone = '" . $phone . "', email = '" . $email . "', Ext = '" . $Ext . "' WHERE id = '" . $id . "'";
mysql_query($sql);
header('location: ' . $_SERVER['PHP_SELF']);
break;
Try this query -
$sql = "SELECT t1.Ext, t1.name, t1.email, t1.cellphone FROM address t1 join address t2 on t1.id=t2.id ORDER BY t2.department";
EDIT:
<?php
$sql = "SELECT t1.Ext, t1.name, t1.email, t1.cellphone FROM address t1 join address t2 on t1.id=t2.id ORDER BY t2.department";
$data = mysql_query($sql);
?>
<h2>Alpine VW Extension List</h2>
<table class="tableStyleClass">
<tr>
<th width="100">Extension</th>
<th width="100">Name</th>
<th width="200">Email</th>
<th width="200">Cellphone</th>
<th width="200" colspan="2">Admin</th>
</tr>
<td colspan="5" align="right"><?php if($disable!=1){?><div align="right <a href="<?=$_SERVER['PHP_SELF'];?>?mode=add"?mode=add>Add Contact</a><?php }else{?>Contact Book is Full<?php } ?></div></td>
<?php
$rowColor = 0;
$deptName = "";
while($info = mysql_fetch_array( $data )){
if($deptName === "" || $deptName != $info['department']) {
$deptName = $info['department'];
echo "<tr> <th colspan=6> $deptName </td> </th> </tr>\n";
}
if($rowColor==0){
?>
<tr class="oddClassStyle">
<?php
$rowColor =1;
}elseif($rowColor==1){
?>
<tr class="evenClassStyle">
<?php
$rowColor = 0;
}
?>
<td><?=$info['Ext'];?></td>
<td><?=$info['name'];?></td>
<td><?=$info['email'];?></td>
<td><?=$info['phone'];?></td>
<td><a href="<?=$_SERVER['PHP_SELF'];?>?id=<?=$info['id'];?>&name=<?=$info['name'];?>&phone=<?=$info['phone'];?>&email=<?=$info['email']; >&mode=edit" >Edit </a></td>
<td>Remove</td>
</tr>
<?php
}
?>
</table>
<?php
break;
?>
Here's another way:
$depts = [];
$res = mysql_query("SELECT * FROM address ORDER BY department, name");
// build the appropriate data structure that organizes contacts into different departments
// by looping through each contact, check if department exist (if not create the department) and add contact to the department
while ($row = mysql_fetch_assoc($res)) {
if (!isset($depts[$row['department']])) {
$depts[$row['department']] = [];
}
$depts[$row['department']][] = $row;
}
?>
<h2>Alpine VW Extension List</h2>
<table class="tableStyleClass">
<tr>
<th width="100">Extension</th>
<th width="100">Name</th>
<th width="200">Email</th>
<th width="200">Cellphone</th>
<th width="200" colspan="2">Admin</th>
</tr>
<tr>
<td colspan="6">
<?php if ($disable != 1) : ?>
Add Contact
<?php else : ?>
<span>Contact Book is Full</span>
<?php endif ?>
</td>
</tr>
<?php foreach ($depts as $dname => $contacts) : ?>
<tr>
<td colspan="6"><?= $dname ?></td>
</tr>
<?php foreach ($contacts as $contact) : ?>
<tr>
<td><?= $contact['ext'] ?></td>
<td><?= $contact['name'] ?></td>
<td><?= $contact['email'] ?></td>
<td><?= $contact['phone'] ?></td>
<td><a href="<?= $_SERVER['PHP_SELF'] ?>?id=<?= $contact['id'] ?>&mode=edit" >Edit </a></td>
<td>Remove</td>
</tr>
<?php endforeach ?>
<?php endforeach ?>
</table>
On another note, stop using mysql_* functions. There's a big red warning that says it is deprecated for good reasons. Use mysqli or better PDO instead!
And make better use of CSS (and use less attributes such as align="right"). You can use :nth-child selector (particularly with :even and :odd)to do your alternating styles for your table.
So, I have 3 tables in my database (phpMyAdmin) bikes, book and users. I have made bike_id and user_id a foreign key in the book table. Now I want these 2 to get inserted into the book table from the web page.
I've got 3 php files which are book1.php, book2.php and book3.php. In book1, you can select a bike which you want to book which results in showing that particular bike in new page. In book2, you select the date when you want to book and when you go to book3, the user_id and bike_id should be automatically inserted into the book table? But I only get ERROR when I press book in book2 page.
Can someone help me plz.. Below is the php codes for 3 php files.
book1.php:
<?php
require 'connect.php';
$select_posts = "select * from bikes ";
$run_posts = mysql_query($select_posts);
?>
<table cellpadding="2" cellspacing="2" border="2">
<tr>
<th>Name</th>
<th>Image</th>
<th>Available</th>
<th>Select Bike</th>
</tr>
<?php while($row=mysql_fetch_array($run_posts)){ ?>
<tr>
<td><?php echo $row[bike_name]; ?></td>
<?php echo "<td>";?> <img src="<?php echo $row[bike_image]; ?>" height="250" width="300"> <?php echo "</td>";?>
<td><?php echo $row[avail]; ?></td>
<td><a href="book2.php?id=<?php echo $row[bike_id];?>">Select</td>
</tr>
<?php } ?>
book2.php:
<?php
session_start();
?>
<?php
require 'connect.php';
if(isset($_GET['id'])){
$took_id = $_GET['id'];
$select_query = "select * from bikes where bike_id='$took_id'";
$run_query = mysql_query($select_query);
?>
<table cellpadding="2" cellspacing="2" border="2">
<tr>
<th>Name</th>
<th>Image</th>
<th>Available</th>
<th></th>
<th>Select Date</th>
<th>Book</th>
</tr>
<?php while($row=mysql_fetch_array($run_query)){ ?>
<tr>
<form action="book3.php" method="POST">
<td><?php echo $row[bike_name]; ?></td>
<?php echo "<td>";?> <img src="<?php echo $row[bike_image]; ?>" height="250" width="300"> <?php echo "</td>";?>
<td><?php echo $row[avail]; ?></td>
<td><?php echo $took_id; ?></td>
<td>Select Date: <input type="text" id="datepicker" name="datepicker"></td>
<td><input type="submit" name="Submit" value="Book"></td>
</tr>
<?php }} ?>
</table>
book3.php:
<?php
session_start();
?>
<?php
require 'connect.php';
// Get values from form
$datepicker = $_POST['datepicker'];
$sql="INSERT INTO $tbl_name(datepicker)VALUES('$datepicker')";
$sql="INSERT INTO $tbl_name(user_id)VALUES(select user_id from users)";
$sql="INSERT INTO $tbl_name(bike_id)VALUES(select bike_id from bikes)";
$result=mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";
}
else {
echo "ERROR";
}
?>
hod_view.php ## // the view of apply form from database
<?php
$sql= "SELECT * FROM form WHERE id='$formID'";
$result = mysql_query($sql) or die('Cannot get ID. ' . mysql_error());
$row=mysql_fetch_array($result);
$staffID=$row['staff_id'];
$sql2= "SELECT * FROM users WHERE staff_id='$staffID'";
$result2 = mysql_query($sql2);
$row2=mysql_fetch_array($result2);
?>
<form action="viewProcess.php?action=modifyView&id=<?php echo $row['id']?>" method="post" enctype="multipart/form-data" >
<h3 class="underlineLongest">USER APPLICATION FORM </h3>
<p align="right">Reference Number : <b> <?php echo $row['ref_no']; ?> </b> </p>
<table width='100%'>
<tr>
<td colspan='2' bgcolor="#C7C7C7"> Applicant Details</td>
</tr>
<tr>
<td width='30%'>Date of Application </td>
<td width='70%'> <textColor> <?php echo $row['app_date']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>User Full Name </td>
<td width='70%'> <textColor> <?php echo $row2['name']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>Designation/Staff ID </td>
<td width='70%'> <textColor> <?php echo $staffID; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>Department/Division </td>
<td width='70%'> <textColor> <?php echo $row2['department'].'/'.$row2['division']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>Telephone Ext. No </td>
<td width='70%'> <textColor> <?php echo $row2['ext']; ?> </textColor> </td>
</tr>
<tr>
<td colspan='2' bgcolor="#C7C7C7" > Application Service Required </td>
</tr>
<tr>
<td width='30%'>Type of Application </td>
<?php
$type= $row['type'];
$result4 = mysql_query(" SELECT * FROM type WHERE type_code='$type'");
$row4=mysql_fetch_array($result4); ?>
<td width='70%'> <textColor> <?php echo $type.' - '.$row4['description']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'> Type of Facility </td>
<td width='70%'>
<textColor> <?php
$facility=explode(';',$row['facility']);
foreach($facility as $i =>$key)
{
echo $key .' - ';
$result5 = mysql_query(" SELECT * FROM facility WHERE fac_code='$key'");
while($row5=mysql_fetch_array($result5))
{
echo $row5['description'].' <br> ';
}
} ?>
</textColor> </td>
</tr>
<tr>
<td colspan='2' bgcolor="#C7C7C7" > Endorsed Status (Head of Department) </td>
</tr>
<tr>
<td width='30%'>Endorsed By </td>
<td width='70%'> <textColor> <?php echo $row['endorsed_by']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>Status </td>
<td class="alt3">
<input name="radiobutton1" type="radio" value="APPROVED" checked >Approve
<input name="radiobutton2" type="radio" value="REJECTED" >Reject
</td>
</tr>
</tr>
<tr>
<td width='30%'>Date & Time </td>
<td width='70%'> <textColor> <?php echo $row['endorsed_time']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>Remarks </td>
<!--<td width='70%'><textarea name="endorsed_remark" id = "endorsed_remark"></textarea> </td> -->
<td><input type="text" name="endorsed_remark" id="endorsed_remark" /></td>
</tr>
</table>
<br><br>
<center><p><input class="btnSuccess" type ="submit" name="submit" value="Submit" onclick="modifyView();" >
<input class="btnEdit" type="button" name="btnCancel" value="Cancel" onclick="goBack()" > </p>
This hod_view.php is the view form that have been applied by the user. Then, the approver need to approve this form by updating the endorsed_status and endorsed_remark into the database.
Unfortunately, the form is not updated in the database.
viewProcess.php ## // the update query to database
<?php
include 'includes/initial.php';
$action = isset($_GET['action']) ? $_GET['action'] : '';
switch ($action)
{
case 'modifyView' :
break;
default :
header('Location: index.php');
}
function modifyView()
{
if(isset($_GET['id']) && $_GET['id'] > 0)
{
$formID = $_GET['id'];
}
else
{ // redirect to index.php if id is not present
header('Location: index.php');
}
echo $formID;
$sql = "UPDATE form SET endorsed_status='{$_POST['radiobutton1']}',endorsed_remark='{$_POST['endorsed_remark']}' WHERE id='$id'";
$result = mysql_query($sql) or die('Cannot update. ' . mysql_error());
if ($_POST['radiobutton2']=='REJECTED')
{
$sql = "UPDATE form SET endorsed_status='{$_POST['radiobutton2']}',endorsed_remark='{$_POST['endorsed_remark']}' WHERE id={$id} ";
$result = mysql_query($sql) or die('Cannot update. ' . mysql_error());
}
}
**This viewProcess.php is the sql query (update). Can you guys help me to make this coding correct?
Try this.
<?php
include 'includes/initial.php';
$action = isset($_POST['action']) ? $_POST['action'] : '';
switch ($action)
{
case 'modifyView' :
break;
default :
header('Location: index.php');
}
function modifyView()
{
if(isset($_POST['id']) && $_POST['id'] > 0)
{
$formID = $_POST['id'];
}
else
{ // redirect to index.php if id is not present
header('Location: index.php');
}
echo $formID;
$sql = "UPDATE form SET endorsed_status='{$_POST['radiobutton1']}',endorsed_remark='{$_POST['endorsed_remark']}' WHERE id='$id'";
$result = mysql_query($sql) or die('Cannot update. ' . mysql_error());
if ($_POST['radiobutton2']=='REJECTED')
{
$sql = "UPDATE form SET endorsed_status='{$_POST['radiobutton2']}',endorsed_remark='{$_POST['endorsed_remark']}' WHERE id={$id} ";
$result = mysql_query($sql) or die('Cannot update. ' . mysql_error());
}
}
i'm facing problem in getting the apprpriate values for some cells ....In the first page i'm getting the appropriate result..but in the next pages the values for product information,total price and profit from order all have value 0 but all the other fields are containing correct information.
Five records are shown per page.. The code is given below:
<?include"dbconnect.php"?>
session_start();
?>
<?include "adminhead.php"?>
<?include "adminleftnav.php"?>
<div id="seasonal">
<table width="635" border="0" align="left" bgcolor="#CCCCCC" >
<tr>
<td>
<table width="635" border="0" align="left" >
<tr>
<td width="52" bgcolor="#E0EBED">Order Number</td>
<td width="150" bgcolor="#E0EBED">Product Information</td>
<td width="100" bgcolor="#E0EBED">Total Price(TK)</td>
<td width="90" bgcolor="#E0EBED">Order Date</td>
<td width="80" bgcolor="#E0EBED">Payment Status</td>
<td width="100" bgcolor="#E0EBED">Profit from order(TK)</td>
</tr>
</table>
</td>
</tr>
<?php
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1)*5 ;
$sql = "Select distinct order_no,date,payment_status from product_order_info order by order_no ASC LIMIT $start_from,5";
$query_for_order1 = mysql_query ($sql);
?>
<tr>
<td>
<table id="foo" border="1" bgcolor="#f4eddb" cellspacing="2" cellborder="2" width=635>
<? while($row_for_my_order1=mysql_fetch_assoc($query_for_order1))
{
?>
<tr>
<td width=52>
<?echo $row_for_my_order1['order_no'];?>
</td>
<td width=156>
<?
$sql1 = "Select * from product_order_info where order_no= '$row_for_my_order1[order_no]' order by order_no ASC LIMIT $start_from,5";
$query_for_order = mysql_query($sql1);
while($row_for_my_order=mysql_fetch_assoc($query_for_order))
{
$query_for_product_details=mysql_query("select * from product where product_no='$row_for_my_order[product_id]' ");
$row_for_product_details=mysql_fetch_array($query_for_product_details);
?>
<br>
<?echo $row_for_product_details['product_name'];
?>
<br>
Quantity
<?echo $row_for_my_order['quantity'];
}
?>
</td>
<td width=106>
<?
$total=0;
$sql1 = "Select * from product_order_info where order_no= '$row_for_my_order1[order_no]' order by order_no ASC LIMIT $start_from,5";
$query_for_order = mysql_query($sql1);
while($row_for_my_order2=mysql_fetch_assoc($query_for_order))
{
$query_for_product_details=mysql_query("select * from product where product_no='$row_for_my_order2[product_id]' ");
$row_for_product_details=mysql_fetch_array($query_for_product_details);
$total = $total+ $row_for_product_details['sell_price'] * $row_for_my_order2['quantity'];
}
echo $total;
?>
</td>
<td width=90>
<?echo $row_for_my_order1['date'];?>
</td>
<td>
<?echo $row_for_my_order1['payment_status'];?>
</td>
<td width=100>
<? $total=0;
$sql1 = "Select * from product_order_info where order_no= '$row_for_my_order1[order_no]' order by order_no ASC LIMIT $start_from,5";
$query_for_order = mysql_query($sql1);
while($row_for_my_order3=mysql_fetch_assoc($query_for_order))
{
$total=$total+$row_for_my_order3['profit'];
}
echo $total; ?>
</td>
</tr>
<?
}
?>
</table>
</div>
<?php
$sql = "SELECT DISTINCT COUNT(order_no) FROM product_order_info";
$rs_result = mysql_query($sql);
$row = mysql_fetch_row($rs_result);
$total_records = $row[0];
$total_pages = ceil($total_records / 5);
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='view_order.php?page=".$i."'>".$i."</a> ";
};
?>
<?include "footer1.php"?>
Please help me in this regard...
You should delete LIMIT $start_from,5 from every query except the first one. As Dagon pointed out, you should consider the possibility to use a single query, to reduce the number of queries to the SQL server.