Undefined variable: session start (Shopping cart attempt) - php

Iam no expert and just a student and I am attempting to creating a shopping cart, so far i understand that i have to use sessions to store id. my way to connect to my database is always like this:
<html>
<head>Shopping cart</head>
<?php
$session_start();
?>
<body>
<?php
$serverName = "ephesus.cs.cf.ac.uk";
$dbName = "c1429814";
$user = "c1429814";
$pass = "fakepassword";
$con = mysqli_connect($serverName, $user, $pass, $dbName);
if(!$con){
die("failure to connect to the server ".mysqli_connect_error());
}
echo "<h1> Shopping cart </h1><br/>";
echo "<div class='text_border'>";
if(isset($_GET['id']))
$id=$_GET['id'];
else
$id=1;
if(isset($_GET['action']))
$action=$_GET['action'];
else
$action="empty";
switch($action)
{
case "add":
if (isset($_SESSION['cart'][$id]))
$_SESSION['cart'][$id]++;
else
$_SESSION['cart'][$id]=1;
break;
case "remove":
if (isset($_SESSION['cart'][$id]))
{
$_SESSION['cart'][$id]--;
if($_SESSION['cart'][$id]==0)
unset($_SESSION['cast'][$id]);
}
break;
case "empty":
unset($_SESSION['cart']);
break;
/*Display cart */
if (isset($_SESSION['cart']))
{
echo "<table border = 0 cellspacing=0 width='500'>";
$total = 0;
foreach($_SESSION['cart'] as $id => $x)
{
$query = "SELECT * FROM Software WHERE id = '$product' ";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);
$name = $row['name'];
$name=substr($name, 0, 40);
$price = $row['price'];
$the_cost= $price * $x;
$total = $total+$the_cost;
echo "<tr>";
echo "<td align='left'>$name </td>";
echo "<td align='right'>$x action=remove'>reduce'</td>";
echo "<td align='right'>= $the_cost";
echo "</tr>";
}
echo "<tr>";
echo "<td align='right'><br>Total=</td>";
echo "<td align='right'><b><br> $total </b></td>";
echo "</tr>";
echo "</table>";
}
else
echo "Cart is empty";
}
?>
</body>
</html>
I am getting an error which is called Undefined variable session, im not really sure what kind of variable i need to define to get around this? or is the way i connect to the database? any information that would could give me sufficient help and tips would be greatly appreciated. :)

$ is used for php variables...
you do not need $ when you use functions,
and open it above all code...
so here :
//...
session_start();
//...
will be better....

use session_start(); (without the dollar sign) instead, since you are calling a function not accessing a variable. And as a side note: "To use cookie-based sessions, session_start() must be called before outputing anything to the browser." More here: http://php.net/manual/en/function.session-start.php

Try to open the session before the HTML and remove $
Like this:
<?php
session_start();
?>
<html>
<head>Shopping cart</head>
<body>
<?php
$serverName = "ephesus.cs.cf.ac.uk";
$dbName = "c1429814";
$user = "c1429814";
$pass = "ugsok4";
$con = mysqli_connect($serverName, $user, $pass, $dbName);
if(!$con){
die("failure to connect to the server ".mysqli_connect_error());
}
echo "<h1> Shopping cart </h1><br/>";
echo "<div class='text_border'>";
if(isset($_GET['id']))
$id=$_GET['id'];
else
$id=1;
if(isset($_GET['action']))
$action=$_GET['action'];
else
$action="empty";
switch($action)
{
case "add":
if (isset($_SESSION['cart'][$id]))
$_SESSION['cart'][$id]++;
else
$_SESSION['cart'][$id]=1;
break;
case "remove":
if (isset($_SESSION['cart'][$id]))
{
$_SESSION['cart'][$id]--;
if($_SESSION['cart'][$id]==0)
unset($_SESSION['cast'][$id]);
}
break;
case "empty":
unset($_SESSION['cart']);
break;
/*Display cart */
if (isset($_SESSION['cart']))
{
echo "<table border = 0 cellspacing=0 width='500'>";
$total = 0;
foreach($_SESSION['cart'] as $id => $x)
{
$query = "SELECT * FROM Software WHERE id = '$product' ";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);
$name = $row['name'];
$name=substr($name, 0, 40);
$price = $row['price'];
$the_cost= $price * $x;
$total = $total+$the_cost;
echo "<tr>";
echo "<td align='left'>$name </td>";
echo "<td align='right'>$x action=remove'>reduce'</td>";
echo "<td align='right'>= $the_cost";
echo "</tr>";
}
echo "<tr>";
echo "<td align='right'><br>Total=</td>";
echo "<td align='right'><b><br> $total </b></td>";
echo "</tr>";
echo "</table>";
}
else
echo "Cart is empty";
}
?>
</body>
</html>

Please use the following code which is simplified your code. '$' should not use in your session_start();
<?php
session_start();
?>
<head>Shopping cart</head>
<body>
<?php
$serverName = "ephesus.cs.cf.ac.uk";
$dbName = "c1429814";
$user = "c1429814";
$pass = "ugsok4";
$con = mysqli_connect($serverName, $user, $pass, $dbName);
if (!$con) {
die("failure to connect to the server " . mysqli_connect_error());
}
echo "<h1> Shopping cart </h1><br/>";
echo "<div class='text_border'>";
$id = isset($_GET['id']) ? $_GET['id'] : 1;
$action = isset($_GET['action']) ? $_GET['action'] : 'empty';
switch ($action) {
case "add":
if (isset($_SESSION['cart'][$id])) {
$_SESSION['cart'][$id] ++;
} else {
$_SESSION['cart'][$id] = 1;
}
break;
case "remove":
if (isset($_SESSION['cart'][$id])) {
$_SESSION['cart'][$id] --;
if ($_SESSION['cart'][$id] == 0)
unset($_SESSION['cast'][$id]);
}
break;
case "empty":
unset($_SESSION['cart']);
break;
/* Display cart */
if (isset($_SESSION['cart'])) {
echo "<table border = 0 cellspacing=0 width='500'>";
$total = 0;
foreach ($_SESSION['cart'] as $id => $x) {
$query = "SELECT * FROM Software WHERE id = '$product' ";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);
$name = $row['name'];
$name = substr($name, 0, 40);
$price = $row['price'];
$the_cost = $price * $x;
$total = $total + $the_cost;
echo "<tr>";
echo "<td align='left'>$name </td>";
echo "<td align='right'>$x action=remove'>reduce'</td>";
echo "<td align='right'>= $the_cost";
echo "</tr>";
}
echo "<tr>";
echo "<td align='right'><br>Total=</td>";
echo "<td align='right'><b><br> $total </b></td>";
echo "</tr>";
echo "</table>";
} else {
echo "Cart is empty";
}
}
?>
</body>

Related

Calculate and print passed (%) for each application for each table

Right now I could list each application/(Internal Team Names) name in table. Now I want to find out passed (%) from each table for each application and print on html page. Each "aw..." table has all application/(Internal Team Names) names and respective result also.
<html>
<?php
$Show= htmlspecialchars($_GET["Show"]);
$team= htmlspecialchars($_GET["team"]);
$tablename = htmlspecialchars($_GET["tablename"]);
$servername="localhost";
$username="root";
$password="";
?>
<?php
// Create connection with mySQL
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn) {
die("Connection failed:" . mysqli_connect_error());
}
//echo "Connected to mysql successfully";
//select a database to work with
mysqli_query( $conn , "USE plm_dashboard" );
Echo "<Body bgcolor="."white".">" ;
//echo $Show;
Echo "<br>";
Echo "<br>";
Echo "Applied Filters Are <br> ";
//echo "Team = $team "; echo "TableName= $tablename ";
$Local_team= "Reports";
if ($Show == "failed"){
$Result_status = "passed";
} else {
// in this case the value of the $Result_status is 'all'
$Result_status = "";
}
echo "Result = $Show <br>";
//$result =mysqli_query($conn ,"SELECT * FROM aw34_0605_tc1122 where Application="."'".$team."'");
$result = mysqli_query($conn ,"SELECT * FROM teamnames");
$result1 =mysqli_query($conn ,"SELECT * FROM aw34_0530_tc1015 (Select count(id) from aw34_0530_tc1015 where result ='passed' and application='ace')/(Select count(id) from aw34_0530_tc1015 where application='ace')*100");
//$result =mysqli_query($conn ,"SELECT * FROM ". $tablename );
//********** determine number of rows result set **********/
// $row_cnt = $result->num_rows;
//mysqli_query()
//echo "Showing $row_cnt Results ";
//echo "<table border="."1".">
echo "<table border="."1"."align="."right".">
<tr>
<th>ID</th>
<th>Internal Team Names</th>
<th width="."10px"." >Passed % for aw34_0530_tc1015</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['ID'] . "</td>";
echo "<td>" . $row['TeamInternalNames'] . "</td>";
echo "<td>" . $row['TeamName'] . "</td>";
// if ($row['Result'] == "passed") {
// echo "<td style="."background-color:#33FF38".">P</td>";
// } else {
// echo "<td style="."background-color:#FF334C".">F</td>";
// }
echo "</tr>";
}
echo "</table>";
ECHO "BYE";
mysqli_close($conn);
Echo "<Body>";
?>
</html>

PHP Highlight Input Search Keyword

I want to highlight every $searchkey results.
I tried other solutions but they don't work with a search engine.
Results appear in a table.
I want every appearance of the keyword to be highlighted.
Thanks for your help!
<?php
$dbhost = 'xxx';
$username = 'xxx';
$password = 'xxx';
mysql_connect("$dbhost" , "$username", "$password" );
mysql_select_db("xxx") or die("could not find the database!");
$output = '';
if(isset($_GET['search']))
{
$searchkey = $_GET['search'];
$query = mysql_query("SELECT * FROM xxx WHERE email LIKE '%$searchkey%' ") or die("Could not search");
$count = mysql_num_rows($query);
if ($count == 0)
{
$output = 'There was no search results !' ;
}
else
{
echo '<table class="table table-striped table-bordered table-hover">';
echo "<tr><th>email</th><th>hashkey</th></tr>";
while ($row = mysql_fetch_array($query))
{
$email = $row['email'];
$hashkey = $row['hashkey'];
echo "<tr><td>";
echo $email;
echo "</td><td>";
echo $hashkey;
echo "</td></tr>";
}
echo '<div>'."$count results were found for '$searchkey'.".'</div>'.'</br>';
}
echo "</table>";
$searchkey= $words;
}
?>
You can use Regular Expression in PHP to do this. In this code I use <strong> tag, you can replace it as you want.
while ($row = mysql_fetch_array($query))
{
$email = preg_replace('/(' . $searchkey . ')/s', '<strong>\1</strong>', $row["email"]);
$hashkey = $row['hashkey'];
echo "<tr><td>";
echo $email;
echo "</td><td>";
echo $hashkey;
echo "</td></tr>";
}

How can I arrange this code so I can get different entry from database for each table row

I want every different record of database to be display on each table rows, but I'm unable to retrieve different record for each row and column. Please give me suggestion where I can paste than while block so it will give different result for each row and column.
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$rec_limit = 10;
$scriptname=$_SERVER['PHP_SELF'];
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('online_shopping'); // include your code to connect to DB.
$tbl_name="mobile_db"; //your table name
$start = 0;
$limit = 5;
$sql = "SELECT id,company,model,price,availability,image FROM $tbl_name LIMIT $start, $limit";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$company=$row['company'];
$model=$row['model'];
$available=$row['availability'];
$price=$row['price'];
}
echo "<table border='2'>";
$j = 0;
for($j = 0; $j<5; $j++)
{
echo "<tr>";
for($i = 0; $i<3; $i++)
{
echo "<td>";
echo "<table border='2'>";
echo "<tr>";
echo "<td><img src='abc.jpg' height='250' width='250'/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<table border='2'>";
echo "<tr>";
echo "<td><b>Brand : </b></td>";
echo '<td>'.$company.'</td>';
echo "</tr>";
echo "<tr>";
echo "<td><b>Model : </b></td>";
echo '<td>'.$model.'</td>';
echo "</tr>";
echo "<tr>";
echo "<td><b>Availability : </b></td>";
echo '<td>'.$available.'</td>';
echo "</tr>";
echo "<tr>";
echo "<td><b>Price : </b></td>";
echo '<td>'.$price.'</td>';
echo "</tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
?>
You need to move the table rows inside the fetch loop or store the row in an array. I have simplified your tables to make the example clearer:
$result = mysql_query($sql);
if (!$result) {
/* Error */
}
echo '<table>';
while ($row = mysql_fetch_array($result)) {
echo '<tr><td><img src="', htmlspecialchars ($row['image']), '">';
echo '<tr><td><table>';
echo ' <tr><th>Brand<td>', htmlspecialchars ($row['company']);
echo ' <tr><th>Model<td>', htmlspecialchars ($row['model']);
echo ' <tr><th>Availability<td>', htmlspecialchars ($row['availability']);
echo ' <tr><th>Price<td>', htmlspecialchars ($row['price']);
echo ' </table>';
}
echo "</table>\n";
Some notes about the code:
Test the return value of mysql_query(). The query might fail.
Escape your output using htmlspecialchars().
You should use <th> elements for your headings and style those, instead of using inline <b> elements.
I added output of $row['image'] which might not do what you want.
And do not use the deprecated mysql extension. Use PDO or mysqli instead.
In your while loop you always rewrite the same variables, after loop you have only last record saved.
In the loop, you have to save records into array.
In your code you have nested tables, but in the first one, there is only one row and one table cell which contains another table. I use just nested table.
<?php
...
$result = mysql_query($sql);
$data = array();
while($row = mysql_fetch_array($result)) {
$data[] = $row;
}
if (count($data) > 0) {
echo '<table>';
foreach ($data as $row) {
echo '<tr>';
echo '<td>Brand: ' . $row['company'];
echo '<td>Model: ' . $row['model'];
echo '<td>Availability: ' . $row['availability'];
echo '<td>Price: ' . $row['price'];
}
echo '</table>';
} else {
echo 'no records';
}
?>
Not sure I fully understand what you are trying to accomplish but try this.
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$rec_limit = 10;
$scriptname=$_SERVER['PHP_SELF'];
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('online_shopping'); // include your code to connect to DB.
$tbl_name="mobile_db"; //your table name
$start = 0;
$limit = 5;
$sql = "SELECT id,company,model,price,availability,image FROM $tbl_name LIMIT $start, $limit";
$result = mysql_query($sql);
echo "<table border='2'>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row['company']."</td>";
echo "<td>".$row['model']."</td>";
echo "<td>".$row['availability']."</td>";
echo "<td>".$row['price']."</td>";
echo "</tr>";
}
echo "</table>";
?>

PHP: Undefined shown on blank page

I'm trying to print/echo values from previous file however instead of showing error, all that is shown is 'Undefined' on a blank page. I've researched and tried several method but nothing works. Please help.
<?PHP
$user_name = "root";
$password = "";
$database = "leadership_program";
$server = "localhost";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
if (isset($_POST['survey_id'])) {
$survey_id = $_POST['survey_id'];
echo $survey_id;
}
if (isset($_POST['marks'])) {
foreach ($_POST['marks'] as $value) {
echo"$value";
}
}
if (isset($_POST['id'])) {
$id = $_POST['id'];
echo $id;
}
// $SQL2 = "UPDATE answer_table SET marks='$value' WHERE survey_id= '$survey_id' AND student_id= '$id'";
//$result2 = mysql_query($SQL2);
//mysql_close($db_handle);
} else {
print "Database NOT Found ";
mysql_close($db_handle);
// header("Location: surveyView.php");
}
?>
Here is displayresult.php
<form action="student_mark_save.php" method="POST"> //<?php...more codes here
if ($strucrow["qns$i"] === 'radio' || $strucrow["qns$i"] === 'checkbox') {
foreach ($arr as $b) {
echo "<br/>";
if (strpos($b, '%#%') !== false) {
$c = substr($b, 3, -2);
//echo $c;
$d = str_replace("$arr[0] :-", ':', $c);
echo $d, "<br/>";
echo "<br/>";
echo "<tr> Marks : <input type=\"text\" name=\"marks[]\"></tr><br />";
//echo $b;
} else {
echo $b;
// echo "is not with comment qns";
}
}
} else if ($strucrow["qns$i"] === 'comment') {
foreach ($arr as $b) {
echo $b;
echo "<tr> Marks : <input type=\"text\" name=\"marks[]\"></tr><br />";
// echo "is not with comment qns";
}
} else {
}
echo "<p/>";
}
$marksquery = sprintf(
"SELECT marks FROM answer_table WHERE survey_id = '%d' AND student_id = '$studentid' ", mysql_real_escape_string($survey_id)
);
$marksQuer = mysql_query($marksquery) or die(mysql_error());
$marksrow = mysql_fetch_assoc($marksQuer);
echo "<td><input type=\"hidden\" value= \"$survey_id\" name=\"survey_id\"></td><br />" ;
echo "<td><input type=\"hidden\" value= \"$studentid\" name=\"id\"></td><br />" ;
echo "<p><input type=\"submit\" value=\"Update\"></p>";
?>
</form>
for undefined mean, there is something which is not existing in global $_POST[]
check try to print $_POST in your first if statement as:
if ($db_found) {
print_r($_POST);
exit();
if (isset($_POST['survey_id'])) {
$survey_id = $_POST['survey_id'];
echo $survey_id;
}
now just see what do you have in $_POST, It might help you...Thanks
Most likely some Post data is not set. Try vardump($_POST); die('happy');.
It would also be better to handle missing Post data instead of just ignoring it so maybe if ($db_found) { should be
<?php
if ( $db_found
&& isset($_POST['survey_id'])
&& isset($_POST['marks'])
&& isset($_POST['id'])
)
{
$survey_id = $_POST['survey_id']; //maybe ensure int
$id = $_POST['id']; //maybe ensure int
$values = array(); //this is important $value will not be available outside the for loop or contain only the last value
foreach ((array)$_POST['marks'] as $value) { //ensure $_POST['marks'] is an array
$values[] = $value; //maybe mysql escape each $value here
}
$SQL2 = sprintf(
"UPDATE answer_table SET marks='%s' WHERE survey_id=%d AND student_id=%d",
impolde(',' $values), //assuming comma separated list here
$survey_id,
$id
);
$result2 = mysql_query($SQL2);
mysql_close($db_handle);
} else { ...
Please also consider to escape the values you read from POST. Doing it this way makes it very easy to SQL inject into your script!

php Deletion from database error

I am trying to delete a user from my simple E-commerce website for a project I am working on. When I click the delete button, the message appears and tells me that it correctly deleted the data from the table. But when I go into my sql database and check the data, its all still there. I cant figure out what I am doing wrong or where my error is. any help would be appreciated. My code is below.
<?php
session_start();
if (isset($_SESSION['shirt_users_id']) && isset($_SESSION['full_name'])) {
require('mysql_connect.php');
$title="List all registered users";
include_once("header_admin.php");
if (isset($_GET['shirt_users_id'])) {
$shirt_users_id = $_GET['shirt_users_id'];
function rollback_die($msg)
{
echo $msg;
global $link;
mysqli_query($link, "ROLLBACK");
mysqli_free_result($exec_select_sui);
mysqli_close($link);
include("footer_admin.php");
die();
}
function delete_records($array_refer)
{
global $link;
foreach ($array_refer as $key => $array_value) {
$table_name = substr($key, 0, -3);
foreach ($array_value as $value) {
$delete = "DELETE from $table_name where $key = $value";
$exec_delete = #mysqli_query($link, $delete);
if (!$exec_delete) {
rollback_die("Records from $table_name could not be deleted because of: ".mysqli_error($link));
}
}
}
return true;
}
#mysqli_query($link, "SET AUTOCOMMIT=0");
$select_sui = "SELECT shirt_users.shirt_users_id, shirt_users_types.shirt_users_types_id, shirt_orders.shirt_orders_id, shirt_shipping_addresses.shirt_shipping_addresses_id, shirt_billing_addresses.shirt_billing_addresses_id, shirt_credit_cards.shirt_credit_cards_id
from
shirt_users, shirt_users_types, shirt_orders, shirt_shipping_addresses, shirt_billing_addresses, shirt_credit_cards
where
shirt_users.shirt_users_id = shirt_users_types.shirt_users_id and
shirt_users_types.shirt_orders_id = shirt_orders.shirt_orders_id and
shirt_orders.shirt_shipping_addresses_id = shirt_shipping_addresses.shirt_shipping_addresses_id and
shirt_orders.shirt_billing_addresses_id = shirt_billing_addresses.shirt_billing_addresses_id and
shirt_orders.shirt_credit_cards_id = shirt_credit_cards.shirt_credit_cards_id and
shirt_users.shirt_users_id = $shirt_users_id";
$exec_select_sui = #mysqli_query($link, $select_sui);
if (!$exec_select_sui) {
rollback_die("A problem when retrieving records from the database for shirt user has occurred: ".mysqli_error($link));
} else {
$users = $gut = $orders = $shipping = $billing = $credit = array();
while ($one_row = mysqli_fetch_assoc($exec_select_sui)) {
$users[] = $one_row['shirt_users_id'];
$gut[] = $one_row['shirt_users_types_id'];
$orders[] = $one_row['shirt_orders_id'];
$shipping[] = $one_row['shirt_shipping_addresses_id'];
$billing[] = $one_row['shirt_billing_addresses_id'];
$credit[] = $one_row['shirt_credit_cards_id'];
}
$multi_array = array('shirt_users_id' => $users, 'shirt_users_types_id' => $gut, 'shirt_orders_id' => $orders, 'shirt_shipping_addresses_id' => $shipping, 'shirt_billing_addresses_id' => $billing, 'shirt_credit_cards_id' => $credit);
delete_records($multi_array);
echo "the record(s) of shirt user have successfully been deleted from the tables";
mysqli_query($link, "COMMIT");
}
}
(isset($_GET['sort']))?$sort = $_GET['sort']:$sort = 'ui';
(isset($_GET['bool']))?$bool = $_GET['bool']:$bool=true;
switch ($sort) {
case 'ui': ($bool)?$sort = "user_id ASC":$sort = "user_id DESC";
break;
case 'fn': ($bool)?$sort = "first_name ASC":$sort = "first_name DESC";
break;
case 'ln': ($bool)?$sort = "last_name ASC":$sort = "last_name DESC";
break;
case 'em': ($bool)?$sort = "email ASC":$sort = "email DESC";
break;
}
$select_users = "SELECT shirt_users_id, user_id, first_name, last_name, email from shirt_users order by $sort";
$exec_select_users = #mysqli_query($link, $select_users);
if (!$exec_select_users) {
echo "The user information could not be retrieved from the shirt_users table because of: ".mysqli_error($link);
mysqli_close($link);
include('footer_admin.php');
die();
} else {
echo "<div id='list_users'><table id='list_user' border='0'>";
echo "<tr>";
echo "<th><a href='".$_SERVER['PHP_SELF']."?sort=ui&bool=".!$bool."'>User ID</a></th>";
echo "<th><a href='".$_SERVER['PHP_SELF']."?sort=fn&bool=".!$bool."'>First Name</a></th>";
echo "<th><a href='".$_SERVER['PHP_SELF']."?sort=ln&bool=".!$bool."'>Last Name</a></th>";
echo "<th><a href='".$_SERVER['PHP_SELF']."?sort=em&bool=".!$bool."'>Email</a></th>";
echo "<th>Delete</th>";
echo "</tr>";
while ($one_row = mysqli_fetch_assoc($exec_select_users)) {
echo "<tr>";
echo "<td class='first'>".$one_row['user_id']."</td>";
echo "<td class='second'>".$one_row['first_name']."</td>";
echo "<td class='third'>".$one_row['last_name']."</td>";
echo "<td class='fourth'>".$one_row['email']."</td>";
echo "<td class='fifth'><a href='".$_SERVER['PHP_SELF']."?shirt_users_id=".$one_row['shirt_users_id']."'>Delete</a></td>";
echo "</tr>";
}
echo "<tr><td colspan = '4' class='footer'>Total number of users: </td><td class='footer'>".mysqli_num_rows($exec_select_users)."</td></tr>";
echo "</table></div>";
}
mysqli_free_result($exec_select_users);
} else {
echo "You are not an authentic administrator. Being directed to the login page...";
header("Refresh: 2; url='login.php'");
}
mysqli_close($link);
include("footer.php");
die();
?>
Also, I know my code is not the most efficient way to do things but im new to the whole html/css/php scene and am trying my best so please dont give me some off the wall answer about a differnt way to do this please!

Categories