Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. some like this <?php $count = 0; echo '<table border="3">'; for ($i=0;$i<10;$i++){ //start loop if ($count == 0) echo '<tr>'; $count++; echo '<td>',$i,'</td>';// echo some data in td tag if ($count == 3){ echo '</tr>'; $count=0; } } //end loop if ($count>0){ for (;$count<3;$count++) echo '<td> </td>'; echo '</tr>'; } echo '</table>'; ?>
  2. for your 1st code try <?php $_POST['Bin'][23]='Throw Away';//posted by form $ids = array_keys($_POST['Bin']); echo $id = strtolower(mysql_real_escape_string(stripslashes($ids[0]))); ?>
  3. change line $array_of_subscribers.="'".$array_user_id."'".$array_comma; to $array_of_subscribers[]=$array_user_id; and if(in_array($needle, $test_array)){ to if(in_array($needle, $array_of_subscribers)){
  4. try <?php $i = 1; $data = fgetcsv($handle, 1000, ","); while ($data !== FALSE) { // check if last loop if (($data1 = fgetcsv($handle, 1000, ",")) == false){ echo 'last loop'; } print_r($data); $i++; $data = $data1; } ?>
  5. http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_if
  6. UPDATE menu SET `menu_order` = IF( menu_order =$old_position, $new_position, $old_positon ) WHERE menu_order IN ( $old_position, $new_position )
  7. <?php foreach($_POST['title'] as $key => $value){ //code here $caption = $_POST['caption'][$key]; echo "Title is $value and caption is $caption<br />\n"; } ?>
  8. try <?php $array_of_pos = array(1,2,3,4,5); for ($i=0;$i<10000;$i++){ foreach ($array_of_pos as $pos) //create new value foreach positions $tmp[$pos] = ($pos + 7) * rand(); asort($tmp);//sort new array $tmp = array_flip($tmp); $first = array_shift($tmp);//get 1st element $out[]=$first; // put element for analise } $distribution = array_count_values($out); ksort($distribution); print_r($distribution); ?>[7php]
  9. form field named city doesn't exist in form
  10. if you have 20 items per page and 3 columns it is 6 full rows + 2 items
  11. try <?php function remove_duplicate($items){ $count = count($items); $names = array(); $items1 = array(); for ($i = 0; $i < $count; $i ++) { if (!in_array($items[$i]->name, $names)){ $names[] = $items[$i]->name; $items1[] = $items[$i]; } } return $items1; } $items = remove_duplicate($items); ?>
  12. <?php echo 'Code 1:<br />'; $list = array(1,2,3,4); echo implode(', ', $list); echo "<hr />\n"; echo 'Code 2:<br />'; $list = array(1,2,3,4); $pre = ''; foreach ($list as $item){ echo $pre, $item; $pre = ', '; } echo "<hr />\n"; echo 'Code 3:<br />'; $list = array(1,2,3,4); $last = array_pop($list); foreach ($list as $item){ echo $item, ', '; } echo $last; echo "<hr />\n"; echo 'Code 4:<br />'; $list = array(1,2,3,4); $i = 0; while (isset($list[$i +1])){ echo $list[$i++], ', '; } echo $list[$i]; echo "<hr />\n"; //etc. ?>
  13. try <?php if (isset($_POST['Submit'])){ foreach ($_POST['data'] as $ID => $uValue) { mysql_query("UPDATE titles SET uValue='$uValue' WHERE ID='$ID'"); } } ?> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <table> <?php $UserID =3; //UserID as user id, uTitle as user title, uValue as description/value of title connect(); $query = "SELECT * FROM titles WHERE UserID = $UserID"; $result = mysql_query($query); if (mysql_num_rows($result)){ //$row = mysql_fetch_assoc($result); echo "<br /><b>Edit your data:</b> <br /><br />"; while($row = mysql_fetch_assoc($result)) { extract ($row); echo " <tr> <td><b>$uTitle</b></td> <td><input type='text' name='data[$ID]' value='$uValue'></td> </tr>"; } } else echo 'No data to edit'; ?> <tr><td><input type="submit" value="Submit"></td> </tr> </table> </form>
  14. $max = 10; $num = $page * $max - $max; $totalpage = ceil($lines / $max) + 1; // $page = 1; $show = 9; $start = (int) max(1, min($page - floor(($show - 1)/2), $totalpage - $show + 1)); $end = min($totalpage, $start + $show - 1); if ($page > 1) { echo "<a href=\"?action=index&p=".($page-1)."\"><span id=\"paging\">Previous</span></a> \n"; } else if($page <= 1) { echo "<span id=\"paging\">Previous</span> \n"; } for($i = $start; $i <= $end; $i++) { if($i == $page) { echo "<span id=\"paging\">$i</span> \n"; } else { echo "<a href=\"?action=index&p=".$i."\"><span id=\"paging\">$i</span></a> \n"; } } if ($page < $totalpage - 1) { echo "<a href=\"?action=index&p=".($page + 1)."\"><span id=\"paging\">Next</span></a>\n"; } else if($page >= $totalpage - 1) { echo "<span id=\"paging\">Next</span>\n"; }
  15. or <?php $list = array(1,2,3,4,5); $last_element = array_pop($list); foreach ($list as $element) { echo "$element isn't last.<br />\n"; } echo "$last_element is last.<br />\n"; ?>
  16. you didn't close bracket in IN part of query
  17. move lines $entriesperline=4; $counter=1; print "<table>"; before foreach loop
  18. echo '<div class="cat_name">[<a href="',$row_rssql['category_name'],'">',$row_rssql['category_name'],"</a>]</div>\n ";
  19. ups i made mistake in line 18 in posted code change $_SESSION['items']['$item_to_add']++; to $_SESSION['items'][$item_to_add]++;
  20. <style> .cat_name { display: inline; margin: 0 2 0 0; border: 2 solid red; padding: 2 6 3 6; color: white; background-color: blue; } </style>
  21. change lines for ($i=0;$i<count($_POST['box']);$i++) { } to $count = isset($_POST['box']) ? count($_POST['box']) : 0; for ($i=0;$i<$count;$i++) { }
  22. try <?php session_start(); if(isset($_GET['clearlist'])){ session_destroy(); }else{ $item_to_add = $_GET['item']; if ( ! isset ( $_SESSION['items'] ) ) { echo "no items set... adding item"; $_SESSION['items'][$item_to_add] = 1; } else { if ( ! isset($_SESSION['items'][$item_to_add] ) ) { echo "there is items, but this item doesn't exist"; $_SESSION['items'][$item_to_add] = 1; } else { echo "there is items, and this item exist, so adding to qty"; $_SESSION['items']['$item_to_add']++; } } if ( isset ( $_SESSION['items'] ) ) { foreach($_SESSION['items'] AS $key => $qty){ echo $key . "x" . $qty ."<br />"; } } else { echo "No Items exist!"; } } ?>
  23. while($row_rssql = mysql_fetch_assoc($rssql)) echo '<div class="cat_name">',$row_rssql['category_name'],"</div>\n"; and add CSS to format it
×
×
  • 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.