?
Solved

php html and  css, how to use in the same file

Posted on 2011-10-30
2
Medium Priority
?
295 Views
Last Modified: 2012-05-12
Hi experts,

Im new in php and css and im working on a small project. Im stuck on a coding issue. Here is the scenario: i have two different table layouts defined in css code. Depend on a php variable value one or other css format should be used. here is the code ive made but it gives me error.

<?php
 if ($var==0)
   {
       <table border="1" cellpadding="1" cellspacing="1" style="height: auto; width: 860px;">  
   }
if ($var!=0)
  {
   <table border="1" cellpadding="1" cellspacing="1" style="height: auto; width: auto;">  <!--At this line i got the parsing error-->
  }
?>
<tr>
<td>
....................
.....................
.....................
</tr>
</td>
</table>

Open in new window


Any idea how i can do the css selection according to php variable $var value?
Thank you in advance.
Regards,
Raul
0
Comment
Question by:raulmonda
2 Comments
 
LVL 11

Accepted Solution

by:
kelvinwkw earned 2000 total points
ID: 37055182
<?php
 if ($var==0)
   {
  ?>
<table border="1" cellpadding="1" cellspacing="1" style="height: auto; width: 860px;">
 <?php
   } else  {
  ?>
   <table border="1" cellpadding="1" cellspacing="1" style="height: auto; width: auto;">  <!--At this line i got the parsing error-->
 <?php
  }
?>
0
 

Author Closing Comment

by:raulmonda
ID: 37055208
hi kelvinwkw,

I test it and it works fine.
Thank you very much.
Regards,
Raul
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question