sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
can you send same value of field 'serial_value' for testing. and does your sql command return one or more then one row?
-
[SOLVED] Grabbing text from files/strings/etc
sasa replied to iLLeLogicaL's topic in PHP Coding Help
OK change last line to if($value) $out[$key] = $value; -
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); ?>
-
[SOLVED] shuffle() is giving me the two-step - expects parameter 1 to be array
sasa replied to DLR's topic in PHP Coding Help
change line $colcounter = (($colcounter+1)>$maxcolumns) ? $colcounter++ : 1; to $colcounter = ($colcounter<$maxcolumns) ? $colcounter+1 : 1; -
add line $act = $_GET['act']; before switch stateman
-
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>'; } } ?>
-
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"; ?>
-
[SOLVED] Grabbing text from files/strings/etc
sasa replied to iLLeLogicaL's topic in PHP Coding Help
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); ?> -
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']).", ";
-
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); ?>
-
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"; ?>
-
it works OK for me look at http://sasa.thehostcity.com/index.php
-
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]
-
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>'; ?>
-
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'; }
-
[SOLVED] Convert Two-Dimensional Array to String
sasa replied to shane0714's topic in PHP Coding Help
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 ?> -
tryfcode]<?php $a = 'word'; $b = str_split($a,1); print_r($b); ?>
-
display records that have "all" in category field
sasa replied to Ameslee's topic in PHP Coding Help
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()); -
Help: something's wrong, but I cant find the error
sasa replied to clown[NOR]'s topic in PHP Coding Help
where you set variable $user? (function updateTimestamp()) -
ups try ="12345678901234567890",="00098765432109876543210"
-
try file test.csv '1234567890123456789
-
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"; } } ?>
-
[SOLVED] simple problem (dont know how to put into words)
sasa replied to chocopi's topic in PHP Coding Help
try to echo $inputcode is it pass ok? -
try to trim variable before comparation
-
change if ($user == true || $user['friend'] != "Yes") { to if ($user == false || $user['friend'] != "Yes") {