Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try <?php $test = 'Sponge Face Painting Applicators Medium Sponge Applicator'; $c = 1; while ($c) $test = preg_replace('/^(.*?)(\b[^ ]+?)s?\b (.*\b\2s?\b.*$)/', '\1\3', $test,-1,$c); echo $test; ?>
  2. try <?php $test = array( array("unit name 1", "category name 1", "Course 1"), array("unit name 2", "category name 2", "Course 1"), array("unit name 3", "category name 2", "Course 1"), array("unit name 4", "category name 3", "Course 2"), array("unit name 5", "category name 1", "Course 1"), array("unit name 6", "category name 4", "Course 2") ); foreach ($test as $data){ $tmp[$data[2]][$data[1]][] = $data[0]; } foreach ($tmp as $course => $data){ echo $course, '<br /><table border="3">'; $tbl = array(); $i = 0; foreach ($data as $cat => $unit){ $i++; $tbl [0][$i] = $cat; $tbl[1][$i] = implode('<br />', $unit); } echo '<tr><td>', implode('</td><td>', $tbl[0]),'</td></tr>'; echo '<tr><td>', implode('</td><td>', $tbl[1]),'</td></tr>'; echo '</table><br />'; } ?>
  3. change form part to echo "<td><input type='text' name='quantity[".$uniq_id."]' value='".$quantity."'/></td>"; and on action page do foreach($_POST['quantity'] as $uniq_id => $qty){ mysql_query("UPDATE cart SET quantity='$qty' WHERE id='$uniq_id' "); }
  4. ups try $pattern = '/(?P<name>^[^-]+)-(?P<username>[^:]+)?P<password>.+)@(?P<server>[^@]+$)/'; $subject = 'name-username:p@ssword@server'; preg_match($pattern, $subject, $matches); print_r($matches); ?>
  5. try $pattern = '/(?P<name>^[^-]+)-(?P<username>[^:]+)?P<password>[^@]+)@(?P<server>.*$)/';
  6. try <?php $bb_search = array ( '/\[b\]/', '/\[\/b\]/', '/\[img\=(.*?)\]/e', ); $bb_replace = array ( '<b>', '</b>', 'check_image( \\1 )' ); $test = '[img=sasa]'; function check_image($a){ return "<img src='$a'>"; } echo preg_replace($bb_search, $bb_replace, $test); ?>
  7. change form part to <?php $query = $DB->query("SELECT country_code, country_id, IF(country_code = '".$country_code."', '', '') AS sel FROM countries WHERE site = 'test' ORDER BY country_name ASC"); foreach ($query->result as $row) { $options .= '<label>' . 'Phrase for ' . $this->settings['countries'][$row['country_code']] . '</label>' . '<br />'; $options .= '<input style="width: 100%; height: 5%;" id="country_data" type="text" name="country_data[' . $row['country_id'] . ']" />' . '<br /><br />'; } ?> and on submit page do <?php foreach ($_POST['country_data'] as $country_id => $value) { // do something } ?>
  8. <?php $strContent = 'I am some <a href="/content.htm">Content</a> here, but I could have <a href="/link.php">a Link</a> <a href="http://www.example.com">Followed by another</a> Link, Mix external and not.'; preg_match_all('~href=("|\')(.*?)\1~', $strContent, $out); print_r($out[2]); ?>
  9. try <?php function my_find($data, $start_tag, $end_tag){ $end = strpos($data, $end_tag); if ($end){ if (($start = strpos($data, $start_tag)) !== false){ while ((($tmp = strpos($data, $start_tag, $start+1 )) !== false) and $tmp < $end) $start = $tmp; } else echo 'no open tag'; return substr($data, $start, $end - $start + strlen($end_tag)); } } $test = '<div>1 <div>2 <div>3<div>4</div></div></div></div>'; echo my_find($test, '<div', '</div>'); ?>
  10. change $countCheck=count($_POST['checkbox']); to $countCheck= isset($_POST['checkbox']) ? count($_POST['checkbox']) : 0;
  11. add $line = trim($line); before write $line in file
  12. <?php $test = '<tr> <td><font size="1"><b>Description:</b></font></td> <td width="550">The rich contemporary style of the "Theo" Counter Height Table combines faux marble and a warm finish to create dining room furniture that adds an exciting style to the decor of any home. The thick polyurethane coated faux marble table top perfectly accentuates the warm brown finish flowing over the straight-lined contemporary design of the apron and legs to help create an exceptional dining experience. With the beautiful stitching and button tufting details of the faux leather upholstered bar stools, the "Theo" Counter Height Table is a refreshing addition to any home.</td> </tr> <tr bgcolor="#F8F7E4"> <td><font size="1"><b>Series Features:</b></font></td> <td width="550">Table top made with polyurethane coated print marble. Aprons and legs made from select veneer and solids with a warm brown finish. Chair is upholstered in a brown PVC with accent top stitching. D158-233 bar stool dimension: 18"W x 21"D x 40"H.</td> </tr> <tr> <td><font size="1"><b>Printable Page:</b></font></td> <td width="550"> <a href="javascript:LoadBrochure(\'D158\')"><b>Click here</b> </a>to download full color page for the<b> Theo </b>series. </td> </tr> <tr bgcolor="#F8F7E4"> <td><font size="1"><b>Image Downloads:</b></font></td> <td width="550"><a href="../Downloads/download_results.asp?varSeriesNumber=D158&NAV=fromSeriesDetail"><b>Click here</b></a> for complete image download listing for series <b>D158</b>.</td> </tr>'; preg_match_all('~<td\s+width="550">(.*?)</td>~', $test, $out); print_r($out[1]); ?>
  13. you miss to add limit part to your 2nd queru and your pagination links is not correct it must be something like echo "<a href='". $_SERVER[php_SELF]."?q=".$_GET['q']."&p=$i'>Page $i - </a>";
  14. <?php $data=array('team1'=>array('w'=>0,'l'=>1,'t'=>0,'pts'=>0), 'team2'=>array('w'=>1,'l'=>0,'t'=>0,'pts'=>3), 'team3'=>array('w'=>0,'l'=>0,'t'=>1,'pts'=>1) ); foreach ($data as $team => $value) $tmp[] = $value['pts']; array_multisort($data, SORT_DESC, SORT_NUMERIC, $tmp, SORT_DESC, SORT_NUMERIC); print_r($data); ?>
  15. try <?php $handle = fopen('test.csv', 'r'); while ($line = fgetcsv($handle)) $out[$line[0]][] = array('qty' =>$line[1], 'price' => $line[2]); foreach ($out as $aku => $tierPrices) $proxy->call('tierprice.update', array($aku, $tierPrices)); ?>
  16. you can use UNION of two query. one for one record and 2nd for rest
  17. <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("uni", $con)or trigger_error('MySQL error: ' . mysql_error()); try { $sql = "SELECT StudentID,CourseID FROM take WHERE StudentID =" . $_POST['sid'] . " AND CourseID =" .$_POST['cid'] ; $query = mysql_query($sql) or trigger_error('MySQL error: ' . mysql_error()); if (mysql_num_rows($query) > 0) { echo'StudentID already taken'; } } if (!empty($_POST['sid']) && !empty($_POST['cid'])) //-------> error line { $ct = 0; $student = $_POST['sid']; foreach ($_POST['cid'] as $key => $course) { $sql = "INSERT INTO take (StudentID, CourseID) VALUES('".mysql_real_escape_string($student)."','".mysql_real_escape_string($course)."')"; $query = mysql_query($sql) or trigger_error('MySQL error: ' . mysql_error()); if (mysql_affected_rows() > 0){$ct++;} } echo $ct . ' rows added.'; } mysql_close($con); ?>
  18. look date<='".$nineyesterday."' AND date>='".$nineam date is less then $nineyesterday and greatest then $nineam, is it OK?
  19. add . " after $_POST['sid'] $sql = "SELECT StudentID,CourseID FROM student,course WHERE StudentID =" . $_POST['sid'] . " AND CourseID =".$_POST['cid'] ;
  20. try <?php $handle = fopen('test.csv', 'r'); while ($line = fgetcsv($handle)) $out[$line[0]][$line[1]] = $line[2]; print_r($out); ?>
  21. if it works then mark topic solved
  22. you just check first character of string if you want to check it all change patern to '/^[a-zA-Z0-9]+$/'
  23. <?php require('config.php'); require(INCLUDE_ROOT.'/classes/Category.php'); $viewPages = array( 'category' => array('classfile' => 'Category.php', 'classname' => 'Category', 'functions' => array('create', 'delete', 'modify', 'merge')), 'questions' => array('classfile' => 'Question.php', 'classname' => 'Question', 'functions' => array('create', 'delete', 'modify', 'votegood', 'votebad')) ); $currentPage = $_GET['action']; if(array_key_exist($currentPage, $viewPages)) { $settings = $viewPages[$currentPage]; require(INCLUDE_ROOT.'/classes/'.$ettings['classfile']); $this->$class = new $settings['classname']; $function = $_REQUEST['do']; $this->$class->$function(); loadTemplate($this->viewFile, $this->messages); } else { //show deafult page } ?>
  24. just trim $to_insert variable before insert it in db
  25. change $sql = "SELECT HoursSpentLas, TravelTimeLas FROM tblProjects WHERE AdviserName = $MM_Username AND WeekNumber = $MM_Weeknumber"; to $sql = "SELECT HoursSpentLas, TravelTimeLas FROM tblProjects WHERE AdviserName = '$MM_Username' AND WeekNumber = $MM_Weeknumber"; add qoutes around string data
×
×
  • 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.