Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. UPDATE table_name a, table_name b SET b.volume = a.volume + b. shares WHERE a.id='13' AND b.id='14'
  2. are you shure that your root elements have pid=0? try to print_r($c);
  3. <?php function my_round($num){ return round($num *2 ) / 2; } for ($i = 0.1; $i < 2; $i += 0.1){ echo $i, ' -> ', my_round($i), "<br />\n"; } ?>
  4. if(!(strpos($string, $symbol)===false)){ $before = substr($string, 0, strpos($string, $symbol)); $after = substr($string, strpos($string, $symbol)+1); }
  5. try <?php $allocation=mysql_query("select busno, depot, chassisbody from busfleet WHERE active='Y' ORDER BY depot ASC, chassisbody ASC, busno + 0 ASC "); $DepotNameToDisplay = "abc"; $ChassisToDisplay= "abc"; $totbuses=0; $not_start = false; while($row_allocation=mysql_fetch_assoc($allocation)) { $ThisDepotName = $row_allocation['depot']; if ($ThisDepotName != $DepotNameToDisplay){ if ($not_start){ echo "<p>total buses for $DepotNameToDisplay: $totdepot"; echo "<hr>"; } $DepotNameToDisplay = $ThisDepotName; echo "<p><b>$DepotNameToDisplay</b>"; $totdepot=0; $not_start = true; } $ThisChassisName = $row_allocation['chassisbody']; if ($ThisChassisName != $ChassisToDisplay){ $ChassisToDisplay= $ThisChassisName ; echo "<br><i>$ChassisToDisplay</i><br>"; } echo $row_allocation['busno']; echo " "; $totbuses=$totbuses+1; $totdepot=$totdepot+1; } echo "<p>total buses for $DepotNameToDisplay: $totdepot"; echo "<hr>"; echo "<p>$totbuses buses allocated!"; ?>
  6. UPDATE `$tbl_name` SET `amount` = CASE `sub_category` WHEN 'Mustang' THEN '$budg_mustang' WHEN 'Vulcan' THEN '$budg_vulcan' ... ELSE `amount` END
  7. basic syntax SELECT blah.... FROM table1 JOIN table2 ON ... JOIN table3 ON ... WHERE ...
  8. OK UPDATE table_name AS a, table_name AS b SET a.field2 =b.fiel2, a.field3=b.field3, a.field4=b.field4, a.field5=b.field5, a.field6=b.field6 WHERE LEFT(b.field1, CHAR_LENGTH(b.field1)-2)=a.field1 AND RIGHT(b.field1, 2) IN ('-1', '-2', '-3', '-0')
  9. try to print_r($bonus); just after for loop
  10. try <?php $origArr = array("bread"=>19, "butter"=>19, "coke"=>4, "orange"=> 7); $newArr = array(); foreach($origArr as $key=>$val) { $item = array(); $item["counter"] = $val; $item["term"] = $key; $newArr[] = $item; } rsort($newArr); print_r($newArr); ?>
  11. what function Query do? what data is in field 'reg_add'?
  12. UPDATE table_name AS a, table_name AS b SET a.field2 ='-', a.field3='-', a.field4=b.field3, a.field5='-' WHERE LEFT(b.field1, CHAR_LENGTH(b.field1)-2)=a.field1 AND RIGHT(b.field1, 2) IN ('-1', '-2', '-3', '-0')
  13. 1st change echo "<a href='cart.php?del_id=id'>delete</a><br>"; to echo "<a href='cart.php?del_id=$id'>delete</a><br>";[/code]and if($cmd=="delete") { $sql = "DELETE FROM cart WHERE id=$id"; $result = mysql_query($sql); echo "Row deleted!"; } to if(isset($_GET['del_id'])) { $id=$_GET['del_id']; $sql = "DELETE FROM cart WHERE id=$id"; $result = mysql_query($sql); echo "Row deleted!"; }
  14. but yuo can do <?php $chose_background = 4; switch($chose_background){ case $chose_background >10 : echo "post some code"; break; case $chose_background >5 : echo "post some other code"; break; case $chose_background >1 : echo "post some totally different code"; break; default: echo "post the defoult code"; } ?>
  15. are you change HAVING COUNT(id)=5 to HAVING COUNT(DISTINCT item) = 5
  16. it mean thet member have 5 record with item in ('holy potion', 'arcane potion', 'fire potion', 'shadow potion', 'kinetic potion') 5 of 5 if member can have more then one same items in same day (2 holy potion in one day) change to 'HAVING COUNT(DISTINCT item) = 5'
  17. try SELECT name FROM `actionlog` WHERE item IN ('holy potion', 'arcane potion', 'fire potion', 'shadow potion', 'kinetic potion') GROUP BY name, `date` HAVING COUNT(id)=5
  18. try SELECT a.playlistID, COUNT( b.id ) FROM playlist_songs as a LEFT JOIN playlist_songs as b ON a.playlistID=b.playlistID WHERE a.songID = '1' GROUP BY a.playlistID not tested
  19. try while( $tagging = mysql_fetch_assoc( $tagquery ) ) { str_replace(',', ',', $tagging['tagging'], $tmp); $tags[$tagging['tagging']] = $tmp+1; }
  20. try <?php function my_chunk($text, $limit){ $out = array(); while (strlen($text)>$limit){ $x = strrpos(substr($text,0,$limit), ' '); $out[] = substr($text,0,$x); $text = substr($text, $x+1); } if (strlen($text)) $out[] = $text; return $out; } $test = "If the author should be told that the sentimental love of our day was unknown to the pagan world, he would not cite last the two lovers, Antony and Cleopatra, and the will of the powerful Roman general, in which he expressed the desire, wherever he might die, to be buried beside the woman whom he loved to his latest hour. His wish was fulfilled, and the love-life of these two distinguished mortals, which belongs to history, has more than once afforded to art and poesy a welcome subject. In regard to Cleopatra, especially, life was surrounded with an atmosphere of romance bordering on the fabulous. Even her bitterest foes admire her beauty and rare gifts of intellect. Her character, on the contrary, presents one of the most difficult problems of psychology. The servility of Roman poets and authors, who were unwilling frankly to acknowledge the light emanating so brilliantly from the foe of the state and the Imperator, solved it to her disadvantage. Everything that bore the name of Egyptian was hateful or suspicious to the Roman, and it was hard to forgive this woman, born on the banks of the Nile, for having seen Julius Caesar at her feet and compelled Mark Antony to do her bidding. Other historians, Plutarch at their head, explained the enigma more justly, and in many respects in her favour. It was a delightful task to the author to scan more closely the personality of the hapless Queen, and from the wealth of existing information shape for himself a creature in whom he could believe. Years elapsed ere he succeeded; but now that he views the completed picture, he thinks that many persons might be disposed to object to the brightness of his colours. Yet it would not be difficult for the writer to justify every shade which he has used. If, during his creative work, he learned to love his heroine, it was because, the more distinctly he conjured before his mind the image of this wonderful woman, the more keenly he felt and the more distinctly he perceived how fully she merited not only sympathy and admiration, but, in spite of all her sins and weaknesses, the self-sacrificing affection which she inspired in so many hearts. It was an author of no less importance than Horace who called Cleopatra \"non humilis mulier\"--a woman capable of no baseness. But the phrase gains its greatest importance from the fact that it adorns the hymn which the poet dedicated to Octavianus and his victory over Antony and Cleopatra. It was a bold act, in such an ode, to praise the victor's foe. Yet he did it, and his words, which are equivalent to a deed, are among this greatly misjudged woman's fairest claims to renown. Unfortunately it proved less potent than the opinion of Dio, who often distorted what Plutarch related, but probably followed most closely the farce or the popular tales which, in Rome, did not venture to show the Egyptian in a favourable light. The Greek Plutarch, who lived much nearer the period of our heroine than Dio, estimated her more justly than most of the Roman historians. His grandfather had heard many tales of both Cleopatra and Antony from his countryman Philotas, who, during the brilliant days when they revelled in Alexandria, had lived there as a student. Of all the writers who describe the Queen, Plutarch is the most trustworthy, but even his narrative must be used with caution. We have closely followed the clear and comprehensive description given by Plutarch of the last days of our heroine. It bears the impress of truth, and to deviate widely from it would be arbitrary. Unluckily, Egyptian records contain nothing which could have much weight in estimating the character of Cleopatra, though we have likenesses representing the Queen alone, or with her son Caesarion. Very recently (in 1892) the fragment of a colossal double statue was found in Alexandria, which can scarcely be intended for any persons except Cleopatra and Antony hand in hand. The upper part of the female figure is in a state of tolerable preservation, and shows a young and attractive face. The male figure was doubtless sacrificed to Octavianus's command to destroy Antony's statues. We are indebted to Herr Dr. Walther, in Alexandria, for an excellent photograph of this remarkable piece of sculpture. Comparatively few other works of plastic art, in which we here include coins, that could render us familiar with our heroine's appearance, have been preserved."; $a=my_chunk($test, 300); print_r($a); ?>
  21. try <?php function build_menu($data, $id=0, $pre=' '){ foreach ($data[$id] as $row){ if (isset($data[$row['menu_id']])){ echo "$pre<li><a class=\"MenuBarItemSubmenu\" href=\"#\">".$row[menu]."</a>\n"; echo "$pre <ul>\n"; build_menu($data, $row['menu_id'], $pre.' '); echo "$pre </ul>\n$pre</li>\n"; } else echo "$pre<li><a href=\"#\">$row[menu]</a></li>\n"; } } mysql_connect('localhost', 'root', '') or die(mysql_error()); mysql_select_db('test'); $res = mysql_query('SELECT * FROM menus') or die(mysql_error()); while ($row = mysql_fetch_assoc($res)) $data[$row['parent_menu_id']][] = $row; //print_r($data); echo '<ul id="MenuBar1" class="MenuBarVertical">',"\n"; build_menu($data); echo '</ul>'; ?>
  22. OK you want to change 'Item blah' and '#' in href with data from your database how you store menu in database?
×
×
  • 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.