karto
karto

Reputation: 3658

Javascript modal window

I have PHP code that searches through a mysql table and prints out the empty/null fields. Now I want to print out the messages on a pop-up/modal window.

<?php
mysql_connect('localhost', 'root', '');
mysql_select_db("users") or die(mysql_error());
$emptyFields = array();
//$row_count = 1;
$sql = "SELECT * FROM userinfo";
  $res = mysql_query($sql); 
  while ($row = mysql_fetch_array($res)) {
    foreach($row as $key => $field) {
     
     if( ! is_integer($key) AND empty($field)){
        $emptyFields[] = sprintf('Field "%s" on entry "%d" is empty/null', $key, $row['card_id']);

  
      }
     }
  
   }
echo implode('<br>', $emptyFields);
echo sizeof($emptyFields);
?>

How can I get this unto an 'expandable' modal page using Javascript/jQuery. Where a page pops up to tell me the which columns headers are empty/null and also a details link when clicked, expands to give more details:

Screen shot of modal page

Upvotes: 0

Views: 755

Answers (2)

James Sulak
James Sulak

Reputation: 32447

I've used the qTip jQuery tooltip library for this kind of thing before. Although modal popups are not the primary use of qTip, it works well for simple cases.

Here's an example.

Upvotes: 0

dmackerman
dmackerman

Reputation: 2966

There are many plugins that allow modal functionality with jQuery. You could use jQuery UI and use it's build in "Dialog" functions. See here:

http://jqueryui.com/demos/dialog/

Another simple plugin: http://swip.codylindley.com/DOMWindowDemo.html

All of these can display HTML, so basically you just need to make your PHP script output HTML into the DOM, and then use the jQuery plugins to display the data in a modal.

Upvotes: 1

Related Questions