sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
you can do all job wit SQL look http://dev.mysql.com/doc/refman/5.1/en/insert-select.html and http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_trim
-
yes i see [attachment deleted by admin]
-
try <?php $test = 'Sten1986 folds Denis2391 folds hesims raises to $1 Raphaln123 folds Southlander calls $0.90 d3dsheep raises to $3.75'; preg_match('/Southlander (folds|raises|calls)/', $test, $out); print_r($out[1]); ?>
-
i try this part of code <html> <body bgcolor="#8cc63e" > <font face="Verdana" style="font-size: 24" color="white"> <?php $time=time()+20; $target=date("m/d/Y h:i:s A",$time); echo $target."<br><br>"; ?> <script language="JavaScript"> // TargetDate = "07/05/2010 9:00 AM" //By Default TargetDate = "<?php echo $target; ?>"; //mine entered BackColor = "#8cc63e"; ForeColor = "white"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = " %%S%% "; FinishMessage = "HELLO"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> </font> </body></html> an it works for me
-
you are in right way to set that variables what is error
-
try <?php $test = '<bold>Our Services Include:<endbold> <bullet>Construction<endbullet><bullet>Landscaping<endbullet>'; $test = preg_replace('/<bold>(.*?)<endbold>/s', '<strong>$1</strong>', $test); $test = preg_replace('/<bullet>(.*?)<endbullet>/s', '<li>$1</li>', $test); $test = preg_replace('/<li>.*<\/li>/s', '<ul>$0<br /></ul>', $test); echo $test; ?>
-
try $price_ex_VAT = $price * 40 / 47;
-
change for ($j=0; $j < pages_to_parse; $j++) to for ($j=1; $j <= pages_to_parse; $j++)
-
ups i mean $arrayValue = is_array($arrayValue) ? $arrayValue : trim($arrayValue);
-
try to add $arrayValue=trim($arrayValue); to the begin of foreach loop
-
try <?php $haystack = Array ( 1 => Array ( 'Name' => 'Aberdeen', 'Status' => 'Ready', 'Location' =>'', 'Jobs' => 0, 'Model' => 'HPUniversalPrintingPCL6', 'Comment' => 'PRINT_EARL' ), 2 => Array ( 'Name' => 'Alabama', 'Status' => 'Ready', 'Location' => 'GroundFloorArea012', 'Jobs' => 0, 'Model' => 'RICOHAficioSP4100NPCL6', 'Comment' => 'PRINT_Grd_F' ), 3 => Array ( 'Name' => 'Almond', 'Status' => 'Ready', 'Location' => '', 'Jobs' => 0, 'Model' => 'HPUniversalPrintingPCL6', 'Comment' => 'PRINT_EARL' ), 'PRINT_EARL' => array(1,2,3) ); $needle = "PRINT_EARL"; echo $needle; //print_r ($haystack); $x = my_multidimArrayLocate($haystack,$needle); print_r($x); function my_multidimArrayLocate($haystack, $needle){ $arrayResult = array(); if (!is_array($haystack)) return false; foreach($haystack as $key => $arrayValue){ if ((string) $key == (string) $needle) $arrayResult[$key] = $arrayValue; else { if (is_array($arrayValue)){ if ($x = my_multidimArrayLocate($arrayValue, $needle)) $arrayResult[$key] = $x; } else if ((string) $needle == (string) $arrayValue) $arrayResult[$key] = $arrayValue; } } return $arrayResult; } $x = 'as' == 0; var_dump($x); ?>
-
try <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); $url = $_SERVER["REQUEST_URI"]; echo '<div id="page">'; echo '<div id="content">'; if (!isset($_GET['sort'])) $_GET['sort'] = 'animation'; if ($_GET['sort'] == 'animation') $cat=1; elseif ($_GET['sort'] == 'basics') $cat=2; $pagenum = $_GET['pagenum']; if (!(isset($pagenum))) { $pagenum = 1; } $data = mysql_query("SELECT * FROM tutorials WHERE category='".$cat."'") or die(mysql_error()); $rows = mysql_num_rows($data); $page_rows = 5; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $result = mysql_query("SELECT * FROM tutorials WHERE category = '".$cat."' $max") or die(mysql_error()); while($row = mysql_fetch_object($result)) { echo '<div class="post">'; echo '<p class="meta">'; echo $row->fullname. ' | ' .$row->name; echo '</a>'; echo '</p><div class="entry">'; echo '<center>' . $row->path .'<br>'; echo $row->description; echo '</center></div></div>'; } echo " Page $pagenum of $last <p>"; if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?".$_GET['sort']."&pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?sort=".$_GET['sort']."&pagenum=$previous'> <-Previous</a> "; } echo " ---- "; if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?sort=".$_GET['sort']."&pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?sort=".$_GET['sort']."&pagenum=$last'>Last ->></a> "; } echo '<div class="post">'; echo '<p class="meta">Choose a Category'; echo '</p><div class="entry">'; echo '</div></div>'; echo '</div>'; include('footer.php'); ob_flush(); ?>
-
OK [attachment deleted by admin]
-
groupt records by category and splitting with sub-headings
sasa replied to adambedford's topic in PHP Coding Help
//query database $cur_cat=''; while($row = ...){ if($row['t_Category'] != $cur_cat){ echo $row['t_Category']; $cur_cat = $row['t_Category']; } // echo rest of data } -
i didnt scroll to the end of form and don't made all changes <!-- begin roll form --> <form id="roll" name="roll" method="post" action="roll_submit_process.php"> <table width="300" border="1" cellpadding="5" class="shop" align="center"> <tr> <th><div align="center" class='ContentText'>Student Name</div></th><th width="40"><div align="center" class='ContentText'>Roll</div></th></tr><tr> <?php include('includes/connection.php'); $result = mysqli_query($connection,"SELECT * FROM students WHERE tutor_1='$user' ORDER BY last_name ASC") or die(mysqli_error($connection)); $i=0; while($row = mysqli_fetch_array($result)) { $id = $row['id']; $i++; $first_name = $row['first_name']; $last_name = $row['last_name']; $week = "2"; $term = "1"; $year = "2010"; echo "<td align='left'><p><strong>".$last_name . "</strong> " . $first_name ."</p></td>"; echo "<td align='center' width='40'>"; echo "<input type='hidden' name='first_name[$i]' value='$first_name' />"; echo "<input type='hidden' name='last_name[$i]' value='$last_name' />"; echo "<input type='hidden' name='week[$i]' value='$week' />"; echo "<input type='hidden' name='term[$i]' value='$term' />"; echo "<input type='hidden' name='year[$i]' value='$year' />"; echo "<input type='hidden' name='id[$i]' value='$id' />"; echo "<input type='checkbox' name='attendance[$i]' value='1' />"; echo "</td>"; echo "</tr>"; } ?> </table> <p> </p <p align="center"><input name="Submit" type="submit" value="Submit Roll" /></p> </form> <!-- End roll form --> </html> add array index to the reest of array elements
-
change form to <!-- begin roll form --> <form id="roll" name="roll" method="post" action="roll_submit_process.php"> <table width="300" border="1" cellpadding="5" class="shop" align="center"> <tr> <th><div align="center" class='ContentText'>Student Name</div></th><th width="40"><div align="center" class='ContentText'>Roll</div></th></tr><tr> <?php include('includes/connection.php'); $result = mysqli_query($connection,"SELECT * FROM students WHERE tutor_1='$user' ORDER BY last_name ASC") or die(mysqli_error($connection)); $i=0; while($row = mysqli_fetch_array($result)) { $id = $row['id']; $i++; $first_name = $row['first_name']; $last_name = $row['last_name']; $week = "2"; $term = "1"; $year = "2010"; echo "<td align='left'><p><strong>".$last_name . "</strong> " . $first_name ."</p></td>"; echo "<td align='center' width='40'>"; echo "<input type='hidden' name='first_name[$i]' value='$first_name' />"; echo "<input type='hidden' name='last_name[$i]' value='$last_name' />"; echo "<input type='hidden' name='week[$i]' value='$week' />"; echo "<input type='hidden' name='term[$id]' value='$term' />"; echo "<input type='hidden' name='year[]' value='$year' />"; echo "<input type='hidden' name='id[]' value='$id' />"; echo "<input type='checkbox' name='attendance[]' value='1' />"; echo "</td>"; echo "</tr>"; } ?> </table> <p> </p <p align="center"><input name="Submit" type="submit" value="Submit Roll" /></p> </form> <!-- End roll form --> </html> and process page to <?php require_once("includes/tutor_session.php"); ?> <?php require_once("includes/connection.php"); ?> <?php foreach ($_POST['id'] as $i => $id) { //I know I am escaping data that came only from the database - I didn't bother editing my copy and pasted snippet! $first_name = mysqli_real_escape_string($connection,$_POST['first_name'][$i]); $last_name = mysqli_real_escape_string($connection,$_POST['last_name'][$i]); $week = mysqli_real_escape_string($connection,$_POST['week'][$i]); $term = mysqli_real_escape_string($connection,$_POST['term'][$i]); $year = mysqli_real_escape_string($connection,$_POST['year'][$i]); $attendance = $_POST['attendance'][$i]; mysqli_query($connection,"INSERT INTO roll (first_name, last_name, week, term, year, attendance) VALUES ('$first_name', '$last_name', '$week', '$term', '$year','$attendance')")or trigger_error("SQL", E_USER_ERROR); } header("Location: tutorcp.php"); exit; ?> not tested
-
groupt records by category and splitting with sub-headings
sasa replied to adambedford's topic in PHP Coding Help
1st order query by category 2nd set variable $curent_cat to something that can be category 3rd when browse records check varijable $curent_cat again category in record and if it diferent echo subhead and set $curent_cat to category from record out of if block echo rest of data -
add ORDER BY `group` to the end of your query
-
try if(is_dir(rtrim($directory,'/').'/'.$file))
-
Problems with explode and implode - values partially being erased
sasa replied to sleepyw's topic in PHP Coding Help
try $color_exploded = explode(", ", $rows['color']); if(is_array($color_exploded)) { while (list ($key, $color_val) = each ($color_exploded)) { echo "<option value='" . $color_val . "' selected>" . $color . "</option>"; //add some ' } } -
split $arr array in part with same $c and execute script on this parts
-
try <?php $words = str_word_count($str,1); $word1=$words; while ($index = array_search($search, $word1)){ $word1[$index]=''; echo implode(' ',array_slice($words, $index - 10, 20, true)); echo "<br />\n"; } ?>
-
preg_match with variables. how escape forward slash in variable
sasa replied to becu's topic in PHP Coding Help
$end='<\/title>';