sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
Display MySQL Information over Multiple Columns in a Table
sasa replied to adammcmillan's topic in PHP Coding Help
try <?php $result = mysql_query($sql) or die(mysql_error()); $ceil_in_row = 3; echo "<table>\n"; while ($row = mysql_fetch_array($result)){ echo "<tr>\n"; echo "\t<td>",$row['name'],"</td>\n"; for ($i = 1; $i < $ceil_in_row; $i++){ if ($row = mysql_fetch_array($result)) echo "\t<td>",$row['name'],"</td>\n"; else echo "\t<td> </td>\n"; } echo "</tr>\n"; } echo "</table>"; ?> -
try <?php $page = file_get_contents('http://kish89.pondi.hr/auction.htm'); $page = html_entity_decode($page); preg_match_all('|Auction:.*?<font[^>]+>([^<]*).*?<font[^>]+>([^<]*).*?<tr.*?<tr.*?<span><[^>]+>([^<\s]*).*?mailto:([^"\']+).*?<font[^>]+>\s*([0-9,]*).*?<font[^>]+>\s*([0-9,]*)|s', $page, $out); //print_r($out); foreach ($out[0] as $k => $v){ echo 'Aukcija: ', $out[1][$k], "<br />\n"; echo 'ID: ', $out[2][$k], "<br />\n"; echo 'Ime: ', $out[3][$k], "<br />\n"; echo 'E-mail: ', $out[4][$k], "<br />\n"; echo 'Cijena: ', $out[5][$k], "<br />\n"; echo 'Kolicina: ', $out[6][$k], "<hr />\n"; } ?>
-
try <?php $aaa = array( array('id'=>1,'name'=>'aaa','pld'=>1), array('id'=>1,'name'=>'aaa','pld'=>2), array('id'=>3,'name'=>'ccc','pld'=>1), array('id'=>2,'name'=>'bbb','pld'=>1), array('id'=>1,'name'=>'aaa','pld'=>3), array('id'=>3,'name'=>'ccc','pld'=>2), array('id'=>2,'name'=>'bbb','pld'=>2), array('id'=>3,'name'=>'ccc','pld'=>3), array('id'=>2,'name'=>'bbb','pld'=>3) ); $out = array(); foreach ($aaa as $a){ $out[$a['id']][$a['name']] = isset($out[$a['id']][$a['name']]) ? $out[$a['id']][$a['name']] + $a['pld'] : $a['pld']; } $aaa = array(); foreach ($out as $id => $a){ foreach ($a as $name => $pld) $aaa[] = array('id' => $id, 'name' => $name, 'pld' => $pld); } sort($aaa); print_r($aaa); ?>
-
[SOLVED] multiple FCKeditor - value's all identicle
sasa replied to unxposed's topic in PHP Coding Help
try to change line $oFCKeditor = new FCKeditor('blog_content[]') ; to $oFCKeditor = new FCKeditor('blog_content['.$i.']') ; -
$sql ="INSERT INTO table_name (one,two,three,four,five,six) VALUES (" . implode(',',$numbers) . ")";
-
Need a PHP Guru for complicated Coord manipulation
sasa replied to drisate's topic in PHP Coding Help
[code]somethin like this <?php $test ='1:113:13'; $add = '50S'; $test = explode(':',$test); $number = ($test[0]-1)*499*15+($test[1]-1)*15+($test[2]-1); $t = substr($add, -1); switch ($t){ case 'G': $add *= 499; case 'S': $add *= 15; case 'P' : $add *= 1; } $new_number = $number+$add; $sql = "SELECT * FROM table_name WHERE ((G-1)*499*15+(S-1)*15+P-1) BETWEEN $number AND $new_number"; ?>[/code] -
are you look page source code or browser window?
-
merge this two line mysql_query("INSERT INTO gradcoll (u_course) VALUES ('$course')"); mysql_query("INSERT INTO gradcoll (u_id) VALUES ('$id')"); to mysql_query("INSERT INTO gradcoll (u_course, u_id) VALUES ('$course', '$id')"); and next two to
-
look <?php $a = '001020.300'; echo $a + 0; ?>
-
just before 2nd while loop insert lint mysql_data_seek($acc_skr_r, 0);
-
if (($key = array_search($sku,$inventory_sku))!==false)
-
try[code=php:0]$content = preg_replace('/(\[CAL\=([0-9]*\/[0-9]*)\])/ie', "getJobs('$2', 'CAL')", $content); not tested
-
[SOLVED] including variables in a query EVEN if they're empty
sasa replied to glennn.php's topic in PHP Coding Help
in implode you create variable $offerings and in 2nd part you use $offering_sql -
ara you try this test.php <?php $array = parse_ini_file('test2.php',1); print_r($array); ?> and test2.php [prop_1] prop_code = GN110 sqft = 1520 txt = Very nice property pica = picb = picc = picd = pice = picf = picg = [prop_2] prop_code = GN110 sqft = fdbg h h n gg txt = Very nice property pica = picb = picc = picd = pice = picf = picg =
-
try <?php //... $this->sortState = isset($_GET[$name . 'Sort']) ? $_GET[$name . 'Sort'] : self::DEFAULTSORT; //... ?>
-
[SOLVED] including variables in a query EVEN if they're empty
sasa replied to glennn.php's topic in PHP Coding Help
try $where = array(); if ($offerings != '') { $where[] = "offering IN ($offering_sql)"; } if ($some_field != '') { $where[] = "some_field IN ($some_field_sql)"; } //etc. $where = count($where) ? implode(' AND ', $where) : 1; $sql = "SELECT fice FROM characteristics WHERE $where"; -
try <?php $test = '(npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)))'; $test = preg_split('/(\n|\r|\n\r){2,2}/',$test); $test = array_chunk($test,5); foreach ($test as $k => $v) $test[$k] = implode($v); print_r($test); ?> is it OK now
-
change mysql_query("INSERT INTO news (`title`, `body`, `date`) VALUES ( $title, $body, now())") or die(mysql_error()); to mysql_query("INSERT INTO news (`title`, `body`, `date`) VALUES ( '$title', '$body', now())") or die(mysql_error());
-
it's somethin wrong with 1st split can you try just first part of code <?php $test = '(npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)))'; $test = preg_split('/(\n|\r|\n\r){2,2}/',$test); print_r($test); ?> and post output is it Array ( [0] => (npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) [1] => (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1))) )
-
can you post exactly string for input i try code for input (npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1))) end it output is INSERT INTO npc (`name`,`index`,`country`,`race`,`level`,`ai`,`range`,`sight`,`exp`,`itemgroup`,`str`,`hth`,`int`,`wis`,`dex`,`hp`,`mp`,`aspeed`,`hit`,`dodge`,`attack`,`magic`,`defense`,`absorb`,`mspeed`,`quest`) VALUES ('1','1','252','0','1','1','20','160 240','2','1 2','21','1','10','10','2','1','70','2400','0','0','0 7 7','0 0','0 0','0','1600 800','(2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1)') INSERT INTO npc (`name`,`index`,`country`,`race`,`level`,`ai`,`range`,`sight`,`exp`,`itemgroup`,`str`,`hth`,`int`,`wis`,`dex`,`hp`,`mp`,`aspeed`,`hit`,`dodge`,`attack`,`magic`,`defense`,`absorb`,`mspeed`,`resist`,`quest`) VALUES ('2','2','252','0','3','1','16','160 240','4','2 2','27','2','10','10','4','1','70','2400','0','0','0 8 8','0 0','1 1','0','1600 800','0 0 1 1 1','(2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)') time is 0.037781 s
-
tryto change $test = preg_split('/\n\n/',$test); to $test = preg_split('/(\n|\r|\n\r){2,2}/',$test);
-
it's mean that 1st split didn't pass OK have you empty line betvin ?
-
try <?php $test = '(npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)))'; $test = preg_split('/\n\n/',$test); foreach ($test as $line){ $line = trim($line); // find table name $start = 0; for ($i = 0; $line[$i] !== ' '; $i++); $table = substr($line,1, $i - 1); // remove table name and last ) $lin = substr($line, $i + 1, strlen($line) - $i - 1); $count = 0; $key = array(); $value =array(); $part = ''; for ($i = 0; $i < strlen($lin); $i++){ $chr = $lin[$i]; if ($chr == '(') $count++; if ($chr == ')') $count--; if ($count > 0) { $part .= $chr; } elseif ($part) { $part = explode(' ', trim($part, '('), 2); $key[]= $part[0]; $value[]= $part[1]; $part = ''; } } $key = '(`'.implode('`,`', $key).'`)'; $value = "('".implode("','",$value). "')"; $sql = 'INSERT INTO '. $table.' '. $key. ' VALUES '. $value; echo $sql, "\n";//for testing // do query } ?>
-
is evry line start with '(npc ' or it can be something diferent is one npc in one or multipli lines how you want to insert (mspeed 1600 800) or (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)) in db table
-
[SOLVED] strip out part of a string - should be easy enough
sasa replied to CaptainChainsaw's topic in PHP Coding Help
try <?php $test = 'search.php?pagenumber=2¶m0=a'; $test = parse_url($test); parse_str($test[query], $out); print_r($out); ?>