0

I am implementing this Jquery Mobile Table in my PHP web page.

I am running into a problem however. Because I am working in PHP, I am unable to use tags such as <table data-role="table" data-mode="columntoggle" id="my-table"> inside my code.

For example:

echo "<table data-role="table" data-mode="columntoggle" id="my-table">
  <tr><th data-priority="1">Mare</th><th data-priority="2">Stallion</th><th data-priority="3">Covering Date</th><th data-priority="5">Ovulation Scan</th><th data-priority="6">Pregnancy Scan</th></tr>";

...does not work. Is there anyway of working around this?

1 Answer 1

1

Since you're not alternating between single- and double-quotes, you're essentially closing and re-opening your strings, which will cause issues. Try this:

echo '<table data-role="table" data-mode="columntoggle" id="my-table">'
  . '<thead><tr>'
  . '<th data-priority="1">Mare</th>'
  . '<th data-priority="2">Stallion</th>'
  . '<th data-priority="3">Covering Date</th>'
  . '<th data-priority="5">Ovulation Scan</th>'
  . '<th data-priority="6">Pregnancy Scan</th></tr></thead>';

Also note the period (.). This is a concatenation operator that lets you join strings together to make them more readable. They're handy when coding, since it allows you to display code in a nicer format.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks very much Chris, that seems to have worked, however I still have one more problem. When I deselect a column from the columns tab, only the column name disappears, that columns rows still appear! any idea where i might be going wrong?
It looks like you need to wrap the <tr> element in a <thead> (which is the 'table head'). I did update my answer to include the <thead> opening and closing tags.
Perfect! Thanks very much Chris, great help! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.