I need to place a button that says "Yes", but I need that when clicking on the button take the user to a web page, here is the php code for them to review:
<table cellpadding="1" cellspacing="1" id="member">
<thead>
<tr>
<th colspan="10">Players Not Activated</th>
</tr>
<tr>
<td class="on">#</td>
<td class="on">ID</td>
<td class="on">Username</td>
<td class="on">Email</td>
<td class="on">Tribe</td>
<td class="on">Activation Code</td>
<td class="on">Act 2??</td>
<td class="on">Time</td>
<td class="on">PLAY</td>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM ".TB_PREFIX."activate";
$result = mysqli_query($GLOBALS["link"], $sql);
while($row = mysqli_fetch_assoc($result))
{
$i++;
if($row['tribe'] == 1) {$tribe = "Roman"; }
elseif($row['tribe'] == 2) {$tribe = "Teuton"; }
elseif($row['tribe'] == 3) {$tribe = "Gaul"; }
echo "
<tr>
<td>".$i."</td>
<td>".$row['id']."</td>
<td>".$row['username']."</td>
<td>".$row['email']."</td>
<td>".$tribe."</td>
<td>".$row['act']."</td>
<td>".$row['act2']."</td>
<td class=\"hab\">".date('d:m:Y H:i', $row['timestamp'])."</td>
</tr>";
}
?>
</tbody>
</table>
I need the button to appear where it says "PLAY"
and the destination url i want is this link:
<a href="activate.php?id=<?php echo $_GET['id']; ?>
I have tried 4 days ago to be able to make it work but whenever I modify the file I receive a blank error page.
Related
<?php
require_once('../mysql_connect.php');
$query = "SELECT customerName
FROM customerName
WHERE membership = 0";
$result=mysqli_query($dbc,$query);
echo '<table width="75%" border="1" align="center" cellpadding="0"
cellspacing="0" bordercolor="#000000">
<tr>
<td width="10%"><div align="center"><b>CUSTOMER NAME
</div></b></td>
<td width="10%"><div align="center"><b>APPROVE
</div></b></td>
<td width="10%"><div align="center"><b>REJECT
</div></b></td>
</tr>';
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC)){
echo "<tr>
<td width=\"10%\"><div align=\"center\">{$row['customerName']}
</div></td>
<td width=\"10%\"><div align=\"center\"> /*this is supposed to show a button*/
</div></td>
<td width=\"10%\"><div align=\"center\"> /*this is supposed to show a button*/
</div></td>
</tr>";
}
echo '</table>';
?>
I want to show the content of my database in PHP
so I used a code used from another program!
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC))
(this statement is supposed to mean while the db /row has content?)
$result=mysqli_query($dbc,$displayName);
whenever I use it for my program it gives me the same error over and over, error is that:
mysqli_fetch_array() expects parameter 1 to be mysqli_result
I give it mysqli_result
but it says I gave a boolean!
I try to enclose mysqli_result in '' just because the former errors were like it's expecting 'mysqli_result' but it becomes a string so I tried changing mysqli_fetch_array into mysqli_fetch_row which shows the same error!!
also would it be because I am wanting to show buttons in the table?
It might be helpful to you.
db.php
<?php
$conn = mysqli_connect('localhost','root','','crud_db');
if(!$conn){
die('error connecting to database');
}
?>
index.php
<?php
require_once('db.php');
$query = "SELECT *
FROM employees";
$result=mysqli_query($conn,$query);
echo '<table width="75%" border="1" align="center" cellpadding="0"
cellspacing="0" bordercolor="#000000">
<tr>
<td width="10%"><div align="center"><b>EMPLOYEE NAME
</div></b></td>
<td width="10%"><div align="center"><b>APPROVE
</div></b></td>
<td width="10%"><div align="center"><b>REJECT
</div></b></td>
</tr>';
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC)){
echo "<tr>
<td width=\"10%\"><div align=\"center\">{$row['ename']}
</div></td>
<td width=\"10%\"><div align=\"center\"> <button type=\"button\">Approve</button>
</div></td>
<td width=\"10%\"><div align=\"center\"> <button type=\"button\">Reject</button>
</div></td>
</tr>";
}
echo '</table>';
?>
This is the code below! It echos out all answers for a specific question in my forum. I want about 6 answers shown on each page. Hence if there are 12 answers on one specific question then it should show the first six from the start then if the user clicks "next page" it should show the user the next 6 answers. I don't know how to fix this step in my progress. Any help is more than appreciated! Thanks.
<?php
$tbl_name2="forum_answers"; // Switch to table "forum_answer"
$sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'";
$result2=mysqli_query($con, $sql2)or die(mysqli_error($con));
while($rows=mysqli_fetch_array($result2)){
?>
<!DOCTYPE HTML SYSTEM>
<table id="answers" width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td id="answerid">#<?php echo $rows['a_id']; ?></td>
</tr>
<tr>
<td><table width="100%" border="0" cellpadding="3" cellspacing="1" >
<tr>
<?php
INCLUDE 'dbh.php';
$query = mysqli_query($conn,"SELECT * FROM forum_answers LEFT JOIN users ON forum_answers.a_name = users.username WHERE forum_answers.a_id=".$rows['a_id']." AND forum_answers.question_id=".$rows['question_id']);
while ($row = mysqli_fetch_assoc($query)) {
if ($row ['image'] == "") {
echo "<img src='bilder/default.jpg'";
?><td width="77%" bgcolor="#F8F7F1"> <?php echo $rows['a_name']; ?></td><?php
}
else {
echo "<img src='bilder/".$row ['image']."'";
?> <td width="77%" bgcolor="#F8F7F1"> <?php echo $rows['a_name']; ?></td><?php
}
echo "<br>";
}
?>
<td id="datetimeanswer" bgcolor="#F8F7F1"><?php echo $rows['a_datetime']; ?></td>
</tr>
<tr>
<td id="answertext" bgcolor="#F8F7F1"><strong>Answer:</strong></td>
<td bgcolor="#F8F7F1"><?php echo $rows['a_answer']; ?>
<button id="removeanswer" name="remove">Remove</button>
<button id="removeanswer">Edit</button>
</td>
</tr>
</table></td>
</tr>
</table>
Hello here is my code :
<table class="table table-hover table-bordered">
<tr>
<th class="well" style="text-align:center">ID</th>
<th class="well" style="text-align:center">Email</th>
<th class="well" style="text-align:center">User level</th>
</tr>';
<?
$code_sql = "SELECT user_id, user_email,user_level FROM users ORDER BY user_id ASC ";
$code_query = mysql_query($code_sql) or die(error_sql(mysql_error(),__LINE__,__FILE__));
$sql_rows = mysql_num_rows($code_query);
if($sql_rows > 0){
while($rows = mysql_fetch_object($code_query)){
$user_id = intval($rows->user_id);
$user_level= intval($rows->user_level);
$user_email = htmlspecialchars($rows->user_email);
echo ' <tr>
<td>'.$user_id.'</td>
<td>'.$user_email.'</td>
<td>'.$user_level.'</td>
</tr>';
}
mysql_free_result($code_query);
}else{
echo '<tr>
<td>
<font color="red">no data found</font>
</td>
</tr>';
}
echo '</table>';
?>
the output of the code will be like .
<table class="table table-hover table-bordered">
<tr>
<th class="well" style="text-align:center">ID</th>
<th class="well" style="text-align:center">Email</th>
<th class="well" style="text-align:center">User level</th>
</tr>
<tr>
<td>1</td>
<td>test1#gmail.com</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>test2#gmail.com</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>test3#gmail.com</td>
<td>2</td>
</tr>
<tr>
<td>4</td>
<td>test4#gmail.com</td>
<td>1</td>
</tr>
</table>
(1 = normal user , and 2 = admin for user level) but what I want is something .like that
<table class="table table-hover table-bordered">
<tr>
<th class="well" style="text-align:center">ID</th>
<th class="well" style="text-align:center">Email</th>
<th class="well" style="text-align:center">User level</th>
</tr>
<div id="users">
<tr>
<td>1</td>
<td>test1#gmail.com</td>
<td>1</td>
</tr>
<tr>
<td>4</td>
<td>test4#gmail.com</td>
<td>1</td>
</tr>
</div>
<div id="admins">
<tr>
<td>2</td>
<td>test2#gmail.com</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>test3#gmail.com</td>
<td>2</td>
</tr>
</div>
</table>
I want to add a div id="users" that will contain all users from database that have user_level = 1 and another div id="admins" for user_level = 2.
try the following code, you need to create div's based on conditions like if the iteration number 1 then insert div(open) before content and after content(close)...and the if iteration number is 3 then again insert the div(open) before content an after content(close)
<table class="table table-hover table-bordered">
<tr>
<th class="well" style="text-align:center">ID</th>
<th class="well" style="text-align:center">Email</th>
<th class="well" style="text-align:center">User level</th>
</tr>
<?php
$code_sql = "SELECT user_id, user_email,user_level FROM users ORDER BY user_id ASC ";
$code_query = mysql_query($code_sql) or die(error_sql(mysql_error(),__LINE__,__FILE__));
$sql_rows = mysql_num_rows($code_query);
if($sql_rows > 0){
$i=0;
while($rows = mysql_fetch_object($code_query)){
$user_id = intval($rows->user_id);
$user_level= intval($rows->user_level);
$user_email = htmlspecialchars($rows->user_email);
if($i==0){?><div id='users'><?php }elseif($i==2){?><div id='admins'><?php }
echo ' <tr>
<td>'.$user_id.'</td>
<td>'.$user_email.'</td>
<td>'.$user_level.'</td>
</tr>';
if($i==0){?></div><?php }elseif($i==2){?></div><?php }
$i++;
}
mysql_free_result($code_query);
}else{
echo '<tr>
<td>
<font color="red">no data found</font>
</td>
</tr>';
}
echo '</table>';
?>
Try the below code with tbody to group table rows,
<?php
$code_sql = "SELECT user_id, user_email,user_level FROM users ORDER BY user_level ASC, user_id ASC ";
$code_query = mysql_query($code_sql) or die(error_sql(mysql_error(),__LINE__,__FILE__));
$sql_rows = mysql_num_rows($code_query);
if($sql_rows > 0){
$newgroup = false;
$groupid = array(1=>'users', 2=>'admins');
while($rows = mysql_fetch_object($code_query)){
$user_id = intval($rows->user_id);
$user_level= intval($rows->user_level);
$user_email = htmlspecialchars($rows->user_email);
if($newgroup != $user_level) {
if($newgroup != false) echo '</tbody>';
echo '<tbody id="'.$groupid[$user_level].'">';
$newgroup = $user_level;
}
echo ' <tr>
<td>'.$user_id.'</td>
<td>'.$user_email.'</td>
<td>'.$user_level.'</td>
</tr>';
}
echo '</tbody>';
mysql_free_result($code_query);
}else{
echo '<tr>
<td>
<font color="red">no data found</font>
</td>
</tr>';
}
echo '</table>';
?>
Note:
It would work if you just want to group table rows. But if you want to add additional features like animation then you might need to add more css/jQuery.
Additional suggestions:
1. You should start using mysqli or PDO
2. You should start using css to replace font tags.
<?php session_start();
require_once('SessionSet.php');
require_once('connection.php');
include('top.php');
if(isset($_GET['ClassID']) && isset($_GET['SectionId']) )
{
$ClassID = $_GET['ClassID'];
$SectionId = $_GET['SectionId'];
$ClassName = $_GET['ClassName'];
$SectionName = $_GET['SectionName'];
$GetCurrentMonth = date('M');
/* select latest Academic Year*/
$GetAcademicQ = "select * from study_year order by StudyYearId desc limit 1";
$GetAcademicQR = mysqli_query($con,$GetAcademicQ);
$GetAcademicRow = mysqli_fetch_assoc($GetAcademicQR);
$AcademciyearId = $GetAcademicRow['StudyYearId'];
$YearName = $GetAcademicRow['YearName'];
/* Get Students and Students Class + Fee Records */
$GetStudentClassQ = "select * from studentclass where
AcademicYearId='$AcademciyearId' and StudentClassId='$ClassID'
and StudentSectionId='$SectionId';";
$GetStudentClassQR = mysqli_query($con,$GetStudentClassQ);
$GetStudentClassNum = mysqli_num_rows($GetStudentClassQR);
if($GetStudentClassNum>0)
{
while($GetStudentClassRow = mysqli_fetch_assoc($GetStudentClassQR))
{
$StudentID = $GetStudentClassRow['StudentID'];
$RollNumber = $GetStudentClassRow['RollNumber'];
$RollNumber = $GetStudentClassRow['RollNumber'];
$StuentClassFee = $GetStudentClassRow['StuentClassFee'];
/* Get Stduent Name and bio data */
$GetStudentQ = "select * from students where Student_ID='$StudentID';";
$GetStudentQR = mysqli_query($con,$GetStudentQ);
$GetStudentRow = mysqli_fetch_assoc($GetStudentQR);
$Name = $GetStudentRow['Name'];
$FatherName = $GetStudentRow['FatherName'];
$StudentPhoto = $GetStudentRow['StudentPhoto'];
$Student_ID = $GetStudentRow['Student_ID'];
/* Get Stduent Name and bio data */
$GetfeeQ = "select * from fee where FeeStudentID='$StudentID';";
$GetfeeQR = mysqli_query($con,$GetfeeQ);
$GetfeeRow = mysqli_fetch_assoc($GetfeeQR);
$FeeAmount = $GetfeeRow['FeeAmount'];
$FeePaid = $GetfeeRow['FeePaid'];
?>
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<table class="table table-hover table-bordered print-table" style="width:100% !important" align="center">
<!--Office Copy-->
<tr class="warning">
<th>Student ID</th>
<td>
<?php echo $Student_ID;?>
</td>
<th>Class</th>
<td>
<?php echo $ClassName;?>
</td>
<th>Section Name</th>
<td>
<?php echo $SectionName;?>
</td>
<th>Roll Number</th>
<td>
<?php echo $RollNumber;?>
</td>
<th>Academic Year </th>
<td>
<?php echo $YearName;?>
</td>
<!--td rowspan="5" style="text-align:center"><img src="StudentImages/<?php/* echo $StudentPhoto;*/?>"/ alt="Stdudent Image not found" style="width:150px; height:200px"></td-->
</tr>
<tr class="warning">
<th>Student Name</th>
<td colspan="4">
<?php echo $Name;?>
</td>
<th>Father Name</th>
<td colspan="4">
<?php echo $FatherName;?>
</td>
</tr>
<tr class="warning">
<th>Fee Month </th>
<td>
<?php echo $GetCurrentMonth;?>
</td>
<th>Fee Amount</th>
<td style="font-size:20px;">
<?php echo $StuentClassFee;?>
</td>
<th>Previous Dues</th>
<td style="font-size:20px;">
<?php echo $FeeAmount-$FeePaid;?>
</td>
<th>Due Date</th>
<td>12 -
<?php echo $GetCurrentMonth;?>
</td>
<th>After Due Date</th>
<td>
<?php echo $StuentClassFee+50;?>
</td>
</tr>
<hr>
<!--Student Copy-->
</table>
<table class="table table-hover table-bordered print-table" style="width:100% !important" align="center" >
<tr class="warning">
<th>Student ID</th>
<td>
<?php echo $Student_ID;?>
</td>
<th>Class</th>
<td>
<?php echo $ClassName;?>
</td>
<th>Section Name</th>
<td>
<?php echo $SectionName;?>
</td>
<th>Roll Number</th>
<td>
<?php echo $RollNumber;?>
</td>
<th>Academic Year </th>
<td>
<?php echo $YearName;?>
</td>
<!--td rowspan="5" style="text-align:center"><img src="StudentImages/<?php/* echo $StudentPhoto;*/?>"/ alt="Stdudent Image not found" style="width:150px; height:200px"></td-->
</tr>
<tr class="warning">
<th>Student Name</th>
<td>
<?php echo $Name;?>
</td>
<th>Father Name</th>
<td>
<?php echo $FatherName;?>
</td>
<th>Fee Month </th>
<td>
<?php echo $GetCurrentMonth;?>
</td>
<th>Fee Amount</th>
<td style="font-size:20px;">
<?php echo $StuentClassFee;?>
</td>
<th>Previous Dues</th>
<td style="font-size:20px;">
<?php echo $FeeAmount-$FeePaid;?>
</td>
</tr>
</table>
</div>
<!-- row end here -->
</div>
</div>
<!-- page-wrapper end here -->
<?php
}
}
else
{
}
?>
<?php
}
?>
i am building a php school management application. when I try to print report after pressing ctrl+p one recored is being shown on each page. but i want to show atleast 3 records on a single page after giving printing command. I have attached snapshots of records before and after print command.
enter image description here
here is picture after giving print command
enter image description here
Your question has nothing to do with PHP, this is a question about CSS, specifically print styles.
In the absence of an example of plain HTML and CSS, take a look at the CSS properties page-break-before, page-break-after and page-break-inside. In this case you may want to look at something like:
#media print {
.row, table {
page-break-before: avoid;
page-break-after: avoid;
}
}
Learn a little bit more about the page-break-* properties at this CSS Tricks article. If you are generally new to CSS print styles, I wrote a primer for .NET magazine.
Bear in mind that whatever styles you use, these are only suggestions to the browser. Paper size, page orientation, font size, zoom level, user margins, etc. will all work together to mess with your plans. Content that you force to be too wide for the page may also be an issue.
Finally, don't use any inline styles. Use your CSS file for that (so get rid of that width:100% inline style I saw.
If you want more help, post the raw HTML output and your CSS.
From below code i am displaying values from tables. The Problem is when i am clicking button no value is displayed. I want the recordset value as echo using PHP_SELF.*
**Here echo "". $row['First_name'] i am trying to fetc recordset via form to display variable without use of javascript or any function**
$sql = "SELECT * FROM test.billing";
try
{
$result = mysql_query($sql);
// Mysql_num_row is counting table row
$count = mysql_affected_rows();
if($count>0)
{
$i=0;
while($row = mysql_fetch_array($result))
{
$i++;
?>
<div class="CSS_Table_Example" style="width:800px;height:100px;">
<table border="1" width="800" cellpadding="2">
<tr>
<td width="5%" nowrap>ID</td>
<th width="15%" align="right" nowrap> First Name</th>
<th width="15%" align="right" nowrap> Last Name</th>
<th width="15%" align="right" nowrap> Password</th>
<th width="25%" align="right" nowrap> E-mail</th>
<th width="25%" align="right" nowrap> Edit</th>
</tr>
<tr>
<td width="5%" nowrap><?php echo $i; ?></td>
<td width="15%" nowrap><?php echo "". $row['First_name']; ?> </td>
<td width="15%" nowrap><?php echo "". $row['Last_name']; ?> </td>
<td width="15%" nowrap><?php echo "". $row['Password']; ?> </td>
<td width="25%" nowrap><?php echo "". $row['Email']; ?> </td>
<td width="25%" align="right" nowrap>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="SUBMIT" name="Submit" size="30"></form> </td>
</tr>
</table>
</div>
<?Php
}
if(isset($_POST['Submit']))
{
echo "". $row['First_name'];
}
}
else
{
Error_reporting (E_ALL ^ E_NOTICE);
}
}
catch(Exception $e)
{
error_reporting (E_ALL ^ E_NOTICE);
}
It's not rror_reporting() it should be error_reporting().
try/catch is redundant, you have nothing that throws exceptions in that code.
And that's what I got from just a quick glance. Please consider rereading the relevant parts of the PHP manual, and learn how to write proper code. I also suggest you grab yourself a good IDE/editor with syntax highlighting.