Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. btw. move line $i=0; outside while loop
  2. try function makeSelectCategories($id = 0, $spacing=""){ $q = "SELECT * FROM `categories` WHERE `cat_root` = ".$id; $r = mysql_query($q) or die(mysql_error()); $str = ''; //if(mysql_num_rows($r) == 0) //return false; while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $str .= "<option>".$spacing.$row['cat_title']."</option>"; $str .= makeSelectCategories($row['cat_id'], $spacing." "); } return $str; }
  3. try <?php // Connect to the database. require_once ('mysql_connect.php'); // Make the query. $query = "SELECT user_id, first_name, last_name, tgroup FROM users WHERE webaccess='2' ORDER BY tgroup, last_name ASC"; // Run the query. $result = @mysql_query ($query); // If the query ran w/o error, print out the results. if ($result) { // Table header. echo '<h3><span style="color: #af410d;">Current Faculty</span></h3> <table>'; $last_group = ''; // Fetch and print all the records. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { if ($row['tgroupd'] != $last_group){ echo ' <tr> <td width="20px"></td> <td>'.$row['tgroup'] . ' -</td> </tr>'; $last_group = $row['tgroup']; } echo ' <tr> <td width="20px"></td> <td>- <a href="teacherpages.php?id=' . $row['user_id'] . '">' . $row['first_name'] . ' ' . $row['last_name'] . '</a><br></td> </tr>'; } // Close the table. echo '</table>'; // Free up the resources. mysql_free_result ($result); } else { // If the query did not run successfully, print out an error message. echo 'No Teachers in the system'; } // Close the database connection. mysql_close(); ?> ?>
  4. i try you code on my local wamp, and it's work OK <?php $AAA = 'a'; $BBB = 'b'; $ezPhoneRun = 0; $ezPhoneCount = 100; // this value varies. while ($ezPhoneRun < $ezPhoneCount) { $ezAPCSCCounter = 0; $ezAPCSCDRCount = 1; //I have just added this here for your sake, the real value is a varied. while ($ezAPCSCCounter < $ezAPCSCDRCount) { if ($AAA != $BBB){ // do some code stuffs, loop $ezAPCSCCounter++; continue 0; } $ezAPCSCCounter++; } // END while ($ezAPCSCCounter < $ezAPCSCDRCount) { $ezPhoneRun++; } // end loop for isp's phone table loop ?> (just setup variables $AAA and $BBB)
  5. the error means that you call continue outside of any loop
  6. or <?php $nodeArray = array ( 1 => array( 2, 4, 5), 2 => array( 1, 3, 6), 3 => array( 2, 4, 7), 4 => array( 1, 3, , 5 => array( 1, 6, , 6 => array( 2, 5, 7), 7 => array( 3, 6, , 8 => array( 4, 5, 7) ); $startPoint = 7; $destination = 3; $path = array($startPoint => $startPoint); $new_nodes = array($startPoint); while (count($new_nodes) and !isset($path[$destination])){ $tmp =array(); foreach ($new_nodes as $node){ foreach ($nodeArray[$node] as $nnoode){ if (!isset($path[$nnoode])){ $tmp[] = $nnoode; $path[$nnoode] = $path[$node]. " -> $nnoode"; } } } $new_nodes = $tmp; } echo $path[$destination]; ?>
  7. remove any echo before header function
  8. last part should be // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } ?> </table>
  9. or <?php function str2int($in){ $out = round(pow(26, strlen($in))/25); $l = range('a', 'z'); $l = array_flip($l); $tmp = 0; for ($i = 0; $i<strlen($in); $i++){ $tmp = $tmp * 26 + $l[$in[$i]]; } return $out + $tmp; } function int2str($in){ $l = range('a', 'z'); $len = 0; $base = 1; while ($in >= $base){ $len++; $in -= $base; $base *= 26; } $out = ''; for ($i = 0; $i < $len; $i++){ $out = $l[$in % 26]. $out; $in = (int) $in / 26; } return $out; } echo int2str(335115), "\n"; echo str2int('zz') ?>
  10. $_POST['txtQty'] is NOT array change NAME property to txtQty[]
  11. try <form method="POST"> <input type="checkbox" value="A" name="le[]" />A<br /> <input type="checkbox" value="B" name="le[]" />B<br /> <input type="checkbox" value="C" name="le[]" />C<br /> <input type="submit" name="submit" value="any" /> <input type="submit" name="submit" value="all" /> </form> <?php if (isset($_POST['submit'])){ mysql_connect('localhost', 'root',''); mysql_select_db('test') OR die(mysql_error()); if ($_POST['submit'] == 'all'){ if (isset($_POST['le'])){ $sql = 'SELECT * FROM `link`'; foreach ($_POST['le'] as $i => $le){ $sql ='SELECT * FROM ('. $sql. ') as xx'.$i.' WHERE `link` LIKE "%'. $le. '%"'; } }else echo 'error,'; } if ($_POST['submit'] == 'any'){ if (isset($_POST['le'])){ $sql = 'SELECT * FROM `link` WHERE link LIKE "%'. implode('%" OR link LIKE "%', $_POST['le']). '%"'; }else echo 'error,'; } if ($sql){ $res = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_array($res)) echo "$row[id] -> $row[link]<br />\n"; } } ?>
  12. try <table> <?php $trclass_array = array('alt1', 'alt2'); $orderNo = ''; $color = 1; while ($ord_inf = mssql_fetch_array($result)) { if ($ordinf['ORDERNO'] != $orderNo) { $color = 1 - $color; $orderNo = $ordinf['ORDERNO']; } $trclass = $trclass_array[$color]; //... etc } ?> </table>
  13. try <?php foreach($rows as $k => $row) { foreach($speaker_array as $speaker) { if($row['entry_id'] == $speaker['entry_id']) { //array_push($row['speakers'], $speaker); $rows[$k]['speakers'][] = $speaker; } } } ?>
  14. try <?php $query = "select merchantid, count(*) as c from tblpmts where date >= date_sub(curdate(), interval 1 month) and date <= date_sub(curdate(), interval 1 day) group by merchantid"; $result = mysql_query($query); while ($data = mysql_fetch_array($result)) { $merchantid = $data["merchantid"]; $count = $data["c"]; } ?>
  15. and is evaluate before or try WHERE (job_tb.status = 'No' OR job_tb.cust_address = 'Cancel') AND user_id = id
  16. how you calculate the place where data go
  17. use str_pad function to change length of string before raplace it
  18. try <?php $text = 'u'; for ($i = 1; $i < 10; $i++) echo $text++,"\n"; ?> use ++ operator
  19. condition !is_array($temp[$i]) || !is_string($temp[$i]) || is_null($temp[$i]) is allways true if $temp[$i] is array 2nd part is true, if not true is 1st part
  20. ok let see your 1st if condition if (!isset($_COOKIE['UserID'])) { $ID = $_COOKIE['UserID']; $ID = mysql_real_escape_string($ID); echo "Sorry, you are not logged in. <a href='Login.php'>Login now</a>"; include('bottom.php'); exit; } it say if $_COOKIE NOT exist then $ID = something is it ok? are you setup $ID if $_COOKIE exist? (not read all code)
  21. or <?php $State = array( 0 => 20000, 1 => 20000, 2 => 0, 3 => 0, ); $ChoiceKey = array_search(min($State));; print_r($State); echo '<br><br>'; echo $ChoiceKey[0]; ?>
  22. try function vac_week($avg_array, $fav_temp) { $min = 10000; $out = 10000; for($k = 0; $k < 52; $k++) if(abs($avg_array[$k] - $fav_temp) < $min) { $out = $k; $min = abs($avg_array[$k] - $fav_temp); } echo 'Your Ideal vacation week is week ' . $out; }
  23. what is output of your script?
  24. try <?php // database connection... $sql="select * from what_ever"; $res=mysql_query($sql)or die(mysql_error()); $i =0; while($data=mysql_fetch_assoc($res)){ if ($i % 4 == 0) echo "<div class='details'> <ul class='categories'> "; $i++; echo" <li><a href='".$data['url']." class='Category'>".$data['Category']."</a></li>"; if ($i %4 == 0) echo" </ul> </div>"; } if ($i %4 > 0) echo" </ul> </div>"; ?>
×
×
  • 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.