each record have its own table with header - php

Is it possible to have the table setup for each record instead of all the records in the database. I can do it with asp.net but can't figure how to do it with php. I just need a sample not the work done for me or a book or link that shows how to do it.
<?php
require_once("../db_connect.php");
error_reporting(E_ERROR | E_PARSE);
$sql = "SELECT id, lanId, name, department, manager, request, request_description, request_comments, status, comments, compUser, compDt FROM requests WHERE status='received'";
$results = mysql_query($sql) or die(mysql_error());
echo"Received Requests";
echo "<br><br>";
echo("<table bgcolor=F2F2F2 width=1000 border='2'>");
echo("<tr><th>Id</th><th>LanID</th><th>Name</th><th>Department Location</th><th>Manager</th><th>request</th><th>request_description</th><th>request_comments</th><th>Status</th><th>Comments</th><th>Completed User</th><th>Completed Date</th><th>Update</th></tr>");
while($row = mysql_fetch_array($results)){
echo("<tr>");
echo "<td>". $row['id'] . "</td>"
."<td>" . $row['lanId'] . "</td> "
. "<td>". $row['name'] . "</td>"
. "<td>". $row['department'] . "</td>"
. "<td>" . $row['manager'] . "</td>"
. "<td>" . $row['request'] ."</td>"
. "<td>" . $row['request_description'] ."</td>"
. "<td>" . $row['request_comments'] ."</td>"
. "<td>" . $row['status'] ."</td>"
. "<td>" . $row['comments'] ."</td>"
. "<td>" . $row['compUser'] ."</td>"
. "<td>" . $row['compDt'] ."</td>"
."<td><a href='../update.php?id=" . $row['id'] . "'>Update</a></td>";
echo '</tr>';
}
echo("</table>");
?>
<html>
<head>
<meta http-equiv="refresh" content="5" >
<title>
</title>
</head>
<body background="../images/background.jpg">
</body>
</html>

Yes
Just put the table tags inside the the while loop
echo("<table bgcolor=F2F2F2 width=1000 border='2'>");
while($row = mysql_fetch_array($results)){
echo("<tr><th>Id</th><th>LanID</th><th>Name</th><th>Department Location</th><th>Manager</th> <th>request</th><th>request_description</th><th>request_comments</th><th>Status</th><th>Comments</th> <th>Completed User</th><th>Completed Date</th><th>Update</th></tr>");
echo("<tr>");
echo "<td>". $row['id'] . "</td>"
."<td>" . $row['lanId'] . "</td> "
. "<td>". $row['name'] . "</td>"
. "<td>". $row['department'] . "</td>"
. "<td>" . $row['manager'] . "</td>"
. "<td>" . $row['request'] ."</td>"
. "<td>" . $row['request_description'] ."</td>"
. "<td>" . $row['request_comments'] ."</td>"
. "<td>" . $row['status'] ."</td>"
. "<td>" . $row['comments'] ."</td>"
. "<td>" . $row['compUser'] ."</td>"
. "<td>" . $row['compDt'] ."</td>"
."<td><a href='../update.php?id=" . $row['id'] . "'>Update</a></td>";
echo '</tr>';
echo("</table>");
}

Related

How can I put the next row on the bottom of first row using PHP and jQuery?

I want to put the next row on the bottom of my first row. How can I do it? I make table using PHP and jQuery. The problem is when I create more than 1 row the result is in the same line. Can somebody help me regarding to my problem? The data is from my database table.
//PHPCODE.PHP
else if(isset($_POST['btnView'])){
$selectData = $conn->query("SELECT * from tbl_wedding");
echo "<table align='center' border='1'>
<th>Groom FirstName</th>
<th>Groom MiddleName</th>
<th>Groom LastName</th>
<th>Groom DateOfBirth</th>
<th>Groom Address</th>
<th>Bride FirstName</th>
<th>Bride MiddleName</th>
<th>Bride LastName</th>
<th>Bride DateOfBirth</th>
<th>Bride Address</th>
<th>Reservation Date</th>
<th>Select Time</th>
<tr>";
while($row = $selectData->fetch_assoc()){
echo "<td>" . $row['GroomFirstName'] . "</td>" . "<td>" . $row['GroomMiddleName'] . "</td>" . "<td>" . $row['GroomLastName'] . "</td>" . "<td>" . $row['GroomDOB'] . "</td>" . "<td>" . $row['GroomAddress'] . "</td>" . "<td>" . $row['BrideFirstName'] . "</td>" . "<td>" . $row['BrideMiddleName'] . "</td>" . "<td>" . $row['BrideLastName'] . "</td>" . "<td>" . $row['BrideDOB'] . "</td>" . "<td>" . $row['BrideAddress'] . "</td>" . "<td>" . $row['ReservationDate'] . "</td>" . "<td>" . $row['SelectTime'] . "</td>";
}
echo "</tr></table>";
}
//JSCODE.JS
while($row = $selectData->fetch_assoc()){
echo "<td>" . $row['FirstName'] . "</td>" . "<td>" . $row['MiddleName'] . "</td>" . "<td>" . $row['LastName'] . "</td> " . "<td>" . $row['DateOfBirth'] . "</td>" . "<td>" . $row['Address'] . "</td>" . "<td>" . $row['NameOfFather'] . "</td>" . "<td>" . $row['NameOfMother'] . "</td>" . "<td>" . $row['ReservationDate'] . "</td>" . "<td>" . $row['BapSelectTime'] . "</td>";
}
echo "</tr></table>";
You have to enclose the <th> and <td> by the <tr>. <tr> indicates row. So each data must be inclined within a row. Isn't it?
else if(isset($_POST['btnView'])){
$selectData = $conn->query("SELECT * from tbl_wedding");
echo "<table align='center' border='1'>
<tr>
<th>Groom FirstName</th>
<th>Groom MiddleName</th>
<th>Groom LastName</th>
<th>Groom DateOfBirth</th>
<th>Groom Address</th>
<th>Bride FirstName</th>
<th>Bride MiddleName</th>
<th>Bride LastName</th>
<th>Bride DateOfBirth</th>
<th>Bride Address</th>
<th>Reservation Date</th>
<th>Select Time</th>
</tr>";
while($row = $selectData->fetch_assoc()){
echo "<tr><td>" . $row['GroomFirstName'] . "</td>" . "<td>" . $row['GroomMiddleName'] . "</td>" . "<td>" . $row['GroomLastName'] . "</td>" . "<td>" . $row['GroomDOB'] . "</td>" . "<td>" . $row['GroomAddress'] . "</td>" . "<td>" . $row['BrideFirstName'] . "</td>" . "<td>" . $row['BrideMiddleName'] . "</td>" . "<td>" . $row['BrideLastName'] . "</td>" . "<td>" . $row['BrideDOB'] . "</td>" . "<td>" . $row['BrideAddress'] . "</td>" . "<td>" . $row['ReservationDate'] . "</td>" . "<td>" . $row['SelectTime'] . "</td></tr>";
}
echo "</table>";
}
//JSCODE.JS
while($row = $selectData->fetch_assoc()){
echo "<tr><td>" . $row['FirstName'] . "</td>" . "<td>" . $row['MiddleName'] . "</td>" . "<td>" . $row['LastName'] . "</td> " . "<td>" . $row['DateOfBirth'] . "</td>" . "<td>" . $row['Address'] . "</td>" . "<td>" . $row['NameOfFather'] . "</td>" . "<td>" . $row['NameOfMother'] . "</td>" . "<td>" . $row['ReservationDate'] . "</td>" . "<td>" . $row['BapSelectTime'] . "</td></tr>";
}
echo "</table>";

HTML table is adding additional row when calling information from database table

I seem to be having an issue with my HTML formatting. I am calling the database to display all information within the table on a webpage. I have got the information coming down into the table. Unfortunately the table is adding an additional row to the bottom of the table making 4 rows when in fact there is only 3 rows displaying in the database.
Any idea as to why?
<?php
//connect to the server
$link = mysql_connect('*****', '*****', '****');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('******');
$query = mysql_query("SELECT * FROM tablename");
echo "<table border='1'>
<tr>
<td>Date</td>
<td>Region</td>
<td>Cameraman</td>
<td>Livestream?</td>
<td>Event Title</td>
<td>Lecturer</td>
<td>Time</td>
<td>Speaker</td>
<td>ICE Contact</td>
<td>Venue Address</td>
<td>Venue Contact</td>
<td>Additional Comments</td>
<td>On App?</td>
</tr>";
WHILE($rows = mysql_fetch_array($query)):
echo "<tr>";
echo "<td>" . $rows['date'] . "</td>";
echo "<td>" . $rows['region'] . "</td>";
echo "<td>" . $rows['cameraman'] . "</td>";
echo "<td>" . $rows['livestream'] . "</td>";
echo "<td>" . $rows['eventitle'] . "</td>";
echo "<td>" . $rows['lecturer'] . "</td>";
echo "<td>" . $rows['time'] . "</td>";
echo "<td>" . $rows['speaker'] . "</td>";
echo "<td>" . $rows['icecontact'] . "</td>";
echo "<td>" . $rows['venueaddress'] . "</td>";
echo "<td>" . $rows['venuecontact'] . "</td>";
echo "<td>" . $rows['additioncomments'] . "</td>";
echo "<td>" . $rows['onapp'] . "</td>";
echo "</tr>";
endwhile;
echo "</table>";
?>
I have added the link to the page below.
http://cpdonline.tv/spreadsheet/spreadsheet.php
Update your while loop with the following:
WHILE($rows = mysql_fetch_array($query)):
$rows = array_filter($rows);
if (!empty($rows)) {
echo "<tr>";
echo "<td>" . $rows['date'] . "</td>";
echo "<td>" . $rows['region'] . "</td>";
echo "<td>" . $rows['cameraman'] . "</td>";
echo "<td>" . $rows['livestream'] . "</td>";
echo "<td>" . $rows['eventitle'] . "</td>";
echo "<td>" . $rows['lecturer'] . "</td>";
echo "<td>" . $rows['time'] . "</td>";
echo "<td>" . $rows['speaker'] . "</td>";
echo "<td>" . $rows['icecontact'] . "</td>";
echo "<td>" . $rows['venueaddress'] . "</td>";
echo "<td>" . $rows['venuecontact'] . "</td>";
echo "<td>" . $rows['additioncomments'] . "</td>";
echo "<td>" . $rows['onapp'] . "</td>";
echo "</tr>";
}
endwhile;
echo "</table>";
array_filter() function's default behavior will remove all values from array which are equal to null, 0, '' or false.
It seems that you have empty data in your database, as many lines are empty
Check your database for empty records or run the query
DELETE FROM table_name WHERE column='';

Adding autonumber column to php table that reads from mysql

I am trying to add a column before my first column that starts numbering each record, starting from 1. I was trying to add autoincrement to this line echo "" . $row['ss'] . "";, but that does not seem to want to work. Any ideas how to do this?
My code looks like this:
$result = mysqli_query($con,"SELECT * FROM `results` WHERE Event='100' AND Gender='M' ORDER BY Performance ASC");
echo "<table border='0'>
<tr>
<th align='left'>Pos</th>
<th align='left'>Event</th>
<th>Performance</th>
<th>Wind</th>
<th>Place</th>
<th align='left'>Name</th>
<th align='left'>Surname</th>
<th>Age</th>
<th>Team</th>
<th>Meet</th>
<th>Date</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['ss'] . "</td>";
echo "<td>" . $row['Event'] . "</td>";
echo "<td>" . $row['Performance'] . "</td>";
echo "<td>" . $row['Wind'] . "</td>";
echo "<td>" . $row['Pos'] . "</td>";
echo "<td width='100' align='left'>" . $row['Surname'] . "</td>";
echo "<td Width='100'>" . $row['Name'] . "</td>";
echo "<td>" . $row['Age'] . "</td>";
echo "<td>" . $row['Team'] . "</td>";
echo "<td>" . $row['Meet'] . "</td>";
echo "<td>" . $row['Date'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
Add this line in header
<th align='left'>#</th>
And here php code
$count = 1;
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $count . "</td>";
echo "<td>" . $row['ss'] . "</td>";
echo "<td>" . $row['Event'] . "</td>";
echo "<td>" . $row['Performance'] . "</td>";
echo "<td>" . $row['Wind'] . "</td>";
echo "<td>" . $row['Pos'] . "</td>";
echo "<td width='100' align='left'>" . $row['Surname'] . "</td>";
echo "<td Width='100'>" . $row['Name'] . "</td>";
echo "<td>" . $row['Age'] . "</td>";
echo "<td>" . $row['Team'] . "</td>";
echo "<td>" . $row['Meet'] . "</td>";
echo "<td>" . $row['Date'] . "</td>";
echo "</tr>";
//other code
$count=$count+1;
}
A better solution would be to use a variable counter to "number" your rows:
$counter = 1;
while($row = mysqli_fetch_array($result))
echo "<td>" . $counter . "</td>";
$counter++;
}
This is the right way to do it since if that ss column is the mysql auto increment, then your rows will not be numbered by the SORT but rather from the order in which they were inserted into the database regardless of any sorting you apply.
Try to change fetch_array with fetch_assoc

Search a Table using PHP

I have a form on my website that I use to send information to a MySQL table, then I have a PHP file called read.php that retrieves the information from the MySQL table and displays it on a page. This works completely fine and I have no issues with it. However I would now like to add a search function so the table can be searched by things such as first name, last name, email etc.
Here is my read.php file:
<html>
<head>
<title>messages</title>
</head>
<body>
<h1>Message Center</h1>
<?php
$con = mysqli_connect('localhost', 'removed', 'removed', 'removed');
$result = mysqli_query($con,"SELECT*FROM specialisttable");
echo"<table border='1'>
Specialist Table
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Phone</th>
<th>Email</th>
<th>Website</th>
<th>Speciality</th>
<th>Street Name</th>
<th>Suburb</th>
<th>City</th>
<th>Post Code</th>
<th>Comments</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
{
echo "<tr>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['phone'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['website'] . "</td>";
echo "<td>" . $row['speciality'] . "</td>";
echo "<td>" . $row['streetname'] . "</td>";
echo "<td>" . $row['suburb'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['postcode'] . "</td>";
echo "<td>" . $row['comments'] . "</td>";
echo "</tr>";
}
}
echo"</table>";
mysqli_close($con);
?>
<br>
<br>
Click to return to homepage
</body>
</html>
I would to like search by things such as first name, email and city so for example if I have an entry with the name John and I type J into the first name search bar John and his other information would show in the table as well as anyone else with J in their name.
Also the same thing for something such as city, if I type auck then all the entries with auck in the city section would show as well as the other information.
I'm unsure of how I would do this, I've managed to work out how to search for first name using $search = $_GET['search']; and then using:
while($row = mysqli_fetch_array($result))
{
if($search=="")
{
echo "<tr>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['phone'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['website'] . "</td>";
echo "<td>" . $row['speciality'] . "</td>";
echo "<td>" . $row['streetname'] . "</td>";
echo "<td>" . $row['suburb'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['postcode'] . "</td>";
echo "<td>" . $row['comments'] . "</td>";
echo "</tr>";
}
else if($row['firstname']==$search)
{
echo "<tr>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['phone'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['website'] . "</td>";
echo "<td>" . $row['speciality'] . "</td>";
echo "<td>" . $row['streetname'] . "</td>";
echo "<td>" . $row['suburb'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['postcode'] . "</td>";
echo "<td>" . $row['comments'] . "</td>";
echo "</tr>";
}
I can do the same thing for last name and any other field but it makes the code very messy and I don't think it's the most efficient way of doing things.
If someone could please point me in the right direction on how to efficiently make a search function I would greatly appreciate it.
Thank you very much.

MySQL Query Returns Blank Field with AES_ENCRYPT

My query string is $SQLstring = "SELECT name, address, city, state, zip, homephone, cellphone, position, shift, status, workedherebefore, previousemploymentdate, referred, empname, under18, friends, empname2, currentlyemployed, contactemployer, lawful, worktime, workweekends, dateavailable, desiredsalary, position1, from1, to1, duties1, company1, cophone1, startsalary, endsalary, reasonleaving1, supervisor1, contact1, position2, from2, to2, duties2, company2, cophone2, startsalary2,
endsalary2, reasonleaving2, supervisor2, contact2, position3, from3, to3, duties3, company3, cophone3, startsalary3, endsalary3, reasonleaving3, supervisor3, contact3, comments, training, otherqual, documents, dltype, dlstate, expdate, yearsdriving, movingviolations, hsname, hscity, hsstate, hsdates, collegename, collegecity, collegestate, collegedates, othername, othercity, otherstate, otherdates, licenseorcert, refname1, refbusiness1, reftitle1, refaddress1, refphone1, refname2, refbusiness2, reftitle2, refaddress2, refphone2, refname3, refbusiness3, reftitle3, refaddress3, refphone3,felony, iffelony, fired, iffired, resident, explanation, signed, q1, q2, q3, q4, mq1, mq2, mq3, mq4, mq5, mq6, mq7, mq8, mq9, mq10, mq11, mq12, mq13, mq14, mq15, mq16,
mq17, mq18, mq19, mq20, mq21, mq22, mq23, mq24, mq24b, mq25, mq25b, mq26, mq27a, mq27b, mq27c, mq28, mq29, mq30answer, disclosuresig, verify_name, other_names, dob, AES_DECRYPT(ssn,'$key') AS ssn FROM applications";
I query the results and then return them in a table. All of them work except for the AES_DECRYPT field (ssn). In the database it seems to have been encrypted fine, but this field in the query is returned as blank. Here is the rest of the code, just in case it's relevant:
$key="88b871WZ3SntWK67rN3l2J1SvMqsOjyk";
$QueryResult = #mysql_query($SQLstring, $conn) or die("Query Problem - "
. mysql_error($conn) . " - Error Number - "
. mysql_errno($conn));
$num_result = mysql_num_rows($QueryResult);
echo "<table>";
for ($i = 0; $i < $num_result; $i++)
{
$row = mysql_fetch_array($QueryResult);
echo "<tr>";
echo "<td>" . $row["name"] . "</td>";
echo "<td>" . $row["email"] . "</td>";
echo "<td>" . $row["address"] . "</td>";
echo "<td>" . $row["city"] . "</td>";
echo "<td>" . $row["state"] . "</td>";
echo "<td>" . $row["zip"] . "</td>";
echo "<td>" . $row["homephone"] . "</td>";
echo "<td>" . $row["cellphone"] . "</td>";
echo "<td>" . $row["position"] . "</td>";
echo "<td>" . $row["shift"] . "</td>";
echo "<td>" . $row["status"] . "</td>";
echo "<td>" . $row["workedherebefore"] . "</td>";
echo "<td>" . $row["previousemploymentdate"] . "</td>";
echo "<td>" . $row["referred"] . "</td>";
echo "<td>" . $row["empname"] . "</td>";
echo "<td>" . $row["under18"] . "</td>";
echo "<td>" . $row["friends"] . "</td>";
echo "<td>" . $row["empname2"] . "</td>";
echo "<td>" . $row["currentlyemployed"] . "</td>";
echo "<td>" . $row["contactemployer"] . "</td>";
echo "<td>" . $row["lawful"] . "</td>";
echo "<td>" . $row["worktime"] . "</td>";
echo "<td>" . $row["workweekends"] . "</td>";
echo "<td>" . $row["dateavailable"] . "</td>";
echo "<td>" . $row["desiredsalary"] . "</td>";
echo "<td>" . $row["position1"] . "</td>";
echo "<td>" . $row["from1"] . "</td>";
echo "<td>" . $row["to1"] . "</td>";
echo "<td>" . $row["duties1"] . "</td>";
echo "<td>" . $row["company1"] . "</td>";
echo "<td>" . $row["cophone1"] . "</td>";
echo "<td>" . $row["startsalary"] . "</td>";
echo "<td>" . $row["endsalary"] . "</td>";
echo "<td>" . $row["reasonleaving1"] . "</td>";
echo "<td>" . $row["supervisor1"] . "</td>";
echo "<td>" . $row["contact1"] . "</td>";
echo "<td>" . $row["position2"] . "</td>";
echo "<td>" . $row["from2"] . "</td>";
echo "<td>" . $row["to2"] . "</td>";
echo "<td>" . $row["duties2"] . "</td>";
echo "<td>" . $row["company2"] . "</td>";
echo "<td>" . $row["cophone2"] . "</td>";
echo "<td>" . $row["startsalary2"] . "</td>";
echo "<td>" . $row["endsalary2"] . "</td>";
echo "<td>" . $row["reasonleaving2"] . "</td>";
echo "<td>" . $row["supervisor2"] . "</td>";
echo "<td>" . $row["contact2"] . "</td>";
echo "<td>" . $row["position3"] . "</td>";
echo "<td>" . $row["from3"] . "</td>";
echo "<td>" . $row["to3"] . "</td>";
echo "<td>" . $row["duties3"] . "</td>";
echo "<td>" . $row["company3"] . "</td>";
echo "<td>" . $row["cophone3"] . "</td>";
echo "<td>" . $row["startsalary3"] . "</td>";
echo "<td>" . $row["endsalary3"] . "</td>";
echo "<td>" . $row["reasonleaving3"] . "</td>";
echo "<td>" . $row["supervisor3"] . "</td>";
echo "<td>" . $row["contact3"] . "</td>";
echo "<td>" . $row["comments"] . "</td>";
echo "<td>" . $row["training"] . "</td>";
echo "<td>" . $row["otherqual"] . "</td>";
echo "<td>" . $row["documents"] . "</td>";
echo "<td>" . $row["dltype"] . "</td>";
echo "<td>" . $row["dlstate"] . "</td>";
echo "<td>" . $row["expdate"] . "</td>";
echo "<td>" . $row["yearsdriving"] . "</td>";
echo "<td>" . $row["movingviolations"] . "</td>";
echo "<td>" . $row["hsname"] . "</td>";
echo "<td>" . $row["hscity"] . "</td>";
echo "<td>" . $row["hsstate"] . "</td>";
echo "<td>" . $row["hsdates"] . "</td>";
echo "<td>" . $row["collegename"] . "</td>";
echo "<td>" . $row["collegecity"] . "</td>";
echo "<td>" . $row["collegestate"] . "</td>";
echo "<td>" . $row["collegedates"] . "</td>";
echo "<td>" . $row["othername"] . "</td>";
echo "<td>" . $row["othercity"] . "</td>";
echo "<td>" . $row["otherstate"] . "</td>";
echo "<td>" . $row["otherdates"] . "</td>";
echo "<td>" . $row["licenseorcert"] . "</td>";
echo "<td>" . $row["refname1"] . "</td>";
echo "<td>" . $row["refbusiness1"] . "</td>";
echo "<td>" . $row["reftitle1"] . "</td>";
echo "<td>" . $row["refaddress1"] . "</td>";
echo "<td>" . $row["refphone1"] . "</td>";
echo "<td>" . $row["refname2"] . "</td>";
echo "<td>" . $row["refbusiness2"] . "</td>";
echo "<td>" . $row["reftitle2"] . "</td>";
echo "<td>" . $row["refaddress2"] . "</td>";
echo "<td>" . $row["refphone2"] . "</td>";
echo "<td>" . $row["refname3"] . "</td>";
echo "<td>" . $row["refbusiness3"] . "</td>";
echo "<td>" . $row["reftitle3"] . "</td>";
echo "<td>" . $row["refaddress3"] . "</td>";
echo "<td>" . $row["refphone3,felony"] . "</td>";
echo "<td>" . $row["iffelony"] . "</td>";
echo "<td>" . $row["fired"] . "</td>";
echo "<td>" . $row["iffired"] . "</td>";
echo "<td>" . $row["resident"] . "</td>";
echo "<td>" . $row["explanation"] . "</td>";
echo "<td>" . $row["signed"] . "</td>";
echo "<td>" . $row["q1"] . "</td>";
echo "<td>" . $row["q2"] . "</td>";
echo "<td>" . $row["q3"] . "</td>";
echo "<td>" . $row["q4"] . "</td>";
echo "<td>" . $row["mq1"] . "</td>";
echo "<td>" . $row["mq2"] . "</td>";
echo "<td>" . $row["mq3"] . "</td>";
echo "<td>" . $row["mq4"] . "</td>";
echo "<td>" . $row["mq5"] . "</td>";
echo "<td>" . $row["mq6"] . "</td>";
echo "<td>" . $row["mq7"] . "</td>";
echo "<td>" . $row["mq8"] . "</td>";
echo "<td>" . $row["mq9"] . "</td>";
echo "<td>" . $row["mq10"] . "</td>";
echo "<td>" . $row["mq11"] . "</td>";
echo "<td>" . $row["mq12"] . "</td>";
echo "<td>" . $row["mq13"] . "</td>";
echo "<td>" . $row["mq14"] . "</td>";
echo "<td>" . $row["mq15"] . "</td>";
echo "<td>" . $row["mq16"] . "</td>";
echo "<td>" . $row["mq17"] . "</td>";
echo "<td>" . $row["mq18"] . "</td>";
echo "<td>" . $row["mq19"] . "</td>";
echo "<td>" . $row["mq20"] . "</td>";
echo "<td>" . $row["mq21"] . "</td>";
echo "<td>" . $row["mq22"] . "</td>";
echo "<td>" . $row["mq23"] . "</td>";
echo "<td>" . $row["mq24"] . "</td>";
echo "<td>" . $row["mq24b"] . "</td>";
echo "<td>" . $row["mq25"] . "</td>";
echo "<td>" . $row["mq25b"] . "</td>";
echo "<td>" . $row["mq26"] . "</td>";
echo "<td>" . $row["mq27a"] . "</td>";
echo "<td>" . $row["mq27b"] . "</td>";
echo "<td>" . $row["mq27c"] . "</td>";
echo "<td>" . $row["mq28"] . "</td>";
echo "<td>" . $row["mq29"] . "</td>";
echo "<td>" . $row["mq30answer"] . "</td>";
echo "<td>" . $row["disclosuresig"] . "</td>";
echo "<td>" . $row["verify_name"] . "</td>";
echo "<td>" . $row["other_names"] . "</td>";
echo "<td>" . $row['ssn'] . "</td>";
echo "<td>" . $row["dob"] . "</td>";
echo "</tr>";
}
echo "</table>";
}
To use AES_ENCRYPT and AES_DECRYPT the field type must be BLOB. I had it set to VARCHAR and it wasn't recognizing some of the characters. Changing the field type to blob worked perfectly.
MySQL AES_DECRYPT() returns NULL if detects invalid data.
So the strings passed to the AES_DECRYPT() are invalid.
In this type of cases, I recommend to ECHO/alert the query so that you can see everything is right. The most probable mistake is what AD7six noted... the $key is probably empty.
$key="88b871WZ3SntWK67rN3l2J1SvMqsOjyk";
$SQLstring = "SELECT * FROM table"; // Replace with your Query
echo $SQLstring;
$QueryResult = #mysql_query($SQLstring, $conn) or die("Query Problem - " . mysql_error($conn) . " - Error Number - " . mysql_errno($conn));
Alerter:
echo "<script type='text/javascript'>
alert($SQLstring);
</script>";
I also recommend you read about mysqli

Categories