Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. part while($row = mysql_fetch_array($result)){ if ($bgcolor == "#E0E0E0"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor.">n<td>"); echo($row["URN"]); echo("</td>n<td>"); echo($row["productName"]); echo("</td>n</tr>"); } must be while($row = mysql_fetch_array($result)){ if ($bgcolor == "#E0E0E0"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor.">\n<td>"); echo($row["URN"]); echo("</td>\n<td>"); echo($row["productName"]); echo("</td>\n</tr>"); } change line $pageprev = $page--; to $pageprev = $page-1; and line $pagenext = $page++; to $pagenext = ++$page;
  2. try to change 2nd loop to $poll_query = mysql_query("SELECT answer, sum(amount) as total FROM tblPollAnswers1 WHERE pollID = '$poll_id' LIMIT 1"); $poll_array = mysql_fetch_array($poll_query) $total = $poll_array['total']; $answer = $poll_array['answer']; $amount = round((($amount * 100) / $total),1);
  3. try <?php $a = array(563,318,394,563,318,983,318); $out = array(); foreach ($a as $k) { if (!isset($out[$k])) $out[$k] = 0; $out[$k] += 1; } ksort($out); foreach ($out as $number => $times) { if ($times>1){ for ($i = 0; $i < $times; $i++){ echo $number,"<br />\n"; } echo '--------',"<br />\n\n"; } } ?>
  4. <?php function tree_wiev($a, $parent=0, $step=0){ $out = ''; $pre = '| '; foreach ($a as $v){ if ($v['cat_parent'] == $parent){ $out .= str_repeat($pre, $step).'|__'.$v['cat_name']."<br />\n".tree_wiev($a,$v['cat_id'],$step + 1); } }return $out; } //$data = array( array('cat_id' => 1, 'cat_name' => 'Cars', 'cat_parent' => 0), array('cat_id' => 2, 'cat_name' => 'Toyota', 'cat_parent' => 1), array('cat_id' => 3, 'cat_name' => 'Suzuki', 'cat_parent' => 1), array('cat_id' => 4, 'cat_name' => 'Trucks', 'cat_parent' => 0), array('cat_id' => 5, 'cat_name' => 'Blue Toyota', 'cat_parent' => 2), array('cat_id' => 6, 'cat_name' => 'Red Toyota', 'cat_parent' => 2), array('cat_id' => 7, 'cat_name' => 'Ford', 'cat_parent' => 1), array('cat_id' => 8, 'cat_name' => 'Red Suzuki', 'cat_parent' => 3)); mysql_connect('','',''); mysql_select_db(''); $xyz = mysql_query('select * from tbl_categories'); while($row = mysql_fetch_assoc($xyz)) $data[]=$row; echo tree_wiev($data); ?>
  5. <?php $ar = array ( 'A stitch in time saves nine', 'Birds of a feather flock together', 'All that glisters is not gold', 'type Hat', 'Bat and ball', 'Color red', 'Type trouser', 'A fool and his money are soon parted', 'Color yellow', 'color green', 'type baggy' ); foreach ($ar as $s){ $k = explode(' ',$s); $k = $k[0]; $k = strtolower($k); //remove for case sensitiv $out[$k][] = $s; } foreach ($out as $k => $s){ if (count($s) == 1){ $out[substr($k, 0, 1)][]=$s[0]; unset ($out[$k]); } } print_r($out); ?>
  6. SELECT COUNT(*) FROM table GROUP BY ID
  7. save images on server setup database with information when you query database use ORDER BY RAND($seed) where is $seed random number saved in session or cookee in query use LIMIT
  8. try <?php function tree_wiev($a, $parent=0, $step=0){ $out = ''; $pre = '| '; foreach ($a as $v){ if ($v['cat_parent'] == $parent){ $out .= str_repeat($pre, $step).'|__'.$v['cat_name']."<br />\n".tree_wiev($a,$v['cat_id'],$step + 1); } }return $out; } $data = array( array('cat_id' => 1, 'cat_name' => 'Cars', 'cat_parent' => 0), array('cat_id' => 2, 'cat_name' => 'Toyota', 'cat_parent' => 1), array('cat_id' => 3, 'cat_name' => 'Suzuki', 'cat_parent' => 1), array('cat_id' => 4, 'cat_name' => 'Trucks', 'cat_parent' => 0), array('cat_id' => 5, 'cat_name' => 'Blue Toyota', 'cat_parent' => 2), array('cat_id' => 6, 'cat_name' => 'Red Toyota', 'cat_parent' => 2), array('cat_id' => 7, 'cat_name' => 'Ford', 'cat_parent' => 1), array('cat_id' => 8, 'cat_name' => 'Red Suzuki', 'cat_parent' => 3)); echo tree_wiev($data); ?>
  9. <?php $f = file_get_contents('Amped.txt'); preg_match_all('/<key>Name<\/key><string>([^<]+)<\/string>[\\n\\r\\t ]*<key>Artist<\/key><string>([^<]+)<\/string>/',$f,$a); //$b = array_combine($a[2],$a[1]); //print_r($b); foreach ($a[1] as $k => $song){ $artist = $a[2][$k]; echo 'Artist: ',$artist,"\n",'Song: ',$song,"\n\n"; } ?>
  10. try <?php $f = file_get_contents('Amped.txt'); preg_match_all('/<key>Name<\/key><string>([^<]+)<\/string>[\\n\\r\\t ]*<key>Artist<\/key><string>([^<]+)<\/string>/',$f,$a); $b = array_combine($a[2],$a[1]); print_r($b); ?>
  11. does sript output anything in page (look in page source too)
  12. <?php include ("dbinfo.php"); $sql = "SELECT * FROM picture ORDER BY ID ASC"; //remove ' around ID $result = mysql_query($sql); print mysql_error(); if(mysql_num_rows($result)){ $i = 1; echo ('<table width=\"510\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">'); while ($row = mysql_fetch_assoc($result)) { if ($i == 1) { echo ('<tr>'); } $i ++; $id = $row['ID']; $plink = $row['link']; $ptitle = $row['title']; $palt = $row['alt']; echo ("<td width=\"170px\" height=\"120px\"><a href=\"/pgallery/$plink.jpg\" rel=\"lightbox\" title=\"$ptitle\"><img src=\"/pgallery/thumb/$plink.jpg\" /></a></td>"); // in line befure chenge ' to " and add </td> to end if ($i == 4) {//change 3 to 4 echo ('</tr>'); $i = 1; } }// close while loop echo ('</table>'); } ?>
  13. set your primary key to autoincriment type
  14. <?php if ($page == 1) { echo " FIRST PREV "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?page=1'>FIRST</a> "; $prevpage = $page-1; echo " <a href='{$_SERVER['PHP_SELF']}?page=$prevpage'>PREV</a> "; } // if echo " ( Page $page of $lastpage ) "; $total_pages = $lastpage; $curent_page = $page; if ($total_pages < { $start = 1; $end = $total_pages; } else { if ($curent_page > 3){ if ($total_pages - $curent_page < 3) $end = $total_pages; else $end = $curent_page + 3; $start = $end - 6; } else { $start = 1; $end = 7; } } if ($start > 1) echo '...'; for ($i = $start; $i <= $end; $i++){ if ($i == $curent_page) echo " $i "; else echo " <a href='?page=$i'> $i </a>"; } if ($end < $total_pages) echo '...'; if ($page == $lastpage) { echo " NEXT LAST "; } else { $nextpage = $page+1; echo " <a href='{$_SERVER['PHP_SELF']}?page=$nextpage'>NEXT</a> "; echo " <a href='{$_SERVER['PHP_SELF']}?page=$lastpage'>LAST</a> "; } // if ?>
  15. try <?php $total_pages = 12; $curent_page = 11; if ($total_pages < { $start = 1; $end = $total_pages; } else { if ($curent_page > 3){ if ($total_pages - $curent_page < 3) $end = $total_pages; else $end = $curent_page + 3; $start = $end - 7; } else { $start = 1; $end = 7; } } if ($start>1) echo '...'; for ($i = $start; $i <= $end; $i++){ if ($i == $curent_page) echo " $i "; else echo " <a href=''> $i </a>"; } if ($end < $total_pages) echo '...'; ?>
  16. try function cropImage($nw, $nh, $source, $stype, $dest) { $size = getimagesize($source); $w = $size[0]; $h = $size[1]; switch($stype) { case 'gif': $simg = imagecreatefromgif($source); break; case 'jpg': $simg = imagecreatefromjpeg($source); break; case 'png': break; } $dimg = imagecreatetruecolor($nw, $nh); $wm = $w/$nw; $hm = $h/$nh; $h_height = $nh/2; $w_height = $nw/2; if($wm> $hm) { $adjusted_width = $w / $hm; $half_width = $adjusted_width / 2; $int_width = $half_width - $w_height; imagecopyresampled($dimg,$simg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h); } elseif(($wm <$hm) || ($w == $h)) { $adjusted_height = $h / $wm; $half_height = $adjusted_height / 2; $int_height = $half_height - $h_height; imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h); } else { imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h); } imagejpeg($dimg,$dest,186); }//end of crop im
  17. move line if($_POST['submit']) { before line $displayname = $_POST['displayname'];
  18. try <? echo "<div id=\"catdiv\">"; $i = 0; while($row = mysql_fetch_array($sql)) { $name = $row['name']; $a = $row['id']; echo "<a class=\"two\" href=?cat=" . $a . ">" . $name . "</a><br/>"; if (++$i == 5){ echo "<br/><br/></div>\n<div id=\"catdiv\">"; $i = 0; } } echo "</div>"; ?>
  19. look function FIND_IN_SET()
  20. you set $sku=$row[sku]; before $row is set it's mine $sku='' (NULL)
  21. SELECT COUNT(DISTINCT topic) FROM topic_table
  22. i hope that works
  23. try <?php $a = 'sasa vitner'; echo ucfirst($a),"\n"; echo ucwords($a); ?>
×
×
  • 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.