hellomello
hellomello

Reputation: 8597

jquery mobile with php?

I'm trying to learn jquery mobile and I was wondering if jquery mobile can be used with PHP as if I'm building a regular website?

with jquery mobile tags are almost the same, but they use tags such as data-role,

indext.html

<div data-role="header">
<div data-role="content">
content page
</div>
</div>

Can I do something like

index.html

<div data-role="header">
<div data-role="content">
<?php echo $content; //this content will be populated by mysql
?>
</div>
</div>

Or would I have to use ajax to get the content?

index.html

$(document).ready(function(){
$.ajax({
  url: "test.html",
  success: function(data){
    $('.page1').html(data);
  }
});
});


<div data-role="header">
<div data-role="content" class='page1'>
<?php echo $content; //this content will be populated by mysql
?>
</div>
</div>

test.html

<?php
$sql = mysql_query("SELECT * FROM test");
while($q = mysql_fetch_array($sql)){
$content = $q['content'];
echo $content;
}
?>

Upvotes: 0

Views: 5078

Answers (1)

Quentin
Quentin

Reputation: 944530

I'm trying to learn jquery mobile and I was wondering if jquery mobile can be used with PHP as if I'm building a regular website?

Of course. It is a regular website.

with jquery mobile tags are almost the same, but they use tags such as data-role,

Those are attributes, not tags and are standard HTML 5 (insofar as HTML 5 is a standard, since it is still in draft form).

Even if they weren't standard, PHP wouldn't care. As far as it is concerned it is just outputting text.

Upvotes: 6

Related Questions