PHP - Xml Output With Css Styling
Hi
Bit new to this so bear with me.
I have an API call that outputs to a .php file (the data in the file appears to be xml - no format).
Can you please advise if i would link this to a .css file as per .html to get the formatting i require...if so, can you offer a suggestion on the syntax?
This is my API call:
<?php
Similar TutorialsHello, I need some simple help styling the output of some simple php code, I have attached a view of what the output is of right now and of what I need it to look like in the end, I have tried several times myself with faulty results. The number 3 in the first screenshot attachment is what I am looking for on the article count code, it has a div style of Code: [Select] <div class="cart-count"> the number 5 is the output of the code and that is what I need changed to the cart count class. I need the article count to be centered and to the left of the text output code, example of what I am looking for is in screenshot2 attachment. Can someone please help??? Code: [Select] <?php // no direct access defined('_JEXEC') or die('Restricted access'); ?> <div class="articles_count<?php echo $params->get('moduleclass_sfx'); ?>"> <!--- I need this article count to have a different output style then the next php code below, I also need to have it float center and to the left---> <?php foreach($lists->artcount as $key => $value): ?> <!--- End ---> <!--- I need this to float center and right to the above article count code ---> <?php echo trim($params->get('beforeText')); ?> <?php echo $value; ?> <!--- End ---> <?php if ($lists->type == 'section'){ echo trim($params->get('afterTextSection')); } else {echo trim($params->get('afterTextCategory')); } ?> <?php echo $lists->names[$key]; ?> <?php endforeach; ?> Well I have a script that executes a scan on a system set to run infinitely, and I need it to echo out a message each time it loops through, but I don't want it to echo out the message with the next loop message below it, and the next one below that etc... I've tried using the flush(); function and been messing around with that with no luck. For security reasons I don't want to release any of the processing code, but here is the basic construction of the script: <?PHP ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $RepeatIt = -1; for($g=1; $g!=$RepeatIt+1; $g++) { ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $ScanMessage = ":.:.: SCANNING THE HITLIST FOR MOBSTER: ".$MobName." (SCAN #$g) :.:.:"."<br/><br/>"; echo $ScanMessage; ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** } ?> At the moment it's returning: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #1) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #2) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #3) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #4) :.:.: So what I want it to do is just delete the scanning message and replace it with the next scan message so while running this script you would see just the number increment on the same line. Any suggestions? Thanks. I would like to style this echo in my css, how would I go about making it a div class or something to give it a ID. Code: [Select] die ("Sorry, No Results Match Your Search."); Thank You This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=351029.0 hey guys, I am wondering how to style the below code snippet using css? the code itself is working - i just am trying to figure out how to style it :( <div class="section"> <?php if(isset($_SESSION['uid'])) { echo 'Hello,'; echo $_SESSION["uid"]; } ?> </div>
This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=315995.0 Hey guys, I have a PHP pagination script, but for some reason the while looping part that shows each row doesnt show the css styling I have. Here is my code. <?php $tableName="news"; $targetpage = "archive.php"; $limit = 10; $query = "SELECT COUNT(*) as num FROM $tableName"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages['num']; $stages = 3; $page = mysql_escape_string($_GET['page']); if($page){ $start = ($page - 1) * $limit; }else{ $start = 0; } // Get page data $query1 = "SELECT * FROM $tableName LIMIT $start, $limit"; $result = mysql_query($query1); // Initial page num setup if ($page == 0){$page = 1;} $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages/$limit); $LastPagem1 = $lastpage - 1; $paginate = ''; if($lastpage > 1) { $paginate .= "<div class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='$targetpage?page=$prev'>previous</a>"; }else{ $paginate.= ""; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a href='$targetpage?page=$next'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</div>"; } //echo $total_pages.' Results'; // pagination echo $paginate; ?> <div class="newsBorder"> <table cellspacing="0" border="0" id="newsList" class="width100"> <tbody> <tr class="row_a"> <td width="30%" class="1 first" id="titleCat"> <b>Category</b> </td> <td width="50%" class="item" id="titleTitle"> <b>News Item</b> </td> <td width="20%" align="right" class="date"> <b>Date</b> </td> </tr> </tbody> </table> <?php while($row = mysql_fetch_array($result)) { ?> <tr class="pad"> <td valign="top"> <a href="list.ws?cat=3&page=1" class="catLink"> <img alt="" src="http://www.runescape.com/img/news/mini_customer_support.gif"> <span>Website</span> </a> </td> <td valign='middle'><a href="news.php?newsid=<?php echo $row['newsid'] ?>" class="titleLink"><?php echo $row['title']; ?> </a></td> <td valign="middle" align="right" class="date"><?php echo $row['dtime']; ?></td></tr><br> <?php } ?> </div> Here is how it looks right now: Here is how I want it to look like. Its basically everything inside the while is not formatting. I have all the CSS I need so that isnt the problem. Thanks for the help ahead of time. In CSS, most people add most styling to the A tag instead of UL or LI. Do you know why?
This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=355432.0 Hi. I’m hoping someone can help me pull the styling/formatting from a static page onto a category template. The content is pulling fine, but it's not formatted/styled. Code used to pull content from static page onto custom category template: <?php $page = get_page_by_title( 'page-name' ); $content = apply_filters('the_content', $page->post_content); echo $content; ?> With the above code, the content is being pulled, but the formatting and styling is not being pulled. The following code is adapted to pull the styling/formatting: <?php $page = get_page_by_title( 'Wedding Venues in Costa Rica' ); $content = apply_filters('the_content', $page->post_content); echo do_blocks( $content );> It did not pull the styling/formatting. We’re using GeneratePress Pro + Generate Blocks (no page builder). The static page is built with Gutenberg and GenerateBlocks. By the way, I'mm not a coder or a developer. I know a little about this and about that, but this isn't my field of expertise. Could someone please suggest what can be done to this code to get it to pull the styling form the static page onto the custom category template? Thank you very much. Hi all, Is there a simple way to log the command output of a linux console? This command locks up my screen. It is a screen on an Aastra IP phone. $command = 'logsave /var/www/html/aastra/test.log ls'; shell_exec($command); Thanks! Hey folks, I have made a cart for buying drinks. I also made an sql database. But when I click on the email button, I receive an email but only with the id of the products. I would like to have an output with the id of the product, but also the name of the product ( the name of the column in sql is also 'name') this is my code and you can check it out on http://fhcs.be/cart-demo3/ thanks in advance cart.php <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); // Start the session session_start(); // Process actions $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; case 'update': if ($cart) { $newcart = ''; foreach ($_POST as $key=>$value) { if (stristr($key,'qty')) { $id = str_replace('qty','',$key); $items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } for ($i=1;$i<=$value;$i++) { if ($newcart != '') { $newcart .= ','.$id; } else { $newcart = $id; } } } } } $cart = $newcart; break; } $_SESSION['cart'] = $cart; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>PHP Shopping Cart Demo &#0183; Cart</title> <link rel="stylesheet" href="css/styles.css" /> </head> <body> <div id="shoppingcart"> <h1>Your Shopping Cart</h1> <?php echo writeShoppingCart(); ?> </div> <div id="contents"> <h1>Please check quantities...</h1> <?php echo showCart(); ?> <p><a href="index.php">Back to bookshop...</a></p> <form action="mail.php" method="post"> <input type="submit" name="sendemail" value="Email" /> <input type="hidden" name="cart" value="<?= $cart; ?>" /> </form> </div> </body> </html> mail.php <?php session_start(); if($_POST['sendemail'] == 'Email') { $headers = 'From: Sender <andrej13@gmail.com>'; mail('andrej13@gmail.com', 'Subject', $_SESSION["cart"] , $headers); echo 'Your mail has been sent'; } else { echo 'message not sent'; } ?> and the functions.php <?php function writeShoppingCart() { $cart = $_SESSION['cart']; if (!$cart) { return '<p>You have no items in your shopping cart</p>'; } else { // Parse the cart session variable $items = explode(',',$cart); $s = (count($items) > 1) ? 's':''; return '<p>You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a></p>'; } } function showCart() { global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="cart.php?action=update" method="post" id="cart">'; $output[] = '<table>'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr>'; $output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>'; $output[] = '<td>'.$name.'</td>'; $output[] = '<td>€'.$price.'</td>'; $output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; $output[] = '<td>€'.($price * $qty).'</td>'; $total += $price * $qty; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<p>Grand total: <strong>€'.$total.'</strong></p>'; $output[] = '<div><button type="submit">Update cart</button></div>'; $output[] = '</form>'; } else { $output[] = '<p>You shopping cart is empty.</p>'; } return join('',$output); } ?> I don't have any output after I push the button :s I dont know how http://fhcs.be/index3.php Code: [Select] <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions session_start(); ?> <?php if (!isset($_POST['submit'])) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <form method="post" action="<?php echo $PHP_SELF; ?>"> <input type="submit" value="Toon Output" name="submit"/> <?php $dranken=array() ; $DrinkResult=mysql_query("SELECT name,price FROM products")or die(mysql_error()); while($DrinkRow=mysql_fetch_assoc($DrinkResult)){ $dranken[] = $DrinkRow; } echo "<table>"; foreach ($dranken as $DrinkRow) { $optionlist = "<select name='{$DrinkRow['name']}_aantal'>"; for ($i=0;$i<10;++$i) { $optionlist .= "<option value='$i'>$i</option>"; } $optionlist .= "</select>"; echo "<tr><td>".$DrinkRow['name']." ".$DrinkRow['price']."</td>\n"; echo "<td>$optionlist</td></tr>\n"; } echo "</table>"; ?> </form> <?php } $dranken=array() ; $DrinkResult=mysql_query("SELECT name,price FROM products")or die(mysql_error()); while($DrinkRow=mysql_fetch_assoc($DrinkResult)){ $dranken[] = $DrinkRow; } echo "<table>"; $totaalPrijs = 0; foreach ($dranken as $DrinkRow) { $aantal = $_POST[$DrinkRow['name'] . "_aantal"]; if ($aantal > 0) { $prijsperDrank = $aantal * $DrinkRow['price']; echo $DrinkRow['name'] . " : " . $aantal . " Prijs: " . $prijsperDrank . "</br>"; $totaalPrijs=$totaalPrijs + $prijsperDrank; } } if($totaalPrijs>0){ echo " totaal: " .$totaalPrijs;} ?> </html> How do I got about outputing one row that can only hold one value? Any reason why the function below doesn't work? Code: [Select] <?php include "database.php"; session_start(); $name = $_session['outname']; function output_wins(){ $sql = 'SELECT * FROM account_info WHERE username ="' . $name .'"'; $result = mysql_query($sql); $wins = mysql_fetch_array($result); echo $wins['win']; } output_wins(); ?> Is there an easier way I can output this one row? hello guys..!!! am new to this phpfreak community...i hav faced some problem while getting on floating point nos addition..if i use echo (int)((0.1+0.7))*10; i am getting output as 7. If i remove (int), i would get output as 8..which is correct... for any other possibilities like ((0.1+0.2))*10 am getting correct output as 3..pls guys help me on this wid proper reason....waiting for solution.... Hi. I found a code online but unfortunately, the data is retrieved via variables. How can i convert this code to retrieve the data from database instead. Thank you in ADVANCE! Code: [Select] var members = [ ['Steven B. Ayres', '1911-1913', 'New York', 'Independent Democrat', '1861-1929'], ['William Augustus Ayres', '1915-1921 1923-1934', 'Kansas', 'Democratic', '1867-1952'], ['William Hanes Ayres', '1951-1971', 'Ohio', 'Republican', '1916-2000'] ]; Hello. I'm looking for some help to make a script. The script should run a .bat file, and get the output from it. (The text from the console). Regards Worqy I'm not getting any errors but I"m not getting the output I'm expecting. When it gets the characterIDList values if there is a value for that field it needs to take that value then explode it and get the ID and characterName of each of the values so say the value inside of characterIDList was 2,3 then for each of those values it would find the characterName and ID of the value and be able to put each of them as a LI inside the UL. I was hoping I could have the charactersQuery separate because I use it for the dropdown. Code: [Select] $newsQuery = " SELECT news.categoryID, news.newsTitle, news.newsPicture, news.content, news.characterIDList FROM news LEFT JOIN categories ON news.categoryID = categories.ID WHERE news.ID = '" . $newsID . "'"; $newsResult = mysqli_query ( $dbc, $newsQuery ); // Run The Query echo $newsQuery; $row = mysqli_fetch_array ( $newsResult, MYSQL_ASSOC ); $characterIDList = $row[ 'chracterIDList' ]; $characterIDList = explode(',', $characterIDList); foreach($characterIDList as $value){ $charactersQuery = " SELECT ID, characterName FROM characters ORDER BY characters.characterName"; $charactersResult = mysqli_query ( $dbc, $charactersQuery ); // Run The Query } Code: [Select] <div class="field required"> <label for="charactersDrop">Characters Involved</label> <ul id="characterList" style="list-style: none; margin-left: 195px;"> <?php mysqli_data_seek( $charactersResult, 0 ); while($row = mysqli_fetch_array ( $newsResult, MYSQL_ASSOC )) { if ($row['characterName'] == NULL ) { } else { ?> <li characterID="<?php echo $row['ID']; ?>" characterName="<?php echo htmlentities( $row['characterName'] ); ?>"><?php echo htmlentities($row['characterName']); ?> <a href="#">Remove</a></li> <?php }} ?> </ul> <select class="dropdown" name="charactersDrop" id="charactersDrop" title="Characters Dropdown" style="margin-left: 195px;"> <option value="">- Select -</option> <?php mysqli_data_seek( $charactersResult, 0 ); while ( $row = mysqli_fetch_array ( $charactersResult, MYSQL_ASSOC ) ) { print "<option value=\"".$row['ID']."\">".$row['characterName']."</option>\r"; } ?> </select> <input type="button" value="Add Character" class="" onclick="CharactersInvolved()"/> </div> Hi, This script lists all the contents of the dir it is placed in bar itself. Perfect for what I need. However, I want to output the results as xml and being new to php I really don't know where to start. <?php foreach (new DirectoryIterator('.') as $file) { if ( (!$file->isDot()) && ($file->getFilename() != basename($_SERVER['PHP_SELF'])) ) { echo ($file->isDir()) ? "(Dir) ".$file->getFilename() : $file->getFilename(); } } ?> I'd be thankful for the help Thanks in advance. help me. i have an index.php file in admin folder. this is the code inside the file: Code: [Select] <?php ?> Or any other code and i get output 0 , but if i echo something else then i get the string has output, help find out what is the problam please!!! |