Ill formatted HTML from a PHP loop - php

I am looping through an array and building tables. The HTML is then sent to DOMPDF. However, DOMPDF will not create the PDF if the HTML is ill formatted. I assume that is what is happening in my case. Here is my loop:
<?php foreach($credits as $credit) : ?>
<?php if($credit['credit_type'] == "short") : ?>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin:0px 0px 15px 0px;">
<tr>
<td><strong><?php echo $credit['category_title']; ?></strong></td>
</tr>
<tr>
<td><?php echo $credit['credit_heading']; ?></td>
</tr>
</table>
<?php endif; ?>
<?php if($credit['credit_type'] == "long") : ?>
<?php if($credit['category_title'] != $oldvalue) : ?>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin:0px 0px 15px 0px;">
<tbody>
<?php endif; ?>
<tr>
<?php if($credit['category_title'] != $oldvalue) : ?>
<td width="25%"><strong><?php echo trim($credit['category_title']); ?></strong></td>
<td width="25%"><strong>Title</strong></td>
<td width="25%"><strong>Role</strong></td>
<td width="25%"><strong>Director</strong></td>
<?php endif; ?>
</tr>
<tr>
<td width="25%"><?php echo $credit['credit_heading'];?></td>
<td width="25%"><?php echo $credit['credit_title']; ?></td>
<td width="25%"><?php echo $credit['credit_role']; ?></td>
<td width="25%"><?php echo $credit['credit_director']; ?></td>
</tr>
<?php if($credit['category_title'] != $oldvalue) : ?>
</tbody>
</table>
<?php endif; ?>
<?php $oldvalue = $credit['category_title']; ?>
<?php endif; ?>
<?php endforeach; ?>
I cannot for the life of me work out which tag I am not closing. If anyone could give some insight, that would be fab!
Specifically, the loop is creating rows that show some headings, and then spit out futher rows whenever the category title changes.

This may be a simple solution but perhaps not the best:
I recommend you to use PHP's Tidy class (eventually you'll have to install it first...)
Here is the link for the Tidy class Manual.
At the first line:
ob_start();
This command buffers everything what is outputed by your follwing script.
The code below should be added at the end of your file, or there where you want to show the output.
It first gets the buffer with ob_get_contents() and than it cleans the code up.
Note that you'll eventually have to change the configuration parameters for your needs, there are really very much.
$raw_output = ob_get_clean();
$config = array('indent' => true, 'output-xhtml' => true, 'wrap' => 0);
$tidy = new Tidy;
$tidy->parseString($raw_output, $config, 'utf8');
$tidy->cleanRepair();
echo $tidy;
This Example Code was modified by the original version of the example on php.net.
Hope that helps you.

It's a bit difficult to parse without known more about your data. For example, why is a table for "short" credit open and closed with the record, but the table for "long" credit is conditional on the previous record? Is it because you have a flat data structure so related data shows up as a series of consecutive rows? If that's the case things would be easier if the data were a bit more normalized. I.e. you could iterate through each credit record then through the details separately. Any possibility of fixing your data structure?
Analyzing the code you have, your problem appears to be in the logic for the second section of the code. You are setting the value of the variable $oldvalue at the end of the loop. This is after the logic that closes the table. So if you parse two records that have the same category title the second record will output it's table rows completely outside a table (never mind that it will also have a completely empty row). Additionally, if you have a short credit type following a long the table will never be closed.
That being said, working with what you have I'm guessing you may need something like the following:
// build a dummy "previous" record for the first iteration so the conditionals don't break.
<?php $previous_credit = array('credit_type'=>null,'category'=>null); ?>
<?php foreach($credits as $credit) : ?>
<?php if($credit['credit_type'] == "short" || ($previous_credit['credit_type'] == "long" && $previous_credit['category'] != $credit['category'])) : ?>
</tbody>
</table>
<?php endif; ?>
<?php if($credit['credit_type'] == "short") : ?>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin:0px 0px 15px 0px;">
<tr>
<td><strong><?php echo $credit['category_title']; ?></strong></td>
</tr>
<tr>
<td><?php echo $credit['credit_heading']; ?></td>
</tr>
</table>
<?php endif; ?>
<?php if($credit['credit_type'] == "long") : ?>
<?php if($credit['category_title'] != $previous_credit['category_title']) : ?>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin:0px 0px 15px 0px;">
<tbody>
<tr>
<td width="25%"><strong><?php echo trim($credit['category_title']); ?></strong></td>
<td width="25%"><strong>Title</strong></td>
<td width="25%"><strong>Role</strong></td>
<td width="25%"><strong>Director</strong></td>
</tr>
<?php endif; ?>
<tr>
<td width="25%"><?php echo $credit['credit_heading'];?></td>
<td width="25%"><?php echo $credit['credit_title']; ?></td>
<td width="25%"><?php echo $credit['credit_role']; ?></td>
<td width="25%"><?php echo $credit['credit_director']; ?></td>
</tr>
<?php endif; ?>
<?php $previous_credit = $credit; ?>
<?php endforeach; ?>
<!-- one last table close for the last record -->
</tbody></table>
(That's some ugly code and I don't have time to keep revising it, so ... community wiki in case anyone else wants to clean it up.)

Related

In PHP, how does one conditionally format a row based on cell value [duplicate]

This question already has answers here:
How do I highlight table row when fetching all information with array?
(2 answers)
Closed 3 months ago.
Given the following code, I want to highlight the row of a table wherein the $listing->Full == '1'.
<table id="datatable-responsive" cellspacing="0" width="100%">
<thead>
<tr>
<th align="center">Qty</th>
<th align="center">Posted Date</th>
<th align="center">Expiration</th>
<th align="center">Full Pkg</th>
</tr>
</thead>
<tbody>
<?php foreach($listings as $listing):
?>
<tr>
<td align="center"><?php echo $listing->quantity; ?></td>
<td align="center"><?php
$pdate = new DateTime($listing->posted_at);
echo $pdate->format('m/d/y'); ?></td>
<td align="center"><?php
$date = new DateTime($listing->expdate);
echo $date->format('m/d/y');
?>
</td>
<td align="center"><?php
if($listing->full == '1'):
?>
<?php echo "Yes"; ?>
<?php else:
?>
<?php echo "No"; ?>
<?php endif; ?>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
So ideally, the highlight color would be FFFFE6. Any help is greatly appreciated. This is an MVC site, so changing the CSS isn't conveniently an option.
Test before you set the style. Here is an inline example:
<?php
if($listing->full == '1'):
?>
<td align="center" style="background:#FFFFE6">
<?php echo "Yes"; ?>
<?php else: ?>
<td align="center">
<?php echo "No"; ?>
<?php endif; ?>
</td>
<?php endif; ?>
Here is an example using a class in your CSS:
CSS
.highlight {
background: #FFFFE6;
}
PHP/HTML
<?php
if($listing->full == '1'):
?>
<td align="center" class="highlight">
<?php echo "Yes"; ?>
<?php else: ?>
<td align="center">
<?php echo "No"; ?>
<?php endif; ?>
</td>
<?php endif; ?>

Displaying submitted form results as a list of URL links

First of all my PHP skills are kinda limited, Hence my question to you here.
I have built a fairly complex form with multiple inputs(text boxs and drop downs) which are stored in a MYsql DB. When the form is submitted it displays on a new page as completed reports. These completed reports display one under the next every time the form is submitted. My question is, How can i get the reports displayed to show as a list of links to the individual reports rather then a list of complete reports.
I hope i've explained the situation well enough.
Code snippit from viewpage.php
<html>
<head>
<body>
<?php
mysql_connect("localhost","user","passwrd");
mysql_select_db("dtbase");
$order = "SELECT * FROM jobrequest" ;
$result = mysql_query($order);
while ($row=mysql_fetch_array($result)){
?>
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
<div style="padding:15px 0px 0px 100px;">
<table cellpadding="0" cellspacing="0" border="0" style="vertical-align:middle;width: 1139px; background-color:#213568; height:36px;">
<tr>
<td class="topbar">Client Request Form</td>
<td style="width:900px;"></td>
<td class="topbar"><a style="color:#ffffff;" href="logout.php?logout">Logout</a></td>
</tr>
</table>
<div class="main-wrap">
<div class="content">
<table cellpadding="0" cellspacing="0" border="0" style="width: 1137px; background-color:#ffffff; height:5px;">
<tr>
<td></td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" border="0" >
<tr>
<td style="vertical-align:top; width:5px;"></td>
<td style="vertical-align:top;"><?php include("includes/clientchoices.php"); ?></td>
<td style="vertical-align:top; padding:0px 5px 15px 5px;">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="vertical-align:top; width:1002px;"> <h1> Dashboard</h1></td>
</tr>
<tr>
<td style="vertical-align:top; background-color:#f5f5f5;"><h2>Job Request Form</h2></td>
</tr>
<tr>
<td style="vertical-align:top; background-color:#ffffff; height:5px;"> </td>
</tr>
<tr>
<td>
<div class="form">
<table cellspacing="0" cellpadding="0" border="0" style="width:998px">
<tr>
<td style="width:1002px; border:solid 1px #000000; padding:10px 0px 10px 0px;"><center><img src="../../images/spectra_logotop.jpg" alt="Spectra" title="Spectra" width="735" height="120" style="padding:5px;"></center>
</td>
</tr>
<tr>
<td>
<div style="padding:10px 0px 10px 0px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="headingsa">Project Leader:</td><td class="answersa"><div class= "typesectiona"><?php echo ($row['project_leader'] ); ?></div></td>
<td class="headingsb">Contact Number:</td><td class="answersb"><div class= "typesectionb"><?php echo ($row['contact_number'] ); ?></div></td>
<td class="headingsc">Company Details:</td><td class="answersc"><div class= "typesectionc"><?php echo ($row['company_details'] ); ?></div></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tr>
<td class="headings5">Contact Person On Site:</td><td class="answers5"><div class= "typesection5"><?php echo ($row['contactperson_onsite'] ); ?></div></td>
<td class="headings6">Contact Details:</td><td class="answers6"><div class= "typesection6"><?php echo ($row['contact_no'] ); ?></div></td>
<td class="headings7">Date:</td><td class="answers7"><div class= "typesection7"><?php echo ($row['date'] ); ?></div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tr>
<td class="headings1">Job/Order Number:</td><td class="answers1"><div class= "typesection1"><?php echo ($row['job_order_number'] ); ?></div></td>
<td class="headings2">Document Number:</td><td class="answers2"><div class= "typesection2"><?php echo ($row['doument_number'] ); ?></div></td>
<td class="headings3">QCP:</td><td class="answers3"><div class= "typesection3"><?php echo ($row['qcp'] ); ?></div></td>
<td class="headings4">Page No:</td><td class="answers4"><div class= "typesection4"><?php echo ($row['pageno'] ); ?></div></td>
</tr>
</table>
</td>
</tr>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="15px"></td>
<td><a class="othersubmitsLink" href="actionpdf.php">Email to Spectra</a></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
<?php
}
?>
</body>
</html>
You will need a separate PHP script for displaying a report based on a supplied ID. This separate script would look something like this:
Using mysqli
<?php
$conn = new mysqli("localhost", "user", "passwrd", "dtbase");
$jrQry = $conn->prepare("SELECT * FROM jobrequest WHERE jobrequest_id = ?");
$jrQry->bind_param('i', $_GET['jobrequest_id']);
$jrQry->execute();
$jobrequestResult = $jrQry->get_result();
$jobrequest = $jobrequestResult->fetch_assoc();
// At this point, $jobrequest will contain the jobrequest record you want to display.
?>
<!-- HTML FOR REPORT GOES HERE, USING $jobrequest VARIABLE TO SHOW THE DATA -->
Note that I have used mysqli in this example, if this is unsuitable you can use the old-style mysql commands, but for many many reasons (security chief among them) I would strongly suggest against this.
Using mysql
<?php
mysql_connect("localhost","user","passwrd");
mysql_select_db("dtbase");
$order = "SELECT * FROM jobrequest WHERE jobrequest_id = " . (int)$_GET['jobrequest_id'];
$result = mysql_query($order);
$jobrequest = mysql_fetch_array($result);
// At this point, $jobrequest will contain the jobrequest record you want to display.
?>
<!-- HTML FOR REPORT GOES HERE, USING $jobrequest VARIABLE TO SHOW THE DATA -->
Save this page as "viewjobrequest.php" and you will be able to load a given job request's report by supplying the jobrequest ID as a parameter in the URL, like so:
http://address_of_site/viewjobrequest.php?jobrequest_id=X
Now you can automatically generate a list of links to these pages by looking up your complete set of jobrequests and iterating over them, but instead on outputting a full report, just output a link:
Using mysqli
<?php
$conn = new mysqli("localhost", "user", "passwrd", "dtbase");
$jrQry = $conn->prepare("SELECT * FROM jobrequest WHERE jobrequest_id = ?");
$jrQry->bind_param('i', $_GET['jobrequest_id']);
$jrQry->execute();
$jobrequestResult = $jrQry->get_result();
?>
<ul>
<?php
while ($jobrequest = $jobrequestResult->fetch_assoc())
{
?>
<li>
<a href="viewjobrequest.php?jobrequest_id=<?php echo $jobrequest['jobrequest_id']; ?>">
View job request #<?php echo $jobrequest['jobrequest_id']; ?>
</a>
</li>
<?php
}
?>
</ul>
Using mysql
<?php
mysql_connect("localhost","user","passwrd");
mysql_select_db("dtbase");
$order = "SELECT * FROM jobrequest WHERE jobrequest_id = " . (int)$_GET['jobrequest_id'];
$result = mysql_query($order);
?>
<ul>
<?php
while ($jobrequest = mysql_fetch_assoc($result))
{
?>
<li>
<a href="viewjobrequest.php?jobrequest_id=<?php echo $jobrequest['jobrequest_id']; ?>">
View job request #<?php echo $jobrequest['jobrequest_id']; ?>
</a>
</li>
<?php
}
?>
</ul>
Note: I have deliberately omitted large portions of your HTML, you can add as much extra HTML as you need, I've just offered the bare bones to get you started.
BY looking at your code, I can say, it's not problem with PHP, it's more like HOW you are showing the result after fetching from database,
you are running loop, started from here
<?php while ($row=mysql_fetch_array($result)){ ?>
and ends here
<?php}?>
So everything inside loop or in easy words inside these brackets {} repeating again and again with new row of result fetched from database, if you take view source of viewpage.php you will see that style css file <link rel="stylesheet" href="css/style.css" type="text/css" /> repeating, Imagine if you are fetching 10 rows of result, you are also loading css file 10 times.
So the answer (most probably the solution) of your question is;
Your mysql query
<?php
mysql_connect("localhost","user","passwrd");
mysql_select_db("dtbase");
$order = "SELECT * FROM jobrequest" ;
$result = mysql_query($order);
$totalrows = mysql_num_rows($result); //Check Total Number of Rows To Check if Data Exist or Not
?>
and then in your HTML, First check if there are any rows exist in database which match your WHERE clause in mysql query.
//Set an if else statement here so incase if no data exist.
<?php if($totalrows > 0) {
//If row(s) exist run your while loop here
<?php while ($row=mysql_fetch_array($result)){ ?>
//Show the result here from database
//Close your loop
<?php } ?>
//Close your if condition
<?php } else { ?>
//Display a message here if there is no data to show
//Close your else bracket
<?php } ?>
With above explaniation I adjusted your HTML to show the result in desired way;
<table cellspacing="0" cellpadding="0" border="0" style="width:998px">
<tr>
<td style="width:1002px; border:solid 1px #000000; padding:10px 0px 10px 0px;"><center><img src="../../images/spectra_logotop.jpg" alt="Spectra" title="Spectra" width="735" height="120" style="padding:5px;"></center></td>
</tr>
<tr>
<td>
<?php if($totalrows > 0) {
<div style="padding:10px 0px 10px 0px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="headingsa">Link to Report</td>
</tr>
<?php while ($row=mysql_fetch_array($result)){ ?>
<tr>
//You have to replace `nameoffile.php` with file in which you want to display report and correct this (as i assumed it) if it's wrong `$row['id']`
<td>Open Report</td>
</tr>
<?php } ?>
</table>
</div>
<?php } else { ?>
<div style="padding:10px 0px 10px 0px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td>There is No Result To Show</td>
</tr>
</table>
</div>
<?php } ?>
</td>
</tr>
</table>
Note: MySQL will soon be deprecated, consider start using MYSQLi or PDO

ajaxForm 500 Internal Server Error

Hi im making an ajaxForm using comments.My problem is why the error is 500 Internal Server Error???, Well my codes and js library are in there, i dont quite understand why 500 internal server error.. Here's my code below.
<script>
$(document).ready(function(){
$("#tbl_comments").hide();
//$("#loading").hide();
$("#ptxt_green").hide();
$('#comment_form').ajaxForm({
target: '.result',
beforeSubmit: validate,
success: function(data) {
alert(data);
}
});
$("#loading")
.hide()
$(".result").show()
.ajaxStart(function(){
$(this).show();
$(".result").hide();
$("#loading").show();
})
.ajaxStop(function(){
$(this).hide();
$(".result").show();
})
;
});
function validate(){
var comment = $('textarea[name=txt_comment]').fieldValue();
if(!comment[0]){
$("#ptxt_green").fadeIn();
$("#ptxt_green").fadeOut(3000);
return false;
}
}
</script>
<?php $sf_response->setTitle(myTitleFactory::getPageTitle('seminar_detail', 'frontend',array('%seminar_title%'=>$seminar->getTitle())));?>
<?php myTools::loadBreadSlot(array(
myBreadcrumbFactory::get('seminar-list', 'frontend'),
myBreadcrumbFactory::get('seminar', 'frontend', array('slug' => $seminar->getSlug()), $seminar->getTitle())))
?>
<h1><?php echo $seminar->getTitle(); ?></h1>
<div class="table_seminar_wrap">
<table class="table_seminar" cellspacing="0" cellpadding="0" border="0" summary="info table">
<tr>
<th>Employee Id</th>
<td><?php echo $seminar->getId(); ?></td>
</tr>
<tr>
<th valign="top">情報公開日</th>
<td><?php echo $seminar->getPublishDate() .' '.$seminar->getPublishHour(); ?>時</td>
</tr>
<tr>
<th valign="top">セミナースキーム</th>
<td><?php echo $seminar->getStyle(); ?></td>
</tr>
<tr>
<th valign="top">日程</th>
<td><?php echo $seminar->getSeminarDate() .' '.$seminar->getStartTime() .' ~'.$seminar->getEndTime(); ?></td>
</tr>
<tr>
<th valign="top">前振りの文章</th>
<td><?php echo $seminar->getRawValue()->getSummary(); ?></td>
</tr>
<tr>
<th valign="top">タイトル</th>
<td><?php echo $seminar->getTitle(); ?></td>
</tr>
<tr>
<th valign="top">サブタイトル</th>
<td><?php echo $seminar->getSubTitle(); ?></td>
</tr>
<tr>
<th valign="top">開催地</th>
<td><?php echo $seminar->_getAddress(ESC_RAW); ?></td>
</tr>
<tr>
<th valign="top">会場</th>
<td>
<?php if($seminar->getLocationName()) : ?>
<?php echo $seminar->getLocationName(); ?><br>
<?php endif; ?>
<?php if($seminar->getRoomName()) : ?>
<?php echo $seminar->getRoomName(); ?>
<?php endif; ?>
</td>
</tr>
<?php if($seminar->getLocationName()) : ?>
<tr>
<th valign="top">会場URL</th>
<td><?php echo $seminar->getLocationUrl(); ?></td>
</tr>
<?php endif; ?>
<tr>
<th valign="top">内容</th>
<td><?php echo $seminar->getRawValue()->getDetail(); ?></td>
</tr>
<tr>
<th valign="top">キーチャート</th>
<td>
<?php if($seminar->getImagePath()): ?>
<a href="<?php echo $seminar->getImagePath(); ?>" target="_blank">
<img style="width:300px;" src="<?php echo $seminar->getImagePath(); ?>"/></a>
<?php endif; ?>
</td>
</tr>
<tr>
<th valign="top">対象</th>
<td>
<?php foreach($seminar->getTarget() as $target): ?>
<?php echo $target; ?>
<?php endforeach;?>
</td>
</tr>
<tr>
<th valign="top">定員・残席状況</th>
<td><?php echo $seminar->getCapacity(); ?>人</td>
</tr>
<tr>
<th valign="top">参加料</th>
<td><?php echo $seminar->getPrice(); ?></td>
</tr>
<tr>
<th valign="top">担当者</th>
<td><?php echo $seminar->getEmployee()->getName(); ?></td>
</tr>
<tr>
<th valign="top">講師</th>
<td>
<img class="instructorImage" alt="Instructor Image" src="<?php echo $seminar->getInstructor()->_getImagePath(); ?>" /><br>
<span><?php echo $seminar->getInstructor()->getName(); ?><span>
</td>
</tr>
<tr>
<th valign="top" style="width:170px">ご参加の皆様へのメッセージ</th>
<td><?php echo $seminar->getRawValue()->getMessage(); ?></td>
</tr>
<?php if($sf_user->isAuthenticated() && !$seminarXPerson): ?>
<tr>
<td style="text-align:center;" colspan="2">
<div class="blueBtnLink">
<span>応募する</span>
</div>
</td>
</tr>
<?php elseif(!$sf_user->isAuthenticated()): ?>
<tr>
<td style="text-align:center;" colspan="2">
<div class="blueBtnLink">
<span>応募する</span>
</div>
</td>
</tr>
<?php endif; ?>
</table>
<div id="ptxt_green">
<p>Please Write A Comments. . .</p>
</div>
<br />
<?php if($sf_user->isAuthenticated()): ?>
<form id="comment_form" action="<?php echo url_for('seminar/comment');?>" method="post">
<textarea id="txt_comment" name="txt_comment"></textarea>
<input type="submit" value="Write Comments" />
<br />
<br />
<div id="loading" style="text-align:center;">
<img alt="" src="/images/loading.gif" />
</div>
<div class="result">
<table id="tbl_comments">
<tr>
<td width="10%">Comments:</td>
<td>asasa</td>
</tr>
</table>
</div>
</form>
<?php endif; ?>
</div>
and my php file is this one
<?php
class commentAction extends sfAction{
public function execute($request){
echo "test"; exit();
//echo "qwqqwqqw"; exit();
//$post = $request->getParameter('seminar');
////print_r($post);exit();
//$comment = new SeminarComments();
//$comment->setComments($post['txt_comment']);
//$comment->save();
//$this->redirect('seminar');
}
}
?>
there.Why 500 internal server error? is this from the js? error?
neeeeeeeeeeed badly help
You have not provided enough info for anyone to give you a definitive answer, but here are some troubleshooting tips:
Check your server logs. To find where they are, see https://serverfault.com/questions/287079/cant-find-apache-error-logs and try to grep it out, here are a few to try (stolen directly from referenced ServerFault question)
grep ErrorLog /usr/local/etc/apache22/httpd.conf
grep ErrorLog /etc/apache2/apache2.conf
grep ErrorLog /etc/httpd/conf/httpd.conf
Once you find your server logs, find the log entry that corresponds to your 500 error. If you are having a hard time finding it, make another request with your client and then try to find the latest log entries.
Possible sources of error in your JavaScript include:
Calling the wrong URL
Calling the right URL but with the wrong parameters
Calling the right URL and parameters but with the wrong format (ie JSON vs XML)
Calling the right URL, parameters, and format but with wrong method (ie GET vs POST)
Calling the right URL/parameters/format/method but sending bogus data that the web server rejects (ie some servers are configured to automatically reject certain strings that look malicious)
By the way the server-side code you have posted does not tell the whole story. It is a simple class but rests on top of a complex framework, and you need to check the framework configuration to see if all is well. In particular, try calling the action directly (ie in your web browser, NOT through jQuery/JS). If it doesn't work, try calling a different action and see if it works. If you cannot get any action to work, it might be a framework config issue. I'm not familiar with symfony but if I were forced to become so I would start there.
If you can provide us the error log it would help greatly.
Try to call dev controller from your ajaxCall.
Normally you call index.php which is production controller and it doesn't provide any useful information about the error. Try to call front_dev.php instead which will return additional information about an error.
(the name of your dev controller is usually your app name suffixed with _dev.php so front_dev.php assumes your app name is front, which is default btw)

How to hide table if a variable empty

I have table with variables in it. I want to hide whole table if the first variable is empty. I want to hide id="con_industry (whole table) if $list_primary_industry variable is empty. Here is my code:
<table class="admintable" id="con_industry">
<tr id="con_id_industry1">
<td class="key"><?php echo JText::_('PRIMARY_INDUSTRY');
?></td<td>echo $list_primary_industry; ?></td></tr>
</table>
Set a check before your table:
<?php if(isset($list_primary_industry) && !empty($list_primary_industry)): ?>
<table class="admintable" id="con_industry">
<tr id="con_id_industry1">
<td class="key"><?php echo JText::_('PRIMARY_INDUSTRY'); ?></td>
<td>echo $list_primary_industry; ?></td>
</tr>
</table>
<?php endif; ?>
Like this: (fixed your code a bit)
<? if($list_primary_industry) {?>
<table class="admintable" id="con_industry">
<tr id="con_id_industry1">
<td class="key"><?php echo JText::_('PRIMARY_INDUSTRY');
?></td><td><? echo $list_primary_industry; ?></td></tr>
</table>
<?}?>

Called hyperlink stopped showing when CSS table implemented

EDIT: Solved - was not flutter's tag stripping, should work as advertised.
I'm using Flutter (which creates custom fields) in Wordpress to display profile information entered as a Post. Before I implemented the CSS tables the link showed up and was clickable. Now I get nothing returned, even when I try to call the link outside the table.
If you know anything about this, here's my code in the index.php file and I remain available for any questions.
<?php if (in_category('Profile')) { ?>
<table id="mytable" cellspacing="0">
-snip-
<tr>
<th class="row1" valign="top">Website </td>
<td>Link: <?php echo get_post_meta($post->ID, 'FrWebsite', $single=true) ?></td>
</tr>
-snip-
</table>
Edit: #Josh - there is a foreach looping construct in the table and it is reading and displaying the code correctly, I see what you're getting at now:
<tr>
<th class="row2" valign="top">Specialities </td>
<td class="alt" valign="top"><?php $my_array = get('Expertise');
$output = "";
foreach($my_array as $check)
{
$output .= "<span>$check</span><br/> ";
}
echo $output; ?></td>
</tr>
Edit - #Josh - here's the old code as far as I can remember it, there was no major difference just a <td> tag where there now stands a <th>, there wasn't the class="" and there was no "Link:" and FrWebsite was called Website, but it still didn't work when called Website so I changed to see if that was the error.
<tr>
<td width="200" valign="top">Website </td>
<td><?php echo get_post_meta($post->ID, 'Website', $single=true) ?></td>
</tr>
Where is $post set? What does the full table look like? Could be that when you changed the table structure you accidentally removed something like (line 2 below):
<table id="mytable" cellspacing="0">
<?php foreach($posts as $post) { ?>
<tr>
<th class="row1" valign="top">Website </td>
<td>Link: <?php echo get_post_meta($post->ID, 'FrWebsite', $single=true) ?></td>
</tr>
<?php } ?>
(Just guessing here...)

Categories