-
Posts
779 -
Joined
-
Last visited
Never
About xyn
- Birthday 02/01/1988
Profile Information
-
Gender
Male
-
Location
Northampton
xyn's Achievements
Advanced Member (4/5)
0
Reputation
-
I fixed it.. the regex i now use is... "/^(.*?)\{(while)\}(.*?)\{(1\|if:row=1)\}(.*?)\{(1\|endif)\}(.*?)\{(endwhile)\}(.*?)$/us";
-
First off, I would like to apologise for posting this, in the "incorrect" area, as i couldn't find the specific regex board. Secondly, I've been working on my own basic template engine, every thing has been working fine, up until i used multiple IF STATEMENTS within my html template page: The Template file: [code=php:0]<table width="600" cellspacing="0" cellpadding="0"> <tbody> {0|if:rows=0} <!-- No items in basket --> <tr class="formbg"> <td colspan="2" width="600" height="25" class="head2" style="padding-left:5px;"> There are not any products in your shopping basket! </td> </tr> {0|else} {while} {1|if:row=1} <!-- The headings for the basket table --> <tr class="formbg"> <td width="300" height="25" class="head3" style="padding-left:5px;"> Heading </td> <td width="300" height="25" class="head3"> Title </td> </tr> {1|endif} <!-- The basket items --> <tr class="formbg"> <td width="300" height="25" class="head3" style="padding-left:5px;"> - </td> <td width="300" height="25" class="head3"> - </td> </tr> {endwhile} {0|endif} </tbody> </table> [/code] Basically I can collect the table row between {0|if:rows=0} and {0|else}. I can also collect everything from {while} to {endwhile} between {0|else} and {0|endif}. However, when i try to extract the following as separate items, the regular expressions will not work... [code=php:0]{1|if:row=1} <!-- The headings for the basket table --> <tr class="formbg"> <td width="300" height="25" class="head3" style="padding-left:5px;"> Heading </td> <td width="300" height="25" class="head3"> Title </td> </tr> {1|endif} [/code] My php code: [code=php:0]function basket_checkout(){ # define smart tags $smart_tags=array( array() ); # select products in basket $cart=mysql_query("select * from `sc_cart_basket` where `sc_basket_user`='{$_SESSION[$this->c_session]}' order by `sc_basket_added` asc"); $cart_html=file_get_contents("$this->c_root/basket_checkout.inc.php"); # regular expressions $pattern_elseif_1="/^(.*?)\{(0\|if:rows=0)\}(.*?)\{(0\|else)\}(.*?)\{(0\|endif)\}(.*?)$/us"; $pattern_while="/^(.*?)\{(while)\}\{(1\|if:row=1)\}(.*?)\{(1\|endif)\}(.*?)\{(endwhile)\}(.*?)$/us"; $html_table_start=preg_replace($pattern_elseif_1, "\\1", $cart_html); # start table $html_no_rows=preg_replace($pattern_elseif_1, "\\3", $cart_html); # if no mysql rows, insert 1 table row $html_basket_while=preg_replace($pattern_elseif_1, "\\5", $cart_html); # the while loop $html_basket_itmes=preg_replace($pattern_while, "\\4", $html_basket_while); # DEBUG 1 $html_table_end=preg_replace($pattern_elseif_1, "\\7", $cart_html); # end the table (debug only) echo $html_table_start, $html_basket_itmes, $html_table_end; // --> } [/code]
-
[SOLVED] Randomly splitting form data into 2 groups
xyn replied to tomd79's topic in PHP Coding Help
Sorry, I got lost. so you want to be able to check say 10 players? and then 5 are randomly places in team A, and the other 5 are randomly placed in team B? -
[SOLVED] If Conditional's ""speach mark braces conflict?
xyn replied to yandoo's topic in PHP Coding Help
you're missing a } somewhere -
[SOLVED] Randomly splitting form data into 2 groups
xyn replied to tomd79's topic in PHP Coding Help
Ok, do you store your players in a database? and would you onyl have team A and team B? -
Well As far as i know theres only AJAX.
-
replace that with this; your code fine, but i dont understand the function business <? $host ="localhost"; $user ="ddsqladmin"; $pass ="bobo"; $data ="flory"; $connect =mysql_connect($host, $user, $pass); $database =mysql_select_db($data, $connect); if(!$connect||!$database)die("Database cannot connect..."); function makeClickableLinks($text) { $text = html_entity_decode($text); $text = " ".$text; $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1" target=_blank>\1[/url]', $text); $text = eregi_replace('(((f|ht){1}tps://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1" target=_blank>\1[/url]', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1\2', $text); $text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '\1', $text); return $text; } ?>
-
my url wasnt invalid, its not hard to make an associative array :l, and thats the params sorted. but i dont care agreed.
-
I think you mean this: $result3 = mysql_query("SELECT HeaderDate FROM Headertbl"); print '<h2><select name="$HeaderDate">'; while($row2 = mysql_fetch_array($result3)) { echo "<ption value=\"{$row2['HeaderDate']}\">{$row2['HeaderDate']}</option>'; } print '</select>';
-
[SOLVED] If Conditional's ""speach mark braces conflict?
xyn replied to yandoo's topic in PHP Coding Help
<?php if (@$row_user_conditional['Access'] == "2") { echo "<img src=\"Images/Buttons/admin.png\" onclick=\"window.location.href='http://localhost/RFW/admin.php'\" width=\"100\" height=\"35\" />"; } ?> or <?php if (@$row_user_conditional['Access'] == "2") { ?> <img src="Images/Buttons/admin.png"onclick="window.location.href='http://localhost/RFW/admin.php'" width="100" height="35" /> <? } ?> -
[SOLVED] linking a file (pdf) to an article
xyn replied to anthony-needs-you's topic in PHP Coding Help
If you know the exact path of your PDF, try this? download.php header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); // required for certain browsers header("Content-Type: application/pdf"); header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filename)); readfile("$filename"); exit(); user by download.php?filename=PDF.pdf -
[SOLVED] linking a file (pdf) to an article
xyn replied to anthony-needs-you's topic in PHP Coding Help
try adding this: header('content-type','application/pdf'); -
[SOLVED] Randomly splitting form data into 2 groups
xyn replied to tomd79's topic in PHP Coding Help
Can I just ask what you're trying to archive? and what your problem is? I'll try and code you something to learn from. -
Your code does exactly what my example does, except yours uses more lines