I have the following code, and the tutorial I followed says that the table should show up, but it doesn't. All that shows up is the text inside the <h1> and <h4> tags, and the external CSS file is also not taking effect. The code I have is as follows:
<?php
include_once('connection.php');
$query="select * from myanimelist";
$result=mysql_query($query);
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles-2.css">
</head>
<body>
<h1> Callum Stewart's Amazing Website. </h1>
<h4> The Home of Entertainment. </h4>
<table align="center" border="1px" style="width: 300px" color="black">
<tr>
<th>Anime Database</th>
</tr>
<tr>
<th>Title</th>
<th>MediaType</th>
<th>Rating</th>
<th>NumOfEpisodes</th>
<th>NumOfVolumes</th>
</tr>
</table>
</body>
</html>
Related
Currently, I am working on my datatable to display the detail from the database. I am using the php myadmin for the database. But it only manage to display the detail only but not the pagination, sorting and searching is not working. I have followed some other tutorials but it still doesn't work.
<?php
$conn = mysqli_connect("localhost", "root", "", "jiaen");
$sql = "SELECT * FROM stock LEFT OUTER JOIN category ON stock.categoryid=category.categoryid order by stockCode";
//Execute connection
$result = mysqli_query($conn,$sql);
?>
<!DOCTYPE html>
<html>
<head>
<title>Webslesson Tutorial | Datatables Jquery Plugin with Php MySql and Bootstrap</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />
</script>
</head>
<body>
<br /><br />
<div class="container">
<h3 align="center">Datatables Jquery Plugin with Php MySql and Bootstrap</h3>
<br />
<div class="table-responsive">
<table id="stock" class="table table-striped table-bordered" >
<thead>
<tr>
<td>Stock Code</td>
<td>Stock Name</td>
<td>Stock Category</td>
<td>Quantity</td>
<td>Price (RM)</td>
<td>Action</td>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($result))
{
echo '
<tr>
<td>'.$row["stockCode"].'</td>
<td>'.$row["stockName"].'</td>
<td>'.$row["categoryName"].'</td>
<td>'.$row["quantity"].'</td>
<td>'.$row["price"].'</td>
<td>Stock In</td>
<td>R&D</td>
<td>Remark Stock</td>
<td>Modify</td>
<td>Delete</td>
</tr>
';
}
?>
</tbody>
</table>
</div>
</div>
//Javascript part for datatable
<script>
$(document).ready(function() {
$('#stock').DataTable();
} );
</script>
</body>
</html>
Your <thead> contains a <tr> which is full of <td> tags instead of <th> tags.
It has 6 tags, so your table will have 6 columns.
Your <tbody> on the other hand has 10 <td> tags inside each <tr> tag.
10 will not fit into 6.
I have used below mentioned code :
<html>
<head>
<title>test Document</title>
</head>
<body>
<!--#exec cgi="calc.php" -->
<table>
<tr>
<td></td>
</tr>
<tr>
<td><img src="images1.jpg"></td>
<td><img src="images2.jpg"></td>
<td><img src="images3.jpg"></td>
</tr>
<tr>
<td colspan=3><img src="common.jpg"></td>
</tr>
</table>
</body>
</html>
If I use above mentioned code it show
[an error occurred while processing this directive]
error in front end, now what I have to do should I configure in cpanel and htaccess ?
I have 5 dropdowns on a tab of a website. I have a database table in MS SQL Server. The table has all the data of 5 dropdowns with one of the fieldNames called Region_Name, say the Region_Names are A, B, C, D, and E. I have written codes to display a table and enabled row editing for one of the RegionNames. Now, I am wondering if I could modify the same codes to display associated table with row editing enabled using different queries when a dropdown is clicked. That could reduce the code repetition and improve the performance. But I do not know how to achieve this. Could anyone please give me some hints? I am using PHP PDO to connect to the database.
My codes to display the table is shown below. I am using Datatables plugin and tableExport Jquery plug in. For simplicity, I have not copied the links and libraries for plugins. I can show my edit.php if that will be helpful.
<?php
require_once('include/database.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Matrix</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<meta http-equiv="content-type" content="text/html" charset="UTF-8">
<script src="//code.jquery.com/jquery-1.12.3.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<header>
</header> <br/>
<div id="container">
<table id="myTable" class="display" cellpadding="0px" cellspacing="0px"
width="100%">
<thead>
<tr>
<th style="width: 1px">ID</th>
<th style="width: 1px">Site</th>
<th style="width: 1px">Location</th>
<th style="width: 1px">Remarks</th>
<th width="1px">Action</th>
</tr>
</thead>
<tbody>
<?php
$stmt = $conn->prepare("SELECT * FROM MATRIX WHERE
Region_Name='Charlotte'");
$stmt ->execute();
$result = $stmt->fetchAll();
foreach($result as $row) {
?>
<tr>
<td><?=$row['ID'];?></td>
<td><?= $row['Site']; ?></td>
<td><?= $row['Location']; ?></td>
<td><?= $row['Remarks']; ?></td>
<td> Edit</td>
</tr>
<?php
}
?>
</tbody>
</table>
<br/>
</div>
</body>
</html>
You may use SELECT table_name FROM information_schema.tables WHERE table_schema = '<your database name>' to get all the table in your database.
You can also get all the columns of table with this query
select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='<your table name>'
I upload some image to phpMyAdmin, and write some code on Dreamweaver.
Then got this:
The code is on below:
<?php
require_once("connection.php");
$result = mysql_query("SELECT * FROM food");
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Food & Beverages</title>
</head>
<body>
<form>
<table width="400" border="1">
<tbody>
<?php
while($row = mysql_fetch_assoc($result)){
?>
<tr>
<td width="240" height="130"><img src="<?php echo $row['image']?>"></td>
<td><?php echo $row['info'];?></td>
</tr>
<?php }?>
</tbody>
</table>
</form>
</body>
</html>
How to solve this problem?
I don't profess to be any good at php, so those who are expert please don't bash me for my noob approach. I am trying to learn.
Some time back, I had someone show me how to break up parts of my web pages and write them as includes so that I wasn't having headers, footers, and navigation repainting for every page. As of yesterday morning, my pages were loading fine, and have been for many years now. However, something seems to have gone wrong, possibly on my server, and now all pages go to home page.
I have my pages set up as such:
index.php
<?php
if (! isset($HTTP_GET_VARS['content']) || ! $HTTP_GET_VARS['content']){
$content="squeeze";
}
else
$content=$HTTP_GET_VARS['content'];
//1
if ($content == "do-you-have-success-habits"){
$page_title="Do You Have Success Habits?";
$keywords="Booking Agent Book, Music Business Career Development Information, Performing Arts Entertainment Information";
$desc="Music Business Booking Management artist career development for musicians, performing artists, agents and managers";
$style="../scripts/style.css";
$popupjs="none";
$storbutnjs="none";
$retreatjs="none";
$rolloverjs="none";
$readform_chkjs="none";
$logo="req-files/logo.html";
$navbar="req-files/navbar.html";
$sidebar="req-files/sidebar.html";
$main="weekly/2013/do-you-have-success-habits.html";
}
include ("req-files/head.html");
include ($logo);
include ($navbar);
include ($sidebar);
include ($main);
include ("req-files/footer.html");
?>
This is a chopped down version of what I have. The whole index.php has all pages written like this, but it also contains includes to other php pages. There is so much content to this site that I've had to build php pages with like informations within one page... I.E. all affiliates would go into affiliates.php and then included into my index.php as such.
// INCLUDE AFFILIATES HERE
include ("affiliates.php");
I'm hoping this is enough information to help me troubleshoot my problem.
A sample of my pieces are like this header file. My variables are in the pieces.
head.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php print $page_title ?></title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="author" content=" " />
<meta name="keywords" content="<?php print $keywords ?>" />
<meta name="description" content="<?php print $desc ?>" />
<meta name="copyright" content="2006-2013" />
<link rel="stylesheet" type="text/css" href="<?php print $style ?>" />
<link href="scripts/twoColLiqLtHdr.css" rel="stylesheet" type="text/css" /><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.twoColLiqLtHdr #sidebar1 { padding-top: 30px; }
.twoColLiqLtHdr #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->
<link rel="stylesheet" type="text/css" href="scripts/style.css" />
<script src="scripts/stuHover.js" type="text/javascript"></script>
<link href="scripts/dropdown_menu.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.png" />
<?php
if ($popupjs != "none") {
print("<script src=\"${popupjs}\">");
print("</script>\n");
}
if ($storbutnjs != "none") {
print(" <script src=\"${storbutnjs}\">");
print("</script>\n");
}
if ($retreatjs != "none") {
print(" <script src=\"${retreatjs}\">");
print("</script>\n");
}
if ($rolloverjs != "none") {
print(" <script src=\"${rolloverjs}\">");
print("</script>\n");
}
if ($readform_chkjs != "none") {
print(" <script src=\"${readform_chkjs}\">");
print("</script>\n");
}
?>
</head>
As stated before, I am inexperienced with php. So, I'm having trouble understanding why my pages linked in my nav are going to home (squeeze) page.
Now, my hosting tech support states that it could be deprecated code that is causing this to fail. They are migrating my site, probably to a previous version of php. But I need to know where to begin fixing this. I hope it is a simple fix because this site is huge!
Thank you for your patience and your help.
Heidi
#DrCord:
On this particular example I gave, there are two nav systems. One I call sidebar the other menu. Both are set up as partial html pages.
menu.html
<tr>
<td align="center"><img src="images/design_elements/yellow_spacer.gif" alt="Yellow line" width="745" height="2" border="0" /></td>
</tr>
<tr>
<td align="center" valign="middle" background="images/design_elements/navbar.jpg" width="760" height="42" class="menubar"><nobr>About</nobr> | <nobr>Articles</nobr> | <nobr>Consulting</nobr> | <nobr>Booking Tools</nobr> | <nobr>Seminars</nobr> | <nobr>Teleseminars</nobr> | <nobr>Contact</nobr> | <nobr>Media EPK</nobr> | <nobr>Links</nobr></td>
</tr>
<tr>
<td align="center"><img src="images/design_elements/yellow_spacer.gif" alt="Yellow line" width="745" height="2" border="0" /></td>
</tr>
<tr>
<td><img src="images/design_elements/spacer.gif" alt="spacer" width="1" height="10" border="0" /></td>
</tr>
</table>
sidebar.html
<div id="container2">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td background="images/design_elements/lt-side-shadow.jpg" width="40"><img src="images/design_elements/lt-side-shadow.jpg" border="0" width="40" height="10" alt="Design Element" /></td>
<td valign="top">
<div id="sidebar1">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" style="padding: 10px;">
<table width="90%" border="0" cellpadding="0" cellspacing="0" id="cont">
<tr>
<td class="head">Articles</td>
</tr>
<tr>
<td class="head">Biz Coaching</td>
</tr>
<tr>
<td class="subhead" style="padding-left:10px;" nowrap="nowrap">Programs</td>
</tr>
<tr>
<td class="subhead" style="padding-left:10px;" nowrap="nowrap">Testimonials</td>
</tr>
<tr>
<td class="head">Books</td>
</tr>
<tr>
<td class="subhead" style="padding-left:10px; font-size:95%;" nowrap="nowrap">Huge Success</td>
</tr>
<tr>
<td class="subhead" style="padding-left:10px;" nowrap="nowrap">Guide to Touring</td>
</tr>
<tr>
<td class="subhead" style="padding-left:10px;" nowrap="nowrap">E-Book</td>
</tr>
<tr>
<td class="subhead" style="padding-left:10px;" nowrap="nowrap">I Recommend</td>
</tr>
</table>
<!-- end #sidebar1 --></div>
Again, I thank you for your patience and your help. I know that I need to learn more about PHP, and I am. I am just not clear on what the actual problem is here.