Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. can you send same value of field 'serial_value' for testing. and does your sql command return one or more then one row?
  2. OK change last line to if($value) $out[$key] = $value;
  3. try <? $a = '1 2 3 4 5 6'; $b = explode("\n",$a,5); if ($b[4]) { $c = split("\n", $b[4]); $b[4] = $c[0]; } print_r($b); ?>
  4. change line $colcounter = (($colcounter+1)>$maxcolumns) ? $colcounter++ : 1; to $colcounter = ($colcounter<$maxcolumns) ? $colcounter+1 : 1;
  5. add line $act = $_GET['act']; before switch stateman
  6. try <?php $dbtable = 'table_care'; $depts = $db->Execute("SELECT * FROM $dbtable WHERE batch_nr='92'"); while($row= $depts->FetchRow()){ $h = $row['serial_value']; $keywords = preg_split ("/[\=,\&]+/", "$h"); for ($i = 1; $i < count($keywords); $i += 5) { $cache .= '<tr>'; for ($j = 0; $j < 5; $j++) { if ($i + $j < count($keywords)) { $cache.='<td> $keywords[$i + $j] </td>'; } else $cache .= '<td> </td>'; } $cache .= '</tr>'; } } ?>
  7. try <?php $product = unserialize($_SESSION['product']); $basket = array(); foreach ($product as $key => $value) { if ($value!='') { $select = mysql_query("SELECT * FROM products WHERE id = '$key'"); if ($select && mysql_num_rows($select)){ while ($prodRow = mysql_fetch_assoc($select)) { $basket[] = $prodRow['item']." ".$prodRow['size']." x ".$value." ".money_format('%.2n',$prodRow['price']).", "; } } } } // need to write out $basket here foreach ($basket as $value) echo $value, "<br />\n"; ?>
  8. try <?php $text ="<html> <head> ... </head> <body> ... <input type='hidden' name='hidden_w' value='123456' /> ... <input type='hidden' name='hidden_x' value='654321' /> <input type='hidden' name='y' value='654321' /> </body> </html>"; $out = array(); $text = str_replace("'",'"',$text); //find hidden inputs preg_match_all ('/<input[^>]+hidden[^>]+>/',$text,$b); $x = $b[0]; foreach ($x as $a){ //find name properties preg_match('/name="([^"]+)"/',$a,$c); $key = $c[1]; $key = str_replace('hidden_','', $key); //find value preg_match('/value="([^"]+)"/',$a,$c); $value = $c[1]; $out[$key] = $value; } print_r($out); ?>
  9. change $basket = $prodRow['item']." ".$prodRow['size']." x ".$value." £".money_format('%.2n',$prodRow['price']).", "; to $basket[] = $prodRow['item']." ".$prodRow['size']." x ".$value." £".money_format('%.2n',$prodRow['price']).", ";
  10. try <?php function my_path($a) { if ($a == 0) return ''; $query = "SELECT * FROM categories WHERE catid = $a"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); mysql_free_result($result); $x = my_path($row['CategoryParent'],'/'); $x = $x ? $x.'/' : $x; return $x.$row['catname']; } mysql_connect(); mysql_select_db('test'); echo my_path(3); ?>
  11. try <?php $a = "20070524;apple"; $b = "20070524;banana"; $c = "20070524;carrot"; $d = "20070527;dog"; $e = "20070708;elephant"; $set = array($a, $b, $c, $d, $e); $out = array(); foreach ($set as $v) { $a = explode(';', $v); $out[$a[0]][] = $a[1]; } foreach ($out as $k => $v) { $out[$k] = $k.';'.implode(',',$v); } foreach ($out as $v) echo $v, "<br />\n"; ?>
  12. it works OK for me look at http://sasa.thehostcity.com/index.php
  13. i try some testing and it works fine for me <?php mysql_connect('localhost','root'); mysql_selectdb('test'); $result = mysql_query('select * from `table`') or die(mysql_error()); $file = fopen('e:\doc\test.csv','w'); $x = array('id','num as string','num as num'); fputcsv($file,$x,','); $out = 'id;long number;'."\n"; while ($row = mysql_fetch_assoc($result)) { // testing data from database // num_t is varchar(16) // num_i is bigint(16) foreach ($row as $k => $v) { echo $k, ' -> ', $v , "\n"; } echo '<hr />', "\n"; // prepear data to put in csv file $x = array($row['id'], '="'.$row['num_t'].'"',$row['num_t']); fputcsv($file,$x,','); } fclose($file); ?> it output id -> 1 num_t -> 1234567890123456 num_i -> 1234567890123456 <hr /> id -> 2 num_t -> 0012345678945678 num_i -> 12345678945678 <hr /> id -> 3 num_t -> 9876543210987654 num_i -> 9876543210987654 <hr /> if i open .csv file in excel it looks [attachment deleted by admin]
  14. try <?php $a = array('"sasa"',2,'xyz\'s',12.33,array('k'=>9,'l'=> 8,'m'=> 7)); $one =array(':\'','\';','"'); $two =array(':"','";','"'); $b = str_replace($two,$one,serialize($a)); if($_POST){ $x = unserialize(str_replace($one,$two,stripslashes($_POST['val_array']))); echo "<pre>"; print_r($x); echo "</pre>"; } echo '<form method="POST"> <input type="hidden" value="'.$b.'" name="val_array"> <input type="submit"> </form>'; ?>
  15. use different variable name in 2nd for loop for($j = 0; $j<$shops; $j++) { echo '<option value = '.$shop[$j][0]; if ($shop[$j][0] == $shop[$i][0]) echo ' selected'; echo '>'.$shop[$j][0].'</option>\n'; }
  16. try <?php $a = array( 0 => array(0 =>"src=\"/images/userfiles/image/uploader.png\"", 1 => "uploader.png"), 1 => array(0 => "src=\"/images/userfiles/image/llcorner2.gif\"", 1 => "llcorner2.gif" )); $tmp = array(); foreach ($a as $b) $tmp[] = $b[1]; //pull out data echo $out = implode(', ', $tmp); //and implode ?>
  17. sasa

    explode()

    tryfcode]<?php $a = 'word'; $b = str_split($a,1); print_r($b); ?>
  18. change line $sql = mysql_query("SELECT * FROM services WHERE category LIKE '%".$search2."%';") or die(mysql_error()); to $sql = mysql_query("SELECT * FROM services WHERE category LIKE '%".$search2."%' OR category = 'all';") or die(mysql_error());
  19. where you set variable $user? (function updateTimestamp())
  20. ups try ="12345678901234567890",="00098765432109876543210"
  21. try file test.csv '1234567890123456789
  22. try <?php // generate test data $a =array('prvi', 'drugi', 'treci'); foreach ($a as $b) $rows[]['ProductCategry'] = $b; echo '<form>'; foreach ($rows as $row) {//print_r($row); print ("<input type=\"checkbox\" name=\"chk[{$row['ProductCategry']}]\" value=\"Y\"> {$row['ProductCategry']}<br />\n"); } echo '<input type="submit" value="Generate Price List">'; echo '</form>'; if ($_GET['chk']) { echo '<hr /><pre>'; foreach ($_GET['chk'] as $k => $v) { echo "Checkbox $k is checked and it has value $v <br />\n"; } } ?>
  23. try to trim variable before comparation
  24. change if ($user == true || $user['friend'] != "Yes") { to if ($user == false || $user['friend'] != "Yes") {
×
×
  • 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.