Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try <?php include('odbc.php'); $sql = odbc_exec("select * from Product1 ORDER BY catfield"); // <-- change this line $prevCat=''; while($row = odbc_fetch_array($sql)) { $title = $row["titlefield"]; $id = $row["idfield"]; $price = $row["pricefield"]; $categorie = $row["catfield"]: // has category changed ? // if so, print it if ($categorie != $prevCat) { echo "<h2>$categorie</h2>"; } echo $title, ' ', $price, '<br/>'; $prevCat = $categorie; } ?>
  2. try <?php $a = 10000000000; echo number_format($a,','); ?>
  3. use nl2br() function try <?php $a='These are my notes. These notes doe not make any sense but it gets the point across. '; echo nl2br($a) ?>
  4. you don't pas any value to function check_number_of_results() but in definition of it it need 3 try if (isset($submit)) { //check_number_of_results(); check_number_of_results($field_name, $input_field, $submit); }
  5. or tray $rounded = round($actualtime/15)*15
  6. remove 1st row from function multiple_rows() function multiple_rows($query, $result, $nums) { //$multiple_row = mysql_fetch_assoc($result); echo "<table id='results_table'><tr><th>Case Number</th><th>Client Reference Number</th></tr>"; while ($multiple_row = mysql_fetch_assoc($result)) { echo "<tr><td>{$multiple_row['case_number']}</td><td>{$multiple_row['client_reference']}</td></tr>"; } return; }
  7. or try function add_to_categories ($categories, $prodid) { if (strstr($categories, ",")) { $cats = explode (",", $categories); //explode from comma } else { $cats[] = $categories; } foreach ($cats AS $cat_to_add) { $main = $main ? 'N' : 'Y'; $sql = "insert into table1 (id, testdata, main) values ('', '$cat_to_add', '$main') "; $query = mysql_query($sql); } }
  8. <?php mysql_connect('localhost'); mysql_select_db('test'); $table_name = 'matches'; //change to your table name $sql = "SHOW TABLE STATUS LIKE '$table_name'"; $res = mysql_query($sql) or die(mysql_error()); $r = mysql_fetch_array($res); echo 'Next auto increment number for table ', $table_name, ' is ', $r['Auto_increment']; ?>
  9. if $col_value is string that $col_value[0] is just 1st caracter of it try substr($col_value, 0, 10) . "...<a href='/idcomment.php'>(More)</a>
  10. you don't close your last for and if bloks ad two } on the end change line if ( $NBPics==$NBPicswidth ) { $NBPics=0; ?> to if ( $NBPics==$NBPicswidth ) { $NBPics=0; }}?>
  11. try <?php function array_delete(&$arr, $value) { $keys = array_keys($arr, $value); foreach ($keys as $key) unset ($arr[$key]); } $letters = array (a,b,c,d,e,f); array_delete($letters, 'd'); print_r($letters); ?>
  12. try <?php session_start(); //1st generat $array_text_files with all text files in it $a_text_files = array('one','two' ,'sasa','angelina', 75, 'is it works?'); if (!array_key_exists('rand_text_files', $_SESSION)) $_SESSION['rand_text_files'] = $a_text_files; if (count($_SESSION['rand_text_files']) == 0) $_SESSION['rand_text_files'] = $a_text_files; shuffle($_SESSION['rand_text_files']); $rand_text = $_SESSION['rand_text_files'][0]; // unset($_SESSION['rand_text_files'][0]); //prevent repeats // do what you want with $rand_text echo $rand_text; ?>
  13. try <?php $n = 4; $a='14 5 8 7 2 12 6 5 7 8 3 9 2 4 6 10'; $a1 = explode("\n",$a); $a = array(); $i = 0; foreach ($a1 as $v) $a[$i++] = explode(' ',$v); for ($i = 0; $i < $n; $i++) {$m[$i] = $i; $cost_total += $a[$i][$i];} do { $save = 0; for ($i = 0; $i < $n-1; $i++){ for ($j = $i+1; $j < $n; $j++){ $cost = $a[$i][$m[$j]] + $a[$j][$m[$i]] - $a[$i][$m[$i]] - $a[$j][$m[$j]]; if ($cost < $save) { $save = $cost; $change = array($i, $j); } } } if($save){ $cost_total += $save; $tmp = $m[$change[0]]; $m[$change[0]] = $m[$change[1]]; $m[$change[1]] = $tmp; } } while ($save); echo 'Totl time ', $cost_total, "\n"; for ($i = 0; $i < $n; $i++) echo 'Machine ', $i + 1, ' - job ', $m[$i] + 1, "\n"; ?>
  14. "return" keyword end the function
  15. try <?php function theme_definition_list($dt_data, $dd_data, $title = NULL) { if (isset($title)) { $output .= '<h3>'. $title .'</h3>'; } $dt_data = array_values($dt_data); $dd_data = array_values($dd_data); $output .='<dl>'."\n"; for ($i = 0; $i < count($dt_data); $i++){ $output .= '<dt>'.$dt_data[$i].'</dt>'."\n"; $output .= '<dd>'.$dd_data[$i].'</dd>'."\n"; } $output .='</dl>'."\n"; return $output; } $a = array('one','two','three'); $b = array('1','2','3'); $c = 'title'; $show_output = theme_definition_list($a, $b, $c); print_r($show_output); ?>
  16. try echo '<tr bgcolor="' . $bg . '"> <td align="left">' . $row['BrotherName'] . '</td> <td align="left">' . $row['attend_status'] . '</td> <td><select name="updated"> <option', $x = $row['attend_status'] == 'Present' ? ' selected="selected"' : '' ,'>Present</option> <option', $x = $row['attend_status'] == 'Excused' ? ' selected="selected"' : '' ,'>Excused</option> <option', $x = $row['attend_status'] == 'Unexcused' ? ' selected="selected"' : '' ,'>Unexcused</option> </select></td> </tr> ';
  17. try <?php $a = '1191707001'; echo date('Y/m/d h:i:s', $a); ?>
  18. look date() function
  19. try <?php $a = 'sasa'; for ($i = 0; $i < strlen($a); $i++) echo $a[$i], "<br />\n"; ?>f/code]
  20. try $menu = array(array('active' => FALSE, 'link' => 'about.php', 'name' => 'About'), array('active' => FALSE, 'link' => 'news_archive.php', 'name' => 'News Archive'=, array('active' => FALSE, 'link' => 'screenshots.php', 'name' => 'Screenshots'));
  21. i don't understund your problem is user input full last name or just part of it is user input somethin from first name can you post some example what user input, and what script must return
  22. i don't test code and i see that i make same mustakes try $whereNow = ($_GET['whereNext']) ? $_GET['whereNext'] : '0'; //startin from 1st record $sqlQuery = "select * from table where authorised='true' limit $whereNow, 1"; //i don't figure out haw it output authorised='false' $sql = mysql_query($sqlQuery); $recordQuery = mysql_query("select count(*) as total from table where authorised='true' ");// add criteria $recordResult = mysql_result($recordQuery, "total"); $previous = ($whereNow == 0) ? $recordResult - 1: ($whereNow-1);// before 1st is last $random = rand(0, $recordResult - 1); $next = ($whereNow == $recordResult - 1) ? 0 : ($whereNow+1); // after last is 1st what is hapend in your code if you delete one row from table?
  23. try $sql="select * from my_table where last='$query' ORDER BY first";
  24. try $query2 = "SELECT * FROM main_item WHERE childof = '" . $row[id] . "'";
×
×
  • 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.