Jump to content

newbtophp

Members
  • Posts

    631
  • Joined

  • Last visited

Everything posted by newbtophp

  1. Thanks ChemicalBliss and Alex. And for your interest, I was'nt generating the array, it was generated by func_get_args() /Solved
  2. Hi, I have an array: Array ( [0] => index.php [1] => Home [2] => page.php?id=23 [3] => Page ) How would I loop through it so I can link the previous value to the next value within the array e.g.: <a href="index.php">Home</a> <a href="page.php?id=23">Page</a>
  3. Im using the XTemplate templating system (http://www.phpxtemplate.org) All works fine, however, Im having issues when it comes to while loops: I have the following within header.php: <?php include_once('./xtemplate.class.php'); $xtpl = new XTemplate('header.xtpl'); $result = mysql_query("SELECT username FROM site_table"); while($row = mysql_fetch_assoc($result)) { echo $row['username']; } $xtpl->parse('header'); $xtpl->out('header'); ?> And the following with header.xtp: <td width="239" valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="5"> <tr> <td bgcolor="#8b0000"> <div align="center">User List</div> </td> </tr> <td valign="top" bgcolor="#660000"> <div align="center"> <table width="100%" border="0" cellpadding="0" cellspacing="2"> <tr> <td> <div align="left"> <tr> <td width="93%" bgcolor="#500F0C"> <div align="left"> {USERNAME} </div> </td> </tr> </div> </td> </tr> </table> </div></td> </tr> </table> How would I go by doing the above?
  4. I have a function validate() which returns true or false, and I was wanting to know if the followin 3 if examples all do the same thing; and which is the best or your preference to go by doing this? <?php if (validate($input)) { //etc.. } //is the same as the following? if (validate($input) == true) { //etc.. } //is the same as the following? if (validate($input) == 1) { //etc.. } ?>
  5. It was on XAMPP (within phpmyadmin), however I cant start that comp as it just gives a black screen..theirfore can't access phpmyadmin to grab the sql.
  6. I can was just asking what others thougth though - what they'd do if they were in my position...Im going to attempt to create it based on the php stuff (analyse the queries and create the tables/columns neccessary) I'll let you know how it goes.
  7. Okay, my comp is dead, and i was working on some php dev - so I managed to back up the php stuff, but not the .sql. So now I have a new comp i have all the php stuff but not the .sql, Im guessing I'd need to recreate/rebuild the .sql, so the php stuff can successfully work. Any suggestions/idea on how to go by? //Also did'nt really wanted to be seen as an idiot, but its better out their just incase; -> Is their some sort of app out their to scan for queries and create a .sql structure based on the columns/tablenames within those queries?
  8. $str = preg_replace('~<a[^>]+>(.+?)</a>~i', '$1', $str);
  9. Thanks Alex that worked perfectly
  10. Hmm I've always taught {1,20} meant the range of characters accepted, so in this case characters between 1-20 are allowed. But thanks for the correction.
  11. Hmm I've tried the following but no luck: function wrapify($text, $maximumLineLength = 70, $callback = '') { $lines = explode("\n", $text); $words = null; foreach($lines as $line) { $words .= implode(", ", explode(' ', $line)); } $words = explode(", ", $words); $line = ''; $lines = ''; foreach ($words as $word) { if (strlen($line . $word) > $maximumLineLength) { $line = sprintf("% -{$maximumLineLength}s", $line); if (function_exists($callback)) { $line = $callback($line); } $lines .= $line; $line = ''; } $line .= $word . ' '; } if (!empty($line)) { $line = sprintf("% -{$maximumLineLength}s", $line); if (function_exists($callback)) { $line = $callback($line); } $lines .= $line; } return $lines; }
  12. Yeah, and what do you expect of me now? That I write this for you, for free? I already did more for you then I had to. Either try it yourself or pay me. lol sorry. I tried myself - always do before posting here, ill retry - but pointers would help.
  13. Great! works great ignace, however does'nt work with line breaks/new lines: Example Text Scenario: $text = "1. Extract the zip files to a folder on your computer. 2. Follow the instructions in readme.txt"; Would brake out of the # border and not proceed to the next line properly.
  14. $_FILES['file']['size'] || filesize($_FILES['file']['tmp_name']) ?
  15. Anyone can help me? plz. xD
  16. php mailer? http://phpmailer.worxware.com/
  17. Hmm ignace I integrated your code: <?php $nfo_text = <<<eof ################################################################### # default text sample of how it should be # # {text} # # ################################################################### eof; $maximumLength = 70; function wrap($text) { global $maximumLength; return str_repeat('#', $maximumLength + . "\n". '# '.wordwrap($text, $maximumLength, " #\n# ", true). " #\n". str_repeat('#', $maximumLength + ; } $text = "phpfreaks ftw, somelongtexttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt hey how are you?"; $nfo_text = str_replace('{text}', wrap($text), $nfo_text); echo "<pre>"; echo($nfo_text); echo "</pre>"; ?> But the output is: ################################################################### # default text sample of how it should be # # ############################################################################## # phpfreaks ftw, # # somelongtexttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt # # tt hey how are you? # ############################################################################## # # ###################################################################
  18. Hi, Im working on alittle NFO outputer, but the trouble is long text and indentation is not done accurately (it goes out of place). I want to add indentation (3 spaces before the start and end of a line) and any long text to be broken and proceeded to the next line (\n) (if neccesary) - my code: (refer to the expected output to see how im trying to get it too look like). <?php $nfo_text = <<<eof ################################################################### # default text sample of how it should be # # {text} # # ################################################################### eof; function wrap($text) { $start_indent = " "; $end_indent = " "; $start = "#".$start_indent; $end = $end_indent."#"; return $start.$text.$end; } $text = "phpfreaks ftw, somelongtexttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt hey how are you?"; $nfo_text = str_replace('{text}', wrap($text), $nfo_text); echo "<pre>"; echo($nfo_text); echo "</pre>"; ?> Output: ################################################################### # default text sample of how it should be # # # phpfreaks ftw, somelongtexttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt hey how are you?# # # ################################################################### Expected Output: ################################################################### # default text sample of how it should be # # # phpfreaks ftw, somelongtexttttttttttttttttttttttttttttttttttt # # tttttttttttttttttttttttttt hey how are you? # # # ################################################################### Anyone can help me? :-\
  19. $content = preg_replace('~<div class="" style="">(.*?)</div>~', '', $content);
  20. Hi, I'm stuck, im my table im logging the date (using time()), theirfore contains the column, date (which contains a timestamp). However I'd like to know how to display content from that table based on this week (weekly)?, and another based on today (daily)?. Im thinking I'd need to perhaps manipulate the date column. Heres my code so you can get an understanding of my structure: <?php //Weekly 10 $result = mysql_query("SELECT * FROM site_reviews ORDER BY date DESC LIMIT 10"); while ($row = mysql_fetch_array($result)){ echo $row['date']."<br>"; echo $row['review']; } //Daily 5 $result = mysql_query("SELECT * FROM site_reviews ORDER BY date DESC LIMIT 5"); while ($row = mysql_fetch_array($result)){ echo $row['date']."<br>"; echo $row['review']; } ?> Appreciate any help. :-\
  21. Hi. Im currently looping twice due 2 two queries, would it be possible to make this 1 loop, id assume it may be achieved if the 2 queries were to combine somehow? :-\ <?php $username = "admin"; $result = mysql_query("SELECT * FROM profile_comments WHERE comment_name = '{$username}' GROUP BY comment ORDER BY id DESC LIMIT 5"); if (mysql_num_rows($result)) { while ($row = mysql_fetch_array($result)) { $result_2 = mysql_query("SELECT * FROM site_users WHERE user_username = '{$row['profile_name']}' LIMIT 5"); while ($row_2 = mysql_fetch_array($result_2)) { $user_id = $row_2['user_id']; $date = $row['posted']; $comment = $row['comment']; $username = $row['profile_name']; echo $date . "<br />"; echo $username . " - " . $user_id . "<br />"; echo $comment; } } } else { echo "None to display."; } ?> Appreciate help.
  22. Figured it out by just doing it with php instead of it all within a query.
  23. I want to do a flood check to check if the topic_author has posted a topic previously within the last 5 minutes. I have the following columns, topic_date (which is a timestamp which i insert using time()) and topic_author (the topic author). Heres what im doing currently: <?php $username = "newbtophp"; $flood_check = mysql_num_rows(mysql_query("SELECT * FROM site_topics WHERE topic_author = '{$username}' AND topic_date {IS WITHIN LAST 5 MINUTES FROM CURRENT TIME}")); if ($flood_check > 0){ //you need to wait X more minutes to post again... } ?> Anyone can help me with the query neccesary? :-\
  24. you don't need to loop, use array_map() with the clean() function, which would apply it to all values/elements...
  25. or use the e modifier.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.