-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
[SOLVED] please help to generate html select from an array
MadTechie replied to tomasd's topic in PHP Coding Help
oops single quote <?php $stack = Array ( 1 => 'Accounting', 2 => 'Banqueting', 3 => 'Executive Office', 4 => 'Front Office', 5 => 'Housekeeping', 6 => 'Human Resources', 7 => 'Kitchen', 8 => 'Loss Prevention', 9 => 'Mini Bar', 10 => 'Repairs & Maintenance', 11 => 'Revenue', 12 => 'Room Service', 13 => 'Sales & Marketing' ); $SelectedID = 4; $select = '<select name="user_department" id="user_department" size="1">'."\n"; foreach($stack as $key => $value) { $Selected = ($key == $SelectedID)?"selected":""; $select .= "\t".'<option '.$Selected.' value="'.$key.'">' . $value.'</option>'."\n"; } $select .= '</select>'; echo $select; ?> -
print("test","test2"); will fail echo("test1","test2"); will work..
-
someone said theirs a speed differents (depending on what your doing) but from what i know,, theirs none
-
[SOLVED] please help to generate html select from an array
MadTechie replied to tomasd's topic in PHP Coding Help
Oppp edited the one above.. updated -
cool i know that was probably a pain but it helps laters :-\ don't hate me
-
wrong one If starts a block ie <?php if( $a == $b) { echo "hello "; echo "world" } ?> Quote this post to see the how to fix (or try to find it, as your intrested in learning bug finding is key) if ($_SESSION['view'] == 10); { to if ($_SESSION['view'] == 10) {
-
[SOLVED] please help to generate html select from an array
MadTechie replied to tomasd's topic in PHP Coding Help
Try this (slighlty more advanced) <?php $stack = Array ( 1 => 'Accounting', 2 => 'Banqueting', 3 => 'Executive Office', 4 => 'Front Office', 5 => 'Housekeeping', 6 => 'Human Resources', 7 => 'Kitchen', 8 => 'Loss Prevention', 9 => 'Mini Bar', 10 => 'Repairs & Maintenance', 11 => 'Revenue', 12 => 'Room Service', 13 => 'Sales & Marketing' ); $SelectedID = 4; $select = '<select name="user_department" id="user_department" size="1">'."\n"; foreach($stack as $key => $value) { $Selected = ($key == $SelectedID)?"selected":""; $select .= "\t".'<option $Selected value="'.$key.'">' . $value.'</option>'."\n"; } $select .= '</select>'; echo $select; ?> -
Oh LOL yeah ; ends a statement see IF you can find the problem try 10 attempts i think thats too many hints
-
i knew that , thanks i feel like a noob now
-
not really.. depends on the code!! re-design
-
[SOLVED] please help to generate html select from an array
MadTechie replied to tomasd's topic in PHP Coding Help
what about <?php $SelectedID = 4; $select = '<select name="user_department" id="user_department" size="1">'."\are\n"; echo '<option value="'.$SelectedID.'">' . $stack[$SelectedID].'</option>'."\are\n"; foreach($stack as $key => $value) { if($key != $SelectedID) { $select .= "\t".'<option value="'.$key.'">' . $value.'</option>'."\are\n"; } } $select .= '</select>'; ?> -
<?php session_start(); if ($_SESSION['view'] == 10); { unset($_SESSION['view']); } if ( isset($_SESSION['view']) ) //somthing is missing here { //Ahh thats better $_SESSION['view']++; //add's 1 else { $_SESSION['view'] = 1; } echo "Views: " .$_SESSION['view']. "<br> This will reset after 10 refreshes."; ?>
-
thanks Daniel that gave me a kick my replie
-
try this <?php $sql = "SELECT * FROM images WHERE page='$page' AND descriptions='header'"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc ($result)) { $imageurl[] = $row['imagename'] . '.' . $row['type']; if($row['descriptions']!="header"){die("ERROR");} } ?> what happens
-
can you post it in code tags please.. as you code is altered by the form.. PREVIOUS will only be a link on pages greater than 1
-
nothing try this echo $var; as $var isn't set thiers nothing to echo, same when you unset.. it no longer exists (so isset will be false) but $var=""; will echo nothing but isset will be true as it exists but contains an empty string.. make sense ?
-
Cool is that a new addition ? (unsolved that is) in anycase i am going to list my reasons. but also note i shouldn't have to justify them as its not in any agreement.. bunch of fools.. indeed anyone know how cron can be claessed as "a thing of the past" is their something new i have missed!
-
and whats the "problem" PS you missed session_start();
-
can you echo $sql and post the results please
-
please use code tags and what appears as text not hyperlinks ?
-
you really should use code tags and whats the problems i got confused what you was asking half way down
-
i used unset first to make the isset fail thus setting it back to 1 hope that makes sense
-
well mine uses the refeash.. :-\
-
Oh Great Andy is in this thread.. Sighs.. i would like to point out this is not a my best work but its basic <?php session_start(); $wait = 30; //unset($_SESSION['time']); if( !isset($_SESSION['time']) ) { $_SESSION['time']=time(); echo "Started"; }else{ if(time() >= $_SESSION['time']+$wait) { echo "Done"; //include("hiddenpage.html"); }else{ echo $wait -(time() - $_SESSION['time']); echo "<meta http-equiv='refresh' content='0.5'>"; } } ?> waits for andy to create a great example in 0.2 seconds leaving mine in a bundle of smoke lol i know its not great ok...
-
use number_format($save - $retail, 2, '.', ''); as number_format will round up