sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
try echo '<center>'; foreach ($Day as $D) { echo '<a style="font-size: 80pt; font-family:Arial; font-weight:bolder">'.$D.'</a>'; } echo '</center>';
-
try <?php eval('$x = '. $newspaper['articles'].';'); print_r($x['articles']['left']); ?>
-
change '".($phfolder == '1' ? '3' : '').($phfolder == '2' ? '2' : '').($phfolder == '3' ? '1' : '')."', to '".(4 - $phfolder)."',
-
change <? if ($_POST["submit"]) { $title = $_POST["title"]; $who = $_POST["author"]; $sql = "UPDATE book SET title='$title',author='$author' WHERE id=$id" or die(mysql_error()); $result = mysql_query($sql); echo "Thank you! Information updated."; } } ?> tochange <? if ($_POST["submit"]) { $title = $_POST["title"]; $who = $_POST["author"]; $id = $_POST['id']; $sql = "UPDATE book SET title='$title',author='$who' WHERE id=$id"; $result = mysql_query($sql) or die(mysql_error()); echo "Thank you! Information updated."; } } ?>
-
your code works this 1st replace all 'a' to 'z', then 'b' etc. code in last iteration replace back 'z' to 'a'
-
$test = "{$info['v']}"; $test = preg_replace('/;\d:/',']$0[',$test);//change , to ; $test = preg_replace('/^\d:/','$0[',$test);//change ( to ^ (start of string) $test .= ']'; // ad ] to end echo $test;
-
$sql = 'SELECT * FROM objects WHERE zupanija = "obiteljske"'; $box=$_POST['box']; while (list ($key,$val) = @each ($box)) { $sql .= '' . $val . '';} $sql .= ' ORDER BY id DESC'; add order by outside while loop
-
try <?php $arr_tower = ""; //$FOLDER=401; if ($FOLDER == "101") $arr_tower = ('kba'); if ($FOLDER == "201") $arr_tower = ('kba'); if ($FOLDER == "301") $arr_tower = ('uni'); if ($FOLDER == "401") $arr_tower = ('uni'); echo 'FOLDER = '. $FOLDER . ' so Tower = '. $arr_tower; echo ' --- foreach ('.$arr_tower.' as $key=>$tower)'; $kba = array(0=>"U1/2", 2=>"T2A", 3=>"U3", 4=>"U5/6", 5=>"T7"); $uni = array(0=>"T1", 1=>"T2", 2=>"T3", 3=>"T4", 4=>"T5", 5=>"T6", 6=>"T7", 7=>"T8", 8=>"T9", 9=>"T10"); echo "<table>"; foreach ($$arr_tower as $key=>$tower) { $k = key($$arr_tower); $val = $key + '15'; echo '<tr><td>'. $key .' => '. $tower. ' = '. $val .' --> '. $pbupdate[$val].'</td></tr>'; }; echo "</table>"; ?>
-
look <?php function my_next(&$array){ $a = array_shift($array); array_push($array, $a); return $a; } $test = array('a', 'b', 'c'); $i = 0; while ($i++ < 10){ echo my_next($test); } ?>
-
<?php $test = 'lV={1:0,1,0,0,0,0,7:0,2,0,1,1,1,8:0,3,0,1,1,1,9:0,4,0,1,1,1,3:1,1,0,1,0,1,4:1,2,1,1,0,1,2:2,1,0,0,0,0,6:2,2,0,1,1,1,5:2,3,0,1,1,1}'; $test = preg_replace('/,\d:/',']$0[',$test); $test = preg_replace('/{\d:/','$0[',$test); $test = str_replace('}', '])', $test); echo $test; ?>
-
[SOLVED] Array PRO needed! Data driven form Array data, aaarrgh!
sasa replied to methodman's topic in PHP Coding Help
try <?php // the code to query the database and insert the new information - this doesn't seem to work at all... if(isset($_POST['submit'])) { // write the updates to the status table foreach ($_POST['notes'] as $status_id => $notes) { $curr_status = $_POST['radio'][$status_id]; $query = "UPDATE status SET curr_status = '$curr_status', notes = '$notes' " . "WHERE status_id = '$status_id' AND user_id = '$client_id'"; mysqli_query($dbc, $query)or die('ERROR UPDATING DB, status and notes were NOT updated'); } print_r($_POST); echo '<p>Your updates have been saved.</p>'; } //generate the updated form by looping through the status array echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?user_id=' . $_GET['user_id'] . '">'; echo '<h3>Client update</h3><br />'; $phase = $updates[0]['phase_name']; echo '<fieldset><legend>' . $updates[0]['phase_name'] . '</legend>'; foreach($updates as $update) { //only start a new fieldset if the phase has changed if($phase != $update['phase_name']) { $phase = $update['phase_name']; echo '</fieldset><fieldset><legend>' . $update['phase_name'] . '</legend>'; } //display the step form field echo '<label ' . ($update['curr_status'] == NULL ? 'class="error"' : '') . ' for="' . $update['status_id'] . '">' . $update['step_name'] . ':</label>'; echo '<input type="radio" id="' . $update['status_id'] . '" name="radio[' . $update['status_id'] . ']" value="2" ' . ($update['curr_status'] == 2 ? 'checked="checked"' : '') . ' /><span id="statusInc">Incomplete</span> '; echo '<input type="radio" id="' . $update['status_id'] . '" name="radio[' . $update['status_id'] . ']" value="1" ' . ($update['curr_status'] == 1 ? 'checked="checked"' : '') . ' /><span id="statusComp">Complete!</span><br />'; echo '<textarea id="notes" name="notes[' . $update['status_id'] . ']" rows="3" cols="80">' . $update['notes'] . '</textarea><br />'; $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die ('ERROR CONNECTING TO DATABASE'); $query = "INSERT INTO status (date) VALUES (NOW())"; $timestamp = mysqli_query($dbc, $query) or die ('ERROR with the timestamp query'); //echo date("D, d M y g a"); // the date must be sent in a post to register for each individual item } echo '</fieldset>'; echo '<input type="submit" value="Save updates" name="submit" />'; echo '</form>'; ?> -
<?php $sql = "SELECT DATEDIFF (ThinDate, CURDATE()) AS intval FROM `vegeschedule` "; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } while ($row = mysql_fetch_assoc($result)) { if ($row["intval"] <= 0) echo 'N/A'; else echo $row["intval"]; echo "<br />\n"; } ?>
-
ALTER IGNORE TABLE `table_name` ADD UNIQUE INDEX `xxx` (`field_1`, `field_2`, `field_3`, ...)
-
difficult to add page numbers to this pagination ?
sasa replied to Reaper0167's topic in PHP Coding Help
you must past $selecting to next page -
insert mysql_data_seek($result,0); before 2nd while loop
-
<?php class Inside { var $something = "Hey"; function __construct() { } } $first = new inside(); class SpaceShip { var $one = "on", $objInside; function __construct($paramOne) { $this->objInside = new Inside($paramOne); //NOT CORRECT } } $a = new SpaceShip('x'); echo $a->objInside->something; ?>
-
[SOLVED] Help counting the number of days in inventory
sasa replied to DBookatay's topic in PHP Coding Help
look datediff() mysql function -
try <?php $test = 'a,b,c,d'; echo '<ol><li>', str_replace(',','</li><li>',$test),'</li></ol>'; ?>
-
try <?php $aiList = mysql_query($query_ai, $contacts) or die(mysql_error()); $num_ai = mysql_num_rows($aiList); $list_ai = mysql_fetch_assoc($aiList); do { $listAI .= open_line(); $listAI .= create_cell($list_ai['ai_name'].'\line '.$list_ai['ai_address'], "50", "8" );//otput 1st data for ( $num_ai = 1; $num_ai < 2; $num_ai++) { $list_ai = mysql_fetch_assoc($aiList); // read next data row and output it $listAI .= create_cell($list_ai['ai_name'].'\line '.$list_ai['ai_address'], "50", "8" ); } $listAI .= close_line(); } while ($list_ai = mysql_fetch_assoc($aiList)); ?>
-
remove echo command before calling your function buildMenu
-
[SOLVED] Loop not giving me the result I want?
sasa replied to garethhall's topic in PHP Coding Help
move this part $print_options = array(); while($rw_options = mysql_fetch_assoc($rs_options)){ $print_options[] = $rw_options ; } before 1st while loop -
Calculating age in number of years and number of months
sasa replied to sheikhmdirfan's topic in PHP Coding Help
<?php function my_old($dob, $now = false){ if (!$now) $now = date('d-m-Y'); $dob = explode('-', $dob); $now = explode('-', $now); $old = $now[2]*12+$now[1]-$dob[2]*12-$dob[1]-($dob[0]>$now[0] ? 1 : 0); return array('year' => floor($old / 12), 'mnt' => $old % 12); } $x = my_old('29-4-2008', '29-4-2009'); print_r($x); ?> -
[SOLVED] Repopulating checkboxes from mysql database
sasa replied to upperbid's topic in PHP Coding Help
$pmethods = explode("¦¦", $r2["PaymentMethods"]); $choices = array('1'=>"Cashiers Check",'2' => "Money Order",'3'=>"Personal Check",'4'=>"Credit Card",'8'=>"PayPal"); foreach ($choices as $key6 => $value6) { $checked = in_array($key6, $pmethods) ? ' checked="checked"' : ''; echo "<input type=\"checkbox\" name=\"methods[]\" value=\"$key6\" $checked />$value6"; echo "</br>"; } -
change $result = mysqli_query($dbLayer, $sql) or die(mysqli_error()); while ($rs = mysqli_fetch_array($result)) { $fundid = $rs['fundingid']; $payments[] = $rs; } to $result = mysqli_query($dbLayer, $sql) or die(mysqli_error()); $payments = array(); //add this line while ($rs = mysqli_fetch_array($result)) { $fundid = $rs['fundingid']; $payments[] = $rs; }
-
<?php $p = $page/$limit+1; $start = max(1,min($p-5, $pages-10)); $end = min($pages, max($p+5, 11)); for ($i=$start; $i <= $end; $i++) { $ppage = $limit*($i - 1); if ($ppage == $page){ echo("<b>$i</b> \n");} else{ echo("<a href=\"$PHP_SELF?section=first&query=$query&page=$ppage&limit=$limit\">$i</a> \n");} } ?>