PHP - How To Run Php In A Html File?
i am new to php, but i have written a php code for a login, basically i have my index html page separate, so when i put it on the server, when i press log in, it takes me to another blank page, with written either saying your logged in, or incorrect password, so this proves my php code works.
But what i want is the writing to be displayed on my html file. Could I run the php code on the html file with the two files being separate? or do i have to insert the php code in the html file? or other way around? (but when i do this, it ruins my html file and things below just disappear. What I already know: that I have to edit the .htacess file and include a line of code would appreciate ur help, thank you. Similar TutorialsHi
I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems.
1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that?
for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; }I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } }If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=359179.0 Hey guys, I'm a total newbie here, and just about as a new to php. My issue: I have a very large .html file that contain multiple articles (I actually have a few of these, but we'll start with one for practicality). The article titles are all wrapped in <h2> tags, there are 10 articles in one file. The articles are very simple, just a title wrapped with <h2> and then a few paragraphs wrapped in <p> tags. What I want to know how to do: I want to know if there's a way to open that file, and have each article saved as it's own .html or .txt document (the title & following paragraphs of each article). Ultimately taking my 1 large file, and creating the subsequent 10 smaller files from the articles inside of it. I am having trouble explaining this in text so I'll try to illustrate: I have "Articles.html" - which contains (article1,article2,article3.. ..article10) I want to split "Articles.html" and create "Article1.html", "Article2.html", "Article3.html", etc. Is that possible? Or am I looking at something far more complex than I can imagine at this point - perhaps something I'd be better off doing by hand? Ultimately I intend to stick all these articles into a database, but that's the 2nd part of what I want to do (and I think will be the easier of the tasks). Let me know if you need any additional information in the event my description above is unclear... I simply am having issues figuring out how to separate out the text into individual articles. Hi, How do I open all HTML file contained in a folder, then search for the title of the page, and save the title in the database? Also, is it possible to do this using functions? Cheers. I have a file ("header.html") that predominately has HTML in it. This may sound silly, but I would like to rename it as a .php file so that when I add comments next to my PHP, my IDE will shade them gray. I just changed all of my PHP comments from // Some PHP comment to <!-- New and Improved PHP comment --> only to realize that PHP freaks out and doesn't treat them as comments - like NetBeans falsely does - but treats them as erroneous code. (Now I have to go back and fix all of my files back to the way they were?!) If I could change my file from "header.html" to "header.php" then all of my // Comments would be grayed out in my PHP blocks and make my code easier to read. To achieve that end, is it okay to rename a file from .html to .php even if most of the content is HTML and only a little is PHP? (BTW, could you have a file that has 100% html content saved as a .php file and still have it work properly?!) Thanks, TomTees I am trying to figure out how we can run a html file within a php script. Hi guys, Sorry if this is too dumb, I'm a student yet .. I have: $newEmail = preg_replace($patterns, $replacements, $email); How can I save $newEmail contents into an html file? Thanks a lot!! Let me apologize in advance for what may seem like a very stupid question for most of you. I am very new to php. I am simply trying to view/html in a .PHP file using Alleycode text editor. When I download the file from the server to my local PC, open the file in Alleycode, I cannot see the HTML. All that I see is the PHP code. Can someone provide me with instruction on how I might view then edit the HTML? Here is the code from Alleycode: <?php /*******************************************************************\ * CashbackEngine v1.1 * http://www.CashbackEngine.net * * Copyright (c) 2010 CashbackEngine Software. All rights reserved. * ------------ CashbackEngine IS NOT FREE SOFTWARE -------------- \*******************************************************************/ session_start(); require_once("inc/config.inc.php"); require_once("inc/pagination.inc.php"); $results_per_page = RESULTS_PER_PAGE; $cc = 0; function getCategory($category_id, $description = 0) { if (isset($category_id) && is_numeric($category_id) && $category_id != 0) { $query = "SELECT name, description FROM cashbackengine_categories WHERE category_id='".(int)$category_id."'"; $result = smart_mysql_query($query); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); if ($description == 1) return $row['description']; else return $row['name']; }else { return "Category not found"; } } else { if ($description != 1) return "Retailers"; } } ////////////////// filter ////////////////////// if (isset($_GET['column']) && $_GET['column'] != "") { switch ($_GET['column']) { case "title": $rrorder = "title"; break; case "added": $rrorder = "added"; break; case "visits": $rrorder = "visits"; break; case "cashback": $rrorder = "cashback"; break; default: $rrorder = "title"; break; } } else { $rrorder = "title"; } if (isset($_GET['order']) && $_GET['order'] != "") { switch ($_GET['order']) { case "asc": $rorder = "asc"; break; case "desc": $rorder = "desc"; break; default: $rorder = "asc"; break; } } else { $rorder = "asc"; } ////////////////////////////////////////////////// if (isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0) { $page = (int)$_GET['page']; } else { $page = 1; } $from = ($page-1)*$results_per_page; $where = ""; if (isset($_GET['cat']) && is_numeric($_GET['cat']) && $_GET['cat'] > 0) { $cat_id = (int)$_GET['cat']; unset($retailers_per_category); $retailers_per_category = array(); $retailers_per_category[] = "111111111111111111111"; $sql_retailers_per_category = smart_mysql_query("SELECT retailer_id FROM cashbackengine_retailer_to_category WHERE category_id='$cat_id'"); while ($row_retailers_per_category = mysql_fetch_array($sql_retailers_per_category)) { $retailers_per_category[] = $row_retailers_per_category['retailer_id']; } $where .= "retailer_id IN (".implode(",",$retailers_per_category).") AND"; } if (isset($_GET['letter']) && in_array($_GET['letter'], $alphabet)) { $ltr = mysql_real_escape_string(getGetParameter('letter')); if ($ltr == "0-9") { $where .= " title REGEXP '^[0-9]' AND"; }else{ $ltr = substr($ltr, 0, 1); $where .= " UPPER(title) LIKE '$ltr%' AND"; } } $where .= " status='active'"; if ($rrorder == "cashback") $query = "SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY ABS(cashback) $rorder LIMIT $from, $results_per_page"; else $query = "SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY $rrorder $rorder LIMIT $from, $results_per_page"; $total_result = smart_mysql_query("SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY title ASC"); $total = mysql_num_rows($total_result); $result = smart_mysql_query($query); $total_on_page = mysql_num_rows($result); /////////////// Page config /////////////// $PAGE_TITLE = getCategory($_GET['cat']); require_once ("inc/header.inc.php"); ?> <h1><?php echo getCategory($_GET['cat']); ?></h1> <?php if ($total > 0) { ?> <p class="category_description"><?php echo getCategory($_GET['cat'], 1); ?></p> <div id="alphabet"> <ul> <li><a href="/retailers.php">All</a></li> <?php $numLetters = count($alphabet); $i = 0; foreach ($alphabet as $letter) { $i++; if ($i == $numLetters) $lilast = ' class="last"'; else $lilast = ''; if (isset($cat_id) && is_numeric($cat_id)) echo "<li".$lilast."><a href=\"/retailers.php?cat=$cat_id&letter=$letter\">$letter</a></li>"; else echo "<li".$lilast."><a href=\"/retailers.php?letter=$letter\">$letter</a></li>"; } ?> </ul> </div> <div class="browse_top"> <div class="sortby"> <form action="retailers.php" id="form1" name="form1" method="get"> <span>Sort by:</span> <select name="column" id="column" onChange="document.form1.submit()"> <option value="title" <?php if ($_GET['column'] == "title") echo "selected"; ?>>Name</option> <option value="visits" <?php if ($_GET['column'] == "visits") echo "selected"; ?>>Popular</option> <option value="added" <?php if ($_GET['column'] == "added") echo "selected"; ?>>Newest</option> <option value="cashback" <?php if ($_GET['column'] == "cashback") echo "selected"; ?>>Cashback</option> </select> <select name="order" id="order" onChange="document.form1.submit()"> <option value="desc"<?php if ($_GET['order'] == "desc") echo "selected"; ?>>Descending</option> <option value="asc" <?php if ($_GET['order'] == "asc") echo "selected"; ?>>Ascending</option> </select> <?php if ($cat_id) { ?><input type="hidden" name="cat" value="<?php echo $cat_id; ?>" /><?php } ?> <?php if ($ltr) { ?><input type="hidden" name="letter" value="<?php echo $ltr; ?>" /><?php } ?> <input type="hidden" name="page" value="<?php echo $page; ?>" /> </form> </div> <div class="results"> Showing <?php echo ($from + 1); ?> - <?php echo min($from + $total_on_page, $total); ?> of <?php echo $total; ?> </div> </div> <table align="center" width="100%" border="0" cellspacing="0" cellpadding="5"> <?php while ($row = mysql_fetch_array($result)) { $cc++; ?> <tr class="<?php if (($cc%2) == 0) echo "even"; else echo "odd"; ?>"> <td width="125" align="center" valign="middle"> <?php if ($row['featured'] == 1) { ?><span class="featured" alt="Featured Retailer" title="Featured Retailer"></span><?php } ?> <div id="shadow"><a href="/view_retailer.php?rid=<?php echo $row['retailer_id']; ?>"><img src="<?php if (!stristr($row['image'], 'http')) echo "/img/"; echo $row['image']; ?>" width="<?php echo IMAGE_WIDTH; ?>" height="<?php echo IMAGE_HEIGHT; ?>" alt="<?php echo $row['title']; ?>" title="<?php echo $row['title']; ?>" border="0" class="imgs" /></a></div> </td> <td align="left" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="80%" align="left" valign="top"> <a class="retailer_title" href="/view_retailer.php?rid=<?php echo $row['retailer_id']; ?>"><?php echo $row['title']; ?></a> </td> <td nowrap="nowrap" width="20%" align="right" valign="top"> <span class="cashback"><?php echo DisplayCashback($row['cashback']); ?>X Points</span> </td> </tr> <tr> <td colspan="2" valign="middle" align="left"><p class="retailer_description"><?php echo $row['description']; ?> </p></td> </tr> <tr> <td valign="middle" align="left"> <?php if ($row['conditions'] != "") { ?> <div class="cashbackengine_tooltip"> <a class="conditions" href="#">Conditions</a> <span class="tooltip"><?php echo $row['conditions']; ?></span> </div> <?php } ?> <a class="favorites" href="#" onclick="if (confirm('Are you sure you want to add this retailer to your favorites?') )location.href='/myfavorites.php?act=add&rid=<?php echo $row['retailer_id']; ?>'">Add to Favorites</a> </td> <td valign="middle" align="right"> <a class="go2store" href="/go2store.php?id=<?php echo $row['retailer_id']; ?>" target="_blank">Go to Store</a> </td> </tr> </table> </td> </tr> <?php } ?> <tr> <td valign="middle" align="center" colspan="2"> <?php $params = ""; if (isset($cat_id) && $cat_id > 0) { $params = "cat=$cat_id&"; } if (isset($ltr) && $ltr != "") { $params = "letter=$ltr&"; } echo ShowPagination("retailers",$results_per_page,"retailers.php?".$params."column=$rrorder&order=$rorder&","WHERE ".$where); ?> </td> </tr> </table> <?php }else{ ?> <p align="center">There are no stores to list in this category!<br/><br/><a class="goback" href="#" onclick="history.go(-1);return false;">Go Back</a></p> <?php } ?> <?php require_once ("inc/footer.inc.php"); ?> Here is the code from the browser (View Source) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Retailers | Bonus.me</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="text/css" href="/css/style.css" /> <script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="/js/jquery.autocomplete.js"></script> <script type="text/javascript" src="/js/cashbackengine.js"></script> <link rel="shortcut icon" href="/favicon.ico" /> <link rel="icon" type="image/ico" href="/favicon.ico" /> </head> <body> <div id="container"> <div id="header"> <div id="logo"><a href="http://www.bonus.me/"><img src="/images/LogoSiteFinal.png" alt="Bonus.me" title="Bonus.me" border="0" /></a></div> <div id="links"> <a href="/login.php">Log In</a> | <a href="/register.php">Sign Up</a> </div> <div id="searchbox"> <form action="search.php" method="get" id="searchfrm" name="searchfrm"> <input type="text" id="searchtext" name="searchtext" class="search_inputt" value="Search for stores..." onclick="if (this.defaultValue==this.value) this.value=''" onkeydown="this.style.color='#000000'" onblur="if (this.value=='') this.value=this.defaultValue" /> <input type="hidden" name="action" value="search" /> <input type="submit" class="search_button" value="" /> </form> </div> </div> <div id="menu"> <a href="/">Home</a> <a href="/retailers.php">Online Shopping</a> <a href="/instore.php">In Store Shopping</a> <a href="/myaccount.php">My Account</a> <a href="/withdraw.php">My Rewards</a> <a href="/invite.php">Get More</a> <a href="/benny.php">Benny</a> </div> <div id="column_left"> <div class="box"> <div class="top">Member Login</div> <div class="middle"> <form action="login.php" method="post"> Email Address:<br/> <input type="text" class="inputt" name="username" value="" size="22" /> Password:<br/> <input type="password" class="inputt" name="password" value="" size="22" /> <input type="hidden" name="action" value="login" /> <input type="submit" class="butt" style="margin-top: 2px;" name="login" id="login" value="Login" /> <br/><br/><a href="/forgot.php">Forgot your password?</a> <br/><br/>Not a Member? <a href="/register.php">Sign Up!</a> </form> </div> <div class="bottom"> </div> </div> <div class="box"> <div class="top">Shop by Category</div> <div class="middle"> <ul id="categories"> <li><a href="/retailers.php">All Stores</a></li> <ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=41">Art, Music & Photo</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=40">Automotive</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=1">Books & Magazines</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=38">Department & Discount</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=6">Education</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=7">Electronics & Computers</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=2">Fashion & Apparel</a></li></ul><ul style='padding-left:10px;margin:0;'><li><a href="/retailers.php?cat=36">Children's Fashion</a></li></ul><ul style='padding-left:10px;margin:0;'><li><a href="/retailers.php?cat=35">Men's Fashions</a></li></ul><ul style='padding-left:10px;margin:0;'><li><a href="/retailers.php?cat=42">Shoes</a></li></ul><ul style='padding-left:10px;margin:0;'><li><a href="/retailers.php?cat=34">Women's Fashion</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=9">Flowers</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=10">Food & Drink</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=12">Gifts & Party</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=13">Health & Beauty</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=14">Home & Garden</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=16">Jewelry</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=17">Mobile Phones & Accesories</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=19">Office</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=22">Pets</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=39">Recreation & Leisure</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=15">Software</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=23">Sports & Fitness</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=24">Toys & Games</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=37">Travel</a></li></ul> </ul> </div> <div class="bottom"> </div> </div> </div> <div id="column_center"> <h1>Retailers</h1> <p class="category_description"></p> <div id="alphabet"> <ul> <li><a href="/retailers.php">All</a></li> <li><a href="/retailers.php?letter=0-9">0-9</a></li><li><a href="/retailers.php?letter=A">A</a></li><li><a href="/retailers.php?letter=B">B</a></li><li><a href="/retailers.php?letter=C">C</a></li><li><a href="/retailers.php?letter=D">D</a></li><li><a href="/retailers.php?letter=E">E</a></li><li><a href="/retailers.php?letter=F">F</a></li><li><a href="/retailers.php?letter=G">G</a></li><li><a href="/retailers.php?letter=H">H</a></li><li><a href="/retailers.php?letter=I">I</a></li><li><a href="/retailers.php?letter=J">J</a></li><li><a href="/retailers.php?letter=K">K</a></li><li><a href="/retailers.php?letter=L">L</a></li><li><a href="/retailers.php?letter=M">M</a></li><li><a href="/retailers.php?letter=N">N</a></li><li><a href="/retailers.php?letter=O">O</a></li><li><a href="/retailers.php?letter=P">P</a></li><li><a href="/retailers.php?letter=Q">Q</a></li><li><a href="/retailers.php?letter=R">R</a></li><li><a href="/retailers.php?letter=S">S</a></li><li><a href="/retailers.php?letter=T">T</a></li><li><a href="/retailers.php?letter=U">U</a></li><li><a href="/retailers.php?letter=V">V</a></li><li><a href="/retailers.php?letter=W">W</a></li><li><a href="/retailers.php?letter=X">X</a></li><li><a href="/retailers.php?letter=Y">Y</a></li><li class="last"><a href="/retailers.php?letter=Z">Z</a></li> </ul> </div> <div class="browse_top"> <div class="sortby"> <form action="retailers.php" id="form1" name="form1" method="get"> <span>Sort by:</span> <select name="column" id="column" onChange="document.form1.submit()"> <option value="title" >Name</option> <option value="visits" >Popular</option> <option value="added" >Newest</option> <option value="cashback" >Cashback</option> </select> <select name="order" id="order" onChange="document.form1.submit()"> <option value="desc">Descending</option> <option value="asc" >Ascending</option> </select> <input type="hidden" name="page" value="1" /> </form> </div> <div class="results"> Showing 1 - 2 of 2 </div> </div> <table align="center" width="100%" border="0" cellspacing="0" cellpadding="5"> <tr class="odd"> <td width="125" align="center" valign="middle"> <div id="shadow"><a href="/view_retailer.php?rid=13"><img src="<a href="http://click.linksynergy.com/fs-bin/click?id=8jghEyj/xMI&offerid=226353.10000004&subid=0&type=4"><IMG border="0" alt="Fanzz General Banner 120x90" src="http://ad.linksynergy.com/fs-bin/show?id=8jghEyj/xMI&bids=226353.10000004&subid=0&type=4&gri" width="120" height="60" alt="Fanzz.com" title="Fanzz.com" border="0" class="imgs" /></a></div> </td> <td align="left" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="80%" align="left" valign="top"> <a class="retailer_title" href="/view_retailer.php?rid=13">Fanzz.com</a> </td> <td nowrap="nowrap" width="20%" align="right" valign="top"> <span class="cashback">7X Points</span> </td> </tr> <tr> <td colspan="2" valign="middle" align="left"><p class="retailer_description">Fanzz.com sells licensed sports apparel and gifts from the NFL, NBA, MLB, NCAA, NHL, MLS, NASCAR and WNBA. We have dozens of top brands on our site including Nike, Adidas, Reebok, New Era, Antigua, Baseline, Fathead, Fanmats, Majestic, Mitchell and Ness, Under Armour, Wilson, Wincraft and many more. </p></td> </tr> <tr> <td valign="middle" align="left"> <a class="favorites" href="#" onclick="if (confirm('Are you sure you want to add this retailer to your favorites?') )location.href='/myfavorites.php?act=add&rid=13'">Add to Favorites</a> </td> <td valign="middle" align="right"> <a class="go2store" href="/go2store.php?id=13" target="_blank">Go to Store</a> </td> </tr> </table> </td> </tr> <tr class="even"> <td width="125" align="center" valign="middle"> <div id="shadow"><a href="/view_retailer.php?rid=14"><img src="http://www.ftjcfx.com/image-5471697-10807939" width="120" height="60" alt="Pets Warehouse" title="Pets Warehouse" border="0" class="imgs" /></a></div> </td> <td align="left" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="80%" align="left" valign="top"> <a class="retailer_title" href="/view_retailer.php?rid=14">Pets Warehouse</a> </td> <td nowrap="nowrap" width="20%" align="right" valign="top"> <span class="cashback">9X Points</span> </td> </tr> <tr> <td colspan="2" valign="middle" align="left"><p class="retailer_description">Founded in 1974 Pets Warehouse® provides the broadest selection of pet supplies available anywhere online, add value to your site and benefit your customers with low prices. </p></td> </tr> <tr> <td valign="middle" align="left"> <a class="favorites" href="#" onclick="if (confirm('Are you sure you want to add this retailer to your favorites?') )location.href='/myfavorites.php?act=add&rid=14'">Add to Favorites</a> </td> <td valign="middle" align="right"> <a class="go2store" href="/go2store.php?id=14" target="_blank">Go to Store</a> </td> </tr> </table> </td> </tr> <tr> <td valign="middle" align="center" colspan="2"> </td> </tr> </table> </div> <div id="column_right"> <div class="center"> <p align="center"> <a href="/invite.php"><img src="/images/ReferAFriend.gif" border="0"></a></br> <a href="/invite.php">Refer A Friend<br/>And Get More!</a> </p> </div> </div> <div id="footer"> <a href="/terms.php">Terms & Conditions</a> · <a href="/contact.php">Contact Us</a> · <a href="/help.php">FAQs</a> <p>© December, 2011. Bonus.Me. All rights reserved.</p> </div> </div> </body> </html> $results_per_page = RESULTS_PER_PAGE; $cc = 0; function getCategory($category_id, $description = 0) { if (isset($category_id) && is_numeric($category_id) && $category_id != 0) { $query = "SELECT name, description FROM cashbackengine_categories WHERE category_id='".(int)$category_id."'"; $result = smart_mysql_query($query); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); if ($description == 1) return $row['description']; else return $row['name']; }else { return "Category not found"; } } else { if ($description != 1) return "Retailers"; } } ////////////////// filter ////////////////////// if (isset($_GET['column']) && $_GET['column'] != "") { switch ($_GET['column']) { case "title": $rrorder = "title"; break; case "added": $rrorder = "added"; break; case "visits": $rrorder = "visits"; break; case "cashback": $rrorder = "cashback"; break; default: $rrorder = "title"; break; } } else { $rrorder = "title"; } if (isset($_GET['order']) && $_GET['order'] != "") { switch ($_GET['order']) { case "asc": $rorder = "asc"; break; case "desc": $rorder = "desc"; break; default: $rorder = "asc"; break; } } else { $rorder = "asc"; } ////////////////////////////////////////////////// if (isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0) { $page = (int)$_GET['page']; } else { $page = 1; } $from = ($page-1)*$results_per_page; $where = ""; if (isset($_GET['cat']) && is_numeric($_GET['cat']) && $_GET['cat'] > 0) { $cat_id = (int)$_GET['cat']; unset($retailers_per_category); $retailers_per_category = array(); $retailers_per_category[] = "111111111111111111111"; $sql_retailers_per_category = smart_mysql_query("SELECT retailer_id FROM cashbackengine_retailer_to_category WHERE category_id='$cat_id'"); while ($row_retailers_per_category = mysql_fetch_array($sql_retailers_per_category)) { $retailers_per_category[] = $row_retailers_per_category['retailer_id']; } $where .= "retailer_id IN (".implode(",",$retailers_per_category).") AND"; } if (isset($_GET['letter']) && in_array($_GET['letter'], $alphabet)) { $ltr = mysql_real_escape_string(getGetParameter('letter')); if ($ltr == "0-9") { $where .= " title REGEXP '^[0-9]' AND"; }else{ $ltr = substr($ltr, 0, 1); $where .= " UPPER(title) LIKE '$ltr%' AND"; } } $where .= " status='active'"; if ($rrorder == "cashback") $query = "SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY ABS(cashback) $rorder LIMIT $from, $results_per_page"; else $query = "SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY $rrorder $rorder LIMIT $from, $results_per_page"; $total_result = smart_mysql_query("SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY title ASC"); $total = mysql_num_rows($total_result); $result = smart_mysql_query($query); $total_on_page = mysql_num_rows($result); /////////////// Page config /////////////// $PAGE_TITLE = getCategory($_GET['cat']); require_once ("inc/header.inc.php"); ?> <h1><?php echo getCategory($_GET['cat']); ?></h1> <?php if ($total > 0) { ?> <p class="category_description"><?php echo getCategory($_GET['cat'], 1); ?></p> <div id="alphabet"> <ul> <li><a href="/retailers.php">All</a></li> <?php $numLetters = count($alphabet); $i = 0; foreach ($alphabet as $letter) { $i++; if ($i == $numLetters) $lilast = ' class="last"'; else $lilast = ''; if (isset($cat_id) && is_numeric($cat_id)) echo "<li".$lilast."><a href=\"/retailers.php?cat=$cat_id&letter=$letter\">$letter</a></li>"; else echo "<li".$lilast."><a href=\"/retailers.php?letter=$letter\">$letter</a></li>"; } ?> </ul> </div> <div class="browse_top"> <div class="sortby"> <form action="retailers.php" id="form1" name="form1" method="get"> <span>Sort by:</span> <select name="column" id="column" onChange="document.form1.submit()"> <option value="title" <?php if ($_GET['column'] == "title") echo "selected"; ?>>Name</option> <option value="visits" <?php if ($_GET['column'] == "visits") echo "selected"; ?>>Popular</option> <option value="added" <?php if ($_GET['column'] == "added") echo "selected"; ?>>Newest</option> <option value="cashback" <?php if ($_GET['column'] == "cashback") echo "selected"; ?>>Cashback</option> </select> <select name="order" id="order" onChange="document.form1.submit()"> <option value="desc"<?php if ($_GET['order'] == "desc") echo "selected"; ?>>Descending</option> <option value="asc" <?php if ($_GET['order'] == "asc") echo "selected"; ?>>Ascending</option> </select> <?php if ($cat_id) { ?><input type="hidden" name="cat" value="<?php echo $cat_id; ?>" /><?php } ?> <?php if ($ltr) { ?><input type="hidden" name="letter" value="<?php echo $ltr; ?>" /><?php } ?> <input type="hidden" name="page" value="<?php echo $page; ?>" /> </form> </div> <div class="results"> Showing <?php echo ($from + 1); ?> - <?php echo min($from + $total_on_page, $total); ?> of <?php echo $total; ?> </div> </div> <table align="center" width="100%" border="0" cellspacing="0" cellpadding="5"> <?php while ($row = mysql_fetch_array($result)) { $cc++; ?> <tr class="<?php if (($cc%2) == 0) echo "even"; else echo "odd"; ?>"> <td width="125" align="center" valign="middle"> <?php if ($row['featured'] == 1) { ?><span class="featured" alt="Featured Retailer" title="Featured Retailer"></span><?php } ?> <div id="shadow"><a href="/view_retailer.php?rid=<?php echo $row['retailer_id']; ?>"><img src="<?php if (!stristr($row['image'], 'http')) echo "/img/"; echo $row['image']; ?>" width="<?php echo IMAGE_WIDTH; ?>" height="<?php echo IMAGE_HEIGHT; ?>" alt="<?php echo $row['title']; ?>" title="<?php echo $row['title']; ?>" border="0" class="imgs" /></a></div> </td> <td align="left" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="80%" align="left" valign="top"> <a class="retailer_title" href="/view_retailer.php?rid=<?php echo $row['retailer_id']; ?>"><?php echo $row['title']; ?></a> </td> <td nowrap="nowrap" width="20%" align="right" valign="top"> <span class="cashback"><?php echo DisplayCashback($row['cashback']); ?>X Points</span> </td> </tr> <tr> <td colspan="2" valign="middle" align="left"><p class="retailer_description"><?php echo $row['description']; ?> </p></td> </tr> <tr> <td valign="middle" align="left"> <?php if ($row['conditions'] != "") { ?> <div class="cashbackengine_tooltip"> <a class="conditions" href="#">Conditions</a> <span class="tooltip"><?php echo $row['conditions']; ?></span> </div> <?php } ?> <a class="favorites" href="#" onclick="if (confirm('Are you sure you want to add this retailer to your favorites?') )location.href='/myfavorites.php?act=add&rid=<?php echo $row['retailer_id']; ?>'">Add to Favorites</a> </td> <td valign="middle" align="right"> <a class="go2store" href="/go2store.php?id=<?php echo $row['retailer_id']; ?>" target="_blank">Go to Store</a> </td> </tr> </table> </td> </tr> <?php } ?> <tr> <td valign="middle" align="center" colspan="2"> <?php $params = ""; if (isset($cat_id) && $cat_id > 0) { $params = "cat=$cat_id&"; } if (isset($ltr) && $ltr != "") { $params = "letter=$ltr&"; } &nbs guys i want to to create a html invoice to pdf file how can i do that ...by using which library...can any one help me out? I am having a rtf file, now i want to convert that rtf file to html version with same alignment, to be display in the web page. Kindly give some example in php. I am trying to make PHP output a file in html and using the following code. Code: [Select] <?php readfile("./1/index.html"); ?> ... but it isn't working. How would I get PHP to output a file as HTML? Hi there, its possible to something like this. <?php $i=0; $MW_Services ="aaaa.php"; $fh_MW_Services = fopen($MW_Services, 'w') or die("can't open file"); $string_MW_Services = "<html><head> </script><span style='padding-left:5px'> MW Services </head> <body> <table> <tr> <td>Teste</td> <td BACKGROUND='images/da.JPG'></td> <td></td> <td><?php for($i;$i>2;$i++){print $i;} ?> </td> </tr> </table> </body>"; fwrite($fh_MW_Services, $string_MW_Services); fclose($fh_MW_Services); ?> my problem is that the code doesnt do the cicle for it only. Tanks I need to convert the following table and graph to PDF when button is clicked. Please help I am using fusion charts and generated graph will be swf file // Table and graph for all students if(isset($_POST['ReportAll'])){ $strQuery = ("SELECT registration_number,SUM(Fine) AS Total_Fine FROM lended_book_cd GROUP BY registration_number"); $result=mysql_query($strQuery); if (!$result){ Error (mysql_error()) ; } if (mysql_num_rows($result)!==0){ $table=1; echo $input_table; echo "<center>Fine report for All Students </center>"; echo "<br>"; echo "<table border='2' align='center'>"; echo("<tr>"); for($i=0;$i<mysql_num_fields($result);$i++){ echo("<th>".mysql_field_name($result,$i)."</th>"); } while($data=mysql_fetch_array($result)){ echo("<tr>"); for($i=0;$i<mysql_num_fields($result);$i++){ echo("<td>".$data[$i]."</td>"); } } echo "</table>"; } else{ Info ("No Fine Reports found for Student $_POST[regnum]"); } $strQuery = ("SELECT registration_number,SUM(Fine) AS Total_Fine FROM lended_book_cd GROUP BY registration_number"); //Where lended_book_cd.registration_number = students.registration_number $result=mysql_query($strQuery); $strXML = "<graph caption='Fine report for All Students' showLabels='1' xAxisName='Student Registration Number' yAxisName='Fine Value' showNames='1' showValues='1' useRoundEdges='1' palette='3'>"; while($ors = mysql_fetch_array($result)) { // Append the names of the countries and their respective populations to the chart's XML string. $strXML .= "<set name='$ors[registration_number]' value='$ors[Total_Fine]' />"; } $strXML .= "</graph>"; echo renderChart('charts/FCF_Column2D.swf', // Path to chart type '', // Empty string when using Data String Method $strXML, // Variable that contains XML string 'chart1Id', // Unique chart ID '560', '400', // Width and height in pixels false, // Disable debug mode true // Enable 'Register with JavaScript' (Recommended) ); } I'm trying to use the readfile() function to read a html page which has a video embedded (.swf file). When I call the function, it seems like it just loads the html file but without the dependent files (css,js, etc) When I call it directly it loads just fine. Created a hyperlink 'openvideo.php?id=video' that calls this function below: if($_REQUEST['id'] == 'video') { readfile('/usr/home/site.com/htdocs/content/videofolder/video.html'); } else { echo 'nada'; } Any help is appreciated. Magandang Araw, Just want to ask if this idea is feasible or something, these past few days im doing some research on how materialize the said topic and apparently there were no sound solution so far. , im working on a script that allows users to publish html design to jpg, Im done with Imagemagik since its the nearest inline with the specs, so is there any other solution aside from this? im thinking of a php script that will do the job, more likely some gdlibrary manipulation or something. Salamat Jestoni Yes, it's a homework assignment. No, I'm not trying to cheat, so pointing me somewhere is better than just feeding me code, like, "look up how to blah blah" or tell me what I've got wrong? I'm trying to parse a text file of the constitution, add header and <p> tags depending on the first word of the paragraph, then print to an html page. I know I'm supposed to create a function that will return a paragraph, and another function that will return the first word of a paragraph. This is my code, and it completely does not work (obviously I've not included the external html tags) <?php // Opens the constitution text file. $const = fopen("constitution.txt","r"); //Returns an entire paragraph function getParagraph($myfile) { while (!feof($myfile)){ $line = file_get_contents($myfile); $paragraph = explode("\n",$line); } return $paragraph; } //Returns the first word of a paragraph function getFirstWord($myfile) { $pg = getParagraph($myfile); $word = explode(" ",$pg); Return $word[0]; } // Runs through some if statements to determine the tags to use if (getFirstWord($const) === "Article"){ echo "<h2> getParagraph($const)</h2>"; } elseif (getFirstWord($const) === "Section"){ echo "<h3> getParagraph($const)</h3>"; } elseif (getFirstWord($const) === "Amendment"){ echo "<h3> getParagraph($const)</h3>"; } elseif (getFirstWord($const) === "We the People"){ echo "<em> getParagraph($const) </em>"; } else{ echo "<p> getParagraph($const) </p>"; } fclose($const); ?> Hi, I want to create a .html file dynamically on the server. Below is the code for that but i was not able to create the file. I have given all the read, write and execute permission on the folder. $filerand = rand(); $fileName = "test.html"; $filepath = $_SERVER['DOCUMENT_ROOT'] . "\\testfolder\\" . $fileName . ".html"; echo $filepath; $bodytxt = "Welcome to my webpage"; $ourFileHandle = fopen($filepath, 'w') or die("can't open file"); fwrite($ourFileHandle, $bodytxt); fclose($ourFileHandle); Thanks in advance Hello So in my index.php code i include('somefile.html');. In the html file itself there is an <img src="/images/picture.jpg">. When looking at index.php on a browser, the html looks fine everything loaded fine except for the <img> There is a little broken image link displayed on the page. i checked through the browser if i mistyped the img src link but somefile.html in the browser displays the image fine. But if i try to display the img in the html file through the php file, its a broken link. Any reason why this is happening? Am I missing something here? Thanks in advance. I have a script that will download a file from my server onto the user's computer. The problem is it's adding the pages HTML to the top of the file. When I actually look at the file on my server it does NOT have the HTML there, so it has to be some sort of problem with my headers. Code: [Select] <?php $fname = "keyword_files/".$this->fileID.".csv"; header('Content-type: application/csv'); header("Content-Disposition: inline; filename=".$fname); readfile($fname); ?> I would appreciate any help! Thanks. This is most likely a noob question, but... why does it not work? <html> <head> </head> <body style="background-color:#fff;margin:0"> <div style="border-top:1px solid #404040"> 1. JS: source file <br /> <script type="text/javascript" src="test2.js"/> </script> <br />----<br /> 2. PHP: source file<br /> <script language="php" src="test.php"/> </script> <br />----<br /> 3. JS: script inside<br /> <script type="text/javascript"> document.write('<b></br></br>Hello World</br></b>'); </script> <br />----<br /> 4. PHP: script inside <br /> <script language="php"> echo("Hello World"); print "hello world"; </script> <br />----<br /> </div></div></body></html> with the test.php file in same dir (using MAMP), the test.php does work when loading the file directly: <?php echo("Hello World"); ?> |