/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php //Set our variables //Connect to the Database //Run our query $result = mysql_query('SELECT * FROM recipes ORDER BY `recipe_id` DESC LIMIT ' . $num, $con) or die('MySQL Error.'); //Preapre our output if($format == 'json') { } } elseif($format == 'xml') { $output = "<?xml version=\"1.0\"?>\n"; $output .= "<recipes>\n"; $output .= "<recipe> \n"; $output .= "<recipe_id>" . $row['recipe_id'] . "</recipe_id> \n"; $output .= "<recipe_name>" . $row['recipe_name'] . "</recipe_name> \n"; $output .= "<recipe_poster>" . $row['recipe_poster'] . "</recipe_poster> \n"; $output .= "<recipe_quick_info>" . $row['recipe_quick_info'] . "</recipe_quick_info> \n"; $output .= "<recipe_link>" . $row['recipe_link'] . "</recipe_link> \n"; $output .= "</recipe> \n"; } $output .= "</recipes>"; } else { } //Output the output. echo $output; } ?>