PHP - How To Make Drop Down List That Read From Database
I am new to PHP and currently trying to develop a website... i am stuck at one place.
Lets say i'm a user(mrX) that has 4 types of car that are Ferrari, Lamborghini, Evo and BMW. So, i will register to the system about my details and all of my car info such as their cc, transmission, plat number, engine capacity. Then, i will log on into the system and after log on, there will be a drop down list. If i pick Ferrari for example, under the drop down list there will be all the information about the car. The same on the other car also. Similar TutorialsHi i have a drop down menu for date which is meant to insert all 3 values into a date column bt is only sending the year how can i fix it <select name="date_of_birth"> <option value="1">January <option value="2">February <option value="3">March <option value="4">April <option value="5">May <option value="6">June <option value="7">July <option value="8">August <option value="9">September <option value="10">October <option value="11">November <option value="12">December </select> <select name="date_of_birth"> <option value="1">1 <option value="2">2 <option value="3">3 <option value="4">4 <option value="5">5 <option value="6">6 <option value="7">7 <option value="8">8 <option value="9">9 <option value="10">10 <option value="11">11 <option value="12">12 <option value="13">13 <option value="14">14 <option value="15">15 <option value="16">16 <option value="17">17 <option value="18">18 <option value="19">19 <option value="20">20 <option value="21">21 <option value="22">22 <option value="23">23 <option value="24">24 <option value="25">25 <option value="26">26 <option value="27">27 <option value="28">28 <option value="29">29 <option value="30">30 <option value="31">31 </select> <select name="date_of_birth" id="year"> <?php $year = date("Y"); for($i=$year;$i>$year-50;$i--) { if($year == $i) echo "<option value='$i' selected>Current Year</option>"; else echo "<option value='$i'>$i</option>"; } ?> form example, in the first page, there is a article, it takes contents from database, if a article is shorter than 1000, it displays the full content on the first page, if its longer than 1000, it will display a short part of article, and displays a 'read more' on the end of the article. how to make this? I think we cant do this by paging function, can we? <html> <body> <script type='text/javascript'> var currenttime = new Date() var montharray=new Array('Jan','Feb','March','April','May','June','July','Aug','Sept','Oct','Nov','Dec') var serverdate=new Date(currenttime) function padlength(what){ var output=(what.toString().length==1)? '0'+what : what return output } function displaytime(){ serverdate.setSeconds(serverdate.getSeconds()+1) var timestring=padlength(serverdate.getHours())+':'+padlength(serverdate.getMinutes())+':'+padlength(serverdate.getSeconds()) document.getElementById('servertime').innerHTML=timestring+' MST ' document.getElementById('nav_servertime').innerHTML=timestring+' MST ' } window.onload=function(){ setInterval('displaytime()', 1000) } </script> </body> </html> <html> <head> <link rel="shortcut icon" href="http://www.toxicpets.co.uk/favicon.ico" > <meta name="description" content="toxicpets Is A FREE Online Virtual Pet Site For All Ages"> <meta name="keywords" content="Toxicpets, adopt, free, online, site, pets, kids, games, children, safe, virtual, fun, Jack, Wright"> <meta name="google-site-verification" content="BeR9LIHxeOGKgw90pAZG6o3dS-Ym3lxxPlH1LTgFiLY" /> <meta name="google-site-verification" content="JXFL8M3LU47SMJZ6aNi4u8BSyD8PWqsqlrORFHkvDfE" /> <meta name="CREATOR" content="Jack Wright"> <meta name="copyright" content="Copyright Toxicpets - 2010"> <meta name="author" content="Jack Wright"> <meta name="email" content="admin@toxicpets.co.uk"> <meta name="Charset" content="ISO-8859-1"> <meta name="Distribution" content="Global"> <meta name="Rating" content="General"> <meta name="Robots" content="INDEX,FOLLOW"> <meta name="Revisit-after" content="1 Day"> </body> </html> <?php $time = date("H"); if ($time <= 5 || $time >= 19) { $backgroundColor = "#3366FF"; $tableOutline = "#000000"; $topAndBottomBG = "#003399"; $topAndBottomText = "#FFFFFF"; $middleBG = "#99CCFF"; $middleTEXT = "#000000"; $reallyLight = "#DEF2FF"; $menuColor = "#FFFFFF"; $maincellColor = "#FFFFFF"; $maincellText = "#000000"; $menulinkColor = "#003399"; $mainlinkColor = "#003399"; $bottomlinkColor = "#FFFFFF"; } else { $backgroundColor = "#333333"; $tableOutline = "#333333"; $topAndBottomBG = "#000000"; $topAndBottomText = "#FFFFFF"; $middleBG = "#CCCCCC"; $middleTEXT = "#000000"; $reallyLight = "#F8F8F8"; $maincellColor = "#FFFFFF"; $maincellText = "#000000"; $menuColor = "#666666"; $menulinkColor = "#FFFFFF"; $menutextColor = "#FFFFFF"; $mainlinkColor = "#003399"; $bottomlinkColor = "#FFFFFF"; } // Page Colors // End Page Colors // Ranks ect if ($rank == { $admin_line .= "<br><a href=$base_url1/admin/admin.php?game=$game class=menu>Admin Panel</a><BR> <a href=$base_url1/dom.php>Show Maintenance?</a> "; } if ($rank == 5) { $admin_line .= "<p align=center>Admin Stuff: <br> <a class=menu href=# onClick=\"window.open('$base_url1/admin/admin_remote.php?game=$game','remote','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=200,height=60')\">Mute User</a> <br> <a class=menu href=$base_url1/warn_user.php?game=$game>Warn User</a>"; //$get = mysql_query("SELECT number FROM dom"); //if ($get = 1) //echo "<meta http-equiv='refresh' content='0;url=http://toxicpets.co.uk/down_for_maitenence.php'>"; //elseif ($get = 0) //echo "<meta http-equiv='refresh' content='0;url=http://toxicpets.co.uk/index.php'>"; } if ($rank == 7) { $admin_line .= "<br><a href=$base_url1/admin/admin.php?game=$game class=menu>Admin Panel</a>"; //$get = mysql_query("SELECT number FROM dom"); //if ($get = 1) //echo "<meta http-equiv='refresh' content='0;url=http://toxicpets.co.uk/down_for_maitenence.php'>"; //elseif ($get = 0) //echo "<meta http-equiv='refresh' content='0;url=http://toxicpets.co.uk/index.php'>"; } if ($rank == null) { $updateLine2 = "<p><a href=register.php?game=$game><img src=http://toxicpets.co.uk/images/nav_register.jpg width=113 height=101 border=0></a></p>"; //End Ranks } { } $rc = mysql_fetch_array( mysql_query("SELECT * FROM members2 WHERE id = '$userid'") ); $menu = "$updateLine2<p><ul id='MenuBar1' class='MenuBarVertical'> <li><a class='MenuBarItemSubmenu' href='#'>My Profile</a> <ul> <li><a href='#'>$username</a></li> <li><a href='#'>Control Panel</a></li> <li><a href='#'>Edit Profile</a></li> <li><a href='#'>Toxic Mail</a></li> <li><a href='#'><span id='nav_servertime'></span></a></li> </ul> </li> <li><a class='MenuBatItemSubmenu' href='/mypets.php?game=1'>Pets</a> <ul> <li><a href='/adopt.php?game=1'>Adoption Center</a></li> </ul> </li> <li><a class='MenuBarItemSubmenu' href='/index.php'>Explore</a> <ul> <li><a href='/index.php?game=$game'>Toxopada</a></li> <li><a href='/blanchills.php?game=$game'>Blanc Hills</a></li> <li><a href='/rija?game=$game'>Rija Mountian</a></li> </ul> </li> </li> <li><a class='MenuBarItemSubmenu' href='/games.php'>Games</a></li> <li><a class='MenuBarItemSubmenu href='#'>Your Stuff</a> <ul> <li><a href='/bank.php'>Slime: $points</a></li> <li><a href='#'>Hunger Level : $hungerLevel</a></li> <li><a href='/myitems.php'>Your Items</a></li> <li><a href='/myshop.php'>Your Shop</a></li> <li><a href='/rarerumble.php'>Rare Coins : $rc[rc]</a></li> </ul> </li> </ul> <script type='text/javascript'> var MenuBar1 = new Spry.Widget.MenuBar('MenuBar1', {imgRight:'../SpryMenuBarRightHover.gif'}); </script> </font></p>$admin_line <center> "; $userInfo = "<P><FONT SIZE=\"-1\"> Username: <A HREF=$base_url1/update_profile.php?game=$game class=menu>$display_name</A><BR> Hunger: <A HREF=$base_url1/myitems.php?game=$game class=menu><FONT SIZE=-1>$hungerLevel</A><BR> $pointVar: <a href=$base_url1/bank.php?game=$game>$points</a><BR> $rp_: <a href=$base_url1/bank.php?game=$game>???</a><BR>"; //PUT IN $rp_: TO ACTIVATE RP!!! //$rp___ $links = "<center><p><b><u>My Prefs</u></b></p></center> <center><a href=$base_url1/myitems.php?game=$game>Items</a><center> <center><a href=$base_url1/mypets.php?game=$game>Pets</a></center> <center><a href=$base_url1/nursery.php?game=$game>Nursery</a></center>"; // SearchBox $searchBox = "<form action=$base_url1/search.php?game=$game method=post><p align=center><INPUT TYPE=text NAME=command VALUE='' SIZE=8><BR><INPUT TYPE=submit NAME=submit VALUE='Do it'></P></form>";; //End SearchBox // Bottom Copyright $Time = "<span id='servertime'></span>"; $Toxicpets = "<a href=http://www.toxicpets.co.uk class=bottom>Run By ToxicPets.co.uk</a><br>"; $Terms = "<a href=$base_url1/tos.php?game=$game class=bottom>Terms/Rules</a>"; $Privacy = "<a href=$base_url1/privacy.php class=bottom>Privacy</a>"; $Upgrade = "<a href=upgrade.php?game=$game class=bottom>Upgrade to Premium Now!</a>"; $Sitemap = "<a href=http://toxicpets.co.uk/sitemap2.xml class=bottom onclick='return popitup('popupex.html')'>Sitemap</a>"; $copywrite =" $Time | $Toxicpets | $Terms | $Privacy | $Upgrade | $Sitemap "; //End Bottom Copyright // // // (C) // // // // CSS // //CSS INCUDED IN PHP// $openHTML = " <HTML> <HEAD> <center><TITLE>$gameName2 - $page_title</TITLE></center> <style><!-- INPUT {color:#000000; font: 9pt verdana; font-weight: none; text-decoration: none; background: $maincellColor; border: 1 solid $topAndBottomBG; } TEXTAREA {color:#000000; font: 9pt verdana; font-weight: none; text-decoration: none; background: $maincellColor; border: 1 solid $topAndBottomBG; } BUTTON {color:#000000; font: 9pt verdana; font-weight: none; text-decoration: none; background: $maincellColor; border: 0 solid $topAndBottomBG; } SELECT {color:#000000; font: 9pt verdana; font-weight: none; text-decoration: none; background: $maincellColor; border: 1 solid $topAndBottomBG; } INPUT {color:#000000; font: 9pt verdana; font-weight: none; text-decoration: none; background: $maincellColor; border: 1 solid $topAndBottomBG; } OPTION {color:#000000; font: 9pt verdana; font-weight: none; text-decoration: none; background: $maincellColor; border: 1 solid $topAndBottomBG; } RESET {color:#000000; font: 9pt verdana; font-weight: none; text-decoration: none; background: $maincellColor; border: 1 solid $topAndBottomBG; } SUBMIT {color:#000000; font: 9pt verdana; font-weight: none; text-decoration: none; background: $maincellColor; border: 1 solid $topAndBottomBG; } A:link { text-decoration: underline; color: $mainlinkColor; } A:visited { text-decoration: underline; color: $mainlinkColor; } A:hover { text-decoration: underline; color: $mainlinkColor; } A:active { text-decoration: underline; color: $mainlinkColor; } A:link.menu { text-decoration: underline; color: $menulinkColor; } A:visited.menu { text-decoration: underline; color: $menulinkColor; } A:hover.menu { text-decoration: underline; color: $menulinkColor; } A:active.menu { text-decoration: underline; color: $menulinkColor; } A:link.bottom { text-decoration: underline; color: $bottomlinkColor; } A:visited.bottom { text-decoration: underline; color: $bottomlinkColor; } A:hover.bottom { text-decoration: underline; color: $bottomlinkColor; } A:active.bottom { text-decoration: underline; color: $bottomlinkColor; } p { font-family: verdana; font-size: 11pt; color: black; } p.error { font-family: verdana; font-weight: bold; color: red; } p.white { font-family: verdana; color: white; } a.white { color: white; text-decoration: underline; } hr { margin: -1; } img { border: 0 } --></style> <script type=text/javascript src=popupBox.js></script> <script type='text/javascript'> var MenuBar1 = new Spry.Widget.MenuBar('MenuBar1', {imgRight:'../SpryMenuBarRightHover.gif'}); </script> <script src='../SpryMenuBar.js' type='text/javascript'></script> <link href='../SpryMenuBarVertical.css' rel='stylesheet' type='text/css' /> </HEAD> <BODY BGCOLOR=\"$backgroundColor\"> <TR BGCOLOR=\"#FFCC00\" width=100%> <TD VALIGN=bottom COLSPAN=2 HEIGHT=60 body background=\"bg.jpg\" width=12> <CENTER> <a href='http://www.toxicpets.co.uk/login.php' onMouseOver=\"image3.src='http://toxicpets.co.uk/login_over.png';\" onmouseout=\"image3.src='http://toxicpets.co.uk/login.png';\"><img name=\"image3\" src='http://toxicpets.co.uk/login.png' border=0></a> <a href='http://www.toxicpets.co.uk/logout.php' onMouseOver=\"image12.src='http://toxicpets.co.uk/logout_over.png';\" onMouseOut=\"image12.src='http://toxicpets.co.uk/logout.png';\"><img name=\"image12\" src='http://toxicpets.co.uk/logout.png' border=0></a> <a href='http://www.toxicpets.co.uk/mypets.php' onMouseOver=\"image1.src='http://toxicpets.co.uk/pets_over.png';\" onMouseOut=\"image1.src='http://toxicpets.co.uk/pets.png';\"><img name=\"image1\" src='http://toxicpets.co.uk/pets.png' border=0></a> <a href='http://www.index.php/explore.php' onMouseOver=\"image2.src='http://toxicpets.co.uk/explore_over.png';\" onMouseOut=\"image2.src='http://toxicpets.co.uk/explore.png';\"><img name=\"image2\" src='http://toxicpets.co.uk/explore.png' border=0></a> <a href='http://www.toxicpets.co.uk/forums.php' onMouseOver=\"image4.src='http://toxicpets.co.uk/forums_over.png';\" onMouseOut=\"image4.src='http://toxicpets.co.uk/forums.png';\"><img name=\"image4\" src='http://toxicpets.co.uk/forums.png' border=0></a> <a href='http://www.toxicpets.co.uk/clubs.php' onMouseOver=\"image6.src='http://toxicpets.co.uk/clubs_over.png';\" onMouseOut=\"image6.src='http://toxicpets.co.uk/clubs.png';\"><img name=\"image6\" src='http://toxicpets.co.uk/clubs.png' border=0></a> <BR style='padding:0;'> <a href='http://www.toxicpets.co.uk/shops.php' onMouseOver=\"image7.src='http://toxicpets.co.uk/shops_over.png';\" onMouseOut=\"image7.src='http://toxicpets.co.uk/shops.png';\"><img name=\"image7\" src='http://toxicpets.co.uk/shops.png' border=0></a> <a href='http://www.toxicpets.co.uk/upgrades.php' onMouseOver=\"image8.src='http://toxicpets.co.uk/upgrade_over.png';\" onMouseOut=\"image8.src='http://toxicpets.co.uk/upgrade.png';\"><img name=\"image8\" src='http://toxicpets.co.uk/upgrade.png' border=0></a> <a href='http://www.toxicpets.co.uk/updates.php' onMouseOver=\"image9.src='http://toxicpets.co.uk/news_over.png';\" onMouseOut=\"image9.src='http://toxicpets.co.uk/news.png';\"><img name=\"image9\" src='http://toxicpets.co.uk/news.png' border=0></a> <a href='http://www.toxicpets.co.uk/battle_center.php' onMouseOver=\"image10.src='http://toxicpets.co.uk/battle_over.png';\" onMouseOut=\"image10.src='http://toxicpets.co.uk/battle.png';\"><img name=\"image10\" src='http://toxicpets.co.uk/battle.png' border=0></a> <a href='http://www.toxicpets.co.uk/auctions.php' onMouseOver=\"image11.src='http://toxicpets.co.uk/auctions_over.png';\" onMouseOut=\"image11.src='http://toxicpets.co.uk/auctions.png';\"><img name=\"image11\" src='http://toxicpets.co.uk/auctions.png' border=0></a><BR style='padding:0;'> <TABLE BGCOLOR=\"$tableOutline\" CELLSPACING=1 CELLPADDING=0 WIDTH=\"95%\"> <TR BGCOLOR=\"#FFCC00\" width=100%> <TD VALIGN=bottom COLSPAN=2 HEIGHT=60 BGCOLOR=\"$topAndBottomBG\" width=12> <P ALIGN=right><FONT SIZE=\"+3\" COLOR=\"$topAndBottomText\"><B>$gameName</B></FONT></P> </TD> </TR> <TR> <TD VALIGN=top BGCOLOR=\"$menuColor\" width=120> $menu $userInfo $links $searchBox </TD> <TD VALIGN=top BGCOLOR='$maincellColor'><font color=$maincellText> "; $closeHTML = " </font></TD> </TR> </CENTER> </TABLE> </BODY> </HTML> <TR BGCOLOR='$topAndBottomBG'> <TD COLSPAN=150> <center><P align=center><FONT SIZE= '-1' color='$topAndBottomText'>$copywrite</FONT></P></center> </TD> </TR> "; ?> What I'm trying to do is allow people to change the order of their navigation bar. I don't have a problem doing this using a listbox to move the values up and down. But to start me off, I'd like to know how I can use CONCAT or explode to draw data from the DB and list it. To better understand: I have a database with a table called "navbar". I have the fields: ID, name, link, icon, caption What we'll be looking at most is the ID. The ID's range from 1-19, so 19 links on the navbar. They are extracted from the database like so: $navbar=$db->execute("select * from navbar"); for($i=1;$nav=$navbar->fetchrow();$i++) { $name=$nav['name']; $link=$nav['link']; $title=$nav['caption']; $image=$nav['icon']; ?> <tr> <td background="images/sub_btn.gif" class="norepeat" valign=top> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td></td> <td><img src="images/spacer.gif" width="198" height="1"></td> </tr> <tr> <td><img src="images/spacer.gif" width="1" height="19"></td> <td style="padding-left: 10px;" class=sub><img src=<?=$image?> width=13 height=13 align=absmiddle> <a target=middle href="<?=$link?>" class="sub_lnk" title='<?=$title?>'><?=$name?></a> </td> </tr> </table></td> </tr> <?}?> This is for my online game, so we then go to my players table and add a field called "navorder". The default value is: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 How would I, just for tests, lists the values from the navbar table, by ID, on the page? Example: My value is set to 1,2,3,4,5 When drawing the data, however I do it, would show: Link1 Link2 Link3 Link4 Link5 Now if I changed the order, with a listbox which I can do, would change it to 3,1,5,2,4 It would then show: Link3 Link1 Link5 Link2 Link4 Sorry if it seems confusing, I tried my best at explaining it. Someone told me to use the explode function, or CONCAT. I tried to read up on explode() but just got confused as to how to use it. If someone could tell me how to do this it'd be much appreciated Thanks! Hi again, i'm wondering how can i make Sort (for example a-z) an column in php reading mysql informations. Here's the script: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="table.css" type="text/css"> </head> <body style="margin: 0 0 0 0;"> <? include("passwd.php"); @$start = $_GET["start"]; if($start =='') $start =0; include("lib.php"); $link = mysql_connect($host,$username,$password); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db($db, $link); if (!$db_selected) { die ("Can't use $db : " . mysql_error()); } //total number of records in the table $res = mysql_query("SELECT * from `$table`"); @$rows = mysql_num_rows ($res); $result = mysql_query("SELECT * from `$table` limit $start,10"); if (!$result) { die('Invalid query: ' . mysql_error()); } echo "<p align=center class = 'menu'> Ocitana tabela: $table </p>"; $cols = mysql_num_fields($result); $records = mysql_num_rows ($result); echo "<table align='center' width='1200' >"; echo "<tr bgcolor='BBCCDD' class='menu'>"; for ($i = 0; $i < $cols;$i++) { echo "<td align='center'>".mysql_field_name($result,$i)."</td>"; } echo "</tr>"; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo "<tr bgcolor='F6F6F6' class='normal'>"; foreach ($row as $value) { echo "<td align='center'>".$value ."</td>"; } echo "</tr>"; } $end = $start + $records; echo "<tr align = 'center' bgcolor = 'BBCCDD' class='menu'><td colspan=$cols> Prijema $start do $end od $rows </td></tr>"; echo "<tr align = 'center' class='mylink'><td colspan=$cols> "; if($start != 0) { $prev = $start - 10; echo "<a href='tabela.php?start=$prev'> Prethodna </a> "; } if($start<$rows-10) { $next = $start + 10; echo "<a href = 'tabela.php?start=$next'>Sledeca</a> "; } echo "</td></tr>"; echo "</table>"; ?> </body> </html> hi i was wondering if anyone has any idea how to read text from a database and if that text = "mytexthere" then goto header("Location: index.php"); sorry i have no code on this post reason is all the code i have tried on my own is crap Hi On my xampp server's database I get the warning that my database is read-only when I try to insert something into a table. I think I may know what cause this, because I created an export/import app that exports/import important data to the database... How can I remove the read-only from the database, because I am scared that the same thing might happen to my server's database? And is there a mysql query that test if the database is read-only? Thanks in advance Hello, Sorry for my english... Well, I make a smaill website. members has to login and then member can see pictures (saved in a folder). When the admin upload pictures a folder wil be created. To get the actual folders in the "album" folder I use this code. <?php //get the folders $handle = opendir(realpath('../album/Album/.')); while ($direc = readdir($handle)) { if($direc == '.' || $direc == '..') continue; else { echo "\t\t<input type='checkbox' name='map[]' id='map[]' value='" . $direc. "' />" . $direc . "<br />\n"; } } closedir($handle); ?> The admin has to assign the folders wich are allowed to see by a member. I use checkboxes for that. And now my problem: When a member can see folder 1 to 4 and the admin upload 2 new folders and want to give that member to see these 2 new folders I want the following: 6 checkboxes (checkbox 1 > album 1, checkbox 2 > album 2... etc). As is said, this member can see folder 1 to 4, so in the CMS album 1 to 4 has to be checked ans album 5 to 6 not. This is my code for that: <?php $sql2 = "SELECT url FROM url WHERE gebruiker_id =" . $_GET['id'] . " ORDER BY url ASC"; $res2 = mysql_query($sql2); while ($rij = mysql_fetch_array($res2)) { $url = $rij['url']; // mappen ophalen $handle = opendir(realpath('../album/Album/.')); while ($direc = readdir($handle)) { if($direc == '.' || $direc == '..' || $direc == $url) { continue; } echo "\t\t<input type='checkbox' name='map[]' id='map[]' value='" . $direc. "' />" . $direc . "<br />\n"; } closedir($handle); } ?> Now my output is: <input type='checkbox' name='map[]' id='map[]' value='album 2' />album 2<br /> <input type='checkbox' name='map[]' id='map[]' value='album 3' />album 3<br /> <input type='checkbox' name='map[]' id='map[]' value='album 4' />album 4<br /> <input type='checkbox' name='map[]' id='map[]' value='album 5' />album 5<br /> <input type='checkbox' name='map[]' id='map[]' value='album 6' />album 6<br /> <input type='checkbox' name='map[]' id='map[]' value='album 1' />album 1<br /> <input type='checkbox' name='map[]' id='map[]' value='album 2' />album 2<br /> <input type='checkbox' name='map[]' id='map[]' value='album 4' />album 4<br /> <input type='checkbox' name='map[]' id='map[]' value='album 5' />album 5<br /> <input type='checkbox' name='map[]' id='map[]' value='album 6' />album 6<br /> <input type='checkbox' name='map[]' id='map[]' value='album 1' />album 1<br /> <input type='checkbox' name='map[]' id='map[]' value='album 2' />album 2<br /> <input type='checkbox' name='map[]' id='map[]' value='album 3' />album 3<br /> <input type='checkbox' name='map[]' id='map[]' value='album 5' />album 5<br /> <input type='checkbox' name='map[]' id='map[]' value='album 6' />album 6<br /> What do I have to do to check the checkboxes (album 1-4) and not to check the album 5-6??? My guess it has to do with the While in While loop but... Greetings, Ferdi Hello PHPfreaks members, I want my PHP coding to read/fetch my database's first attribute/entry like the first number of the client in that first row and then fetch it to be shown on PHP so that it will show '1'. How would I do that? Here's the table of my example database (MySQL) I know the command to select the line via the database is this: SELECT * FROM CUSTOMER WHERE CUST_NO=1; I have a MySQL database with each record of a person who has registered for an event, I am displaying the information on a web page for a user, but he wants to be able to print out all the records in alphabetical order by last name, first name later on so he will have a hard copy of each person who has registered at the table when they arrive. How can I write each record to a Txt file that he can print out later that will be formated with the record contents along with each fields definition (Ex. Last Name - Smith, First Name - John, etc)? This topic has been moved to Microsoft SQL - MSSQL. http://www.phpfreaks.com/forums/index.php?topic=319147.0 I have a "select"-drop down bar and I want to have a numbered list in it, i've tried but it doesn't seem to be possible. Is there any way that i'm able to do this? Hi ,
I am pretty new to php. I would like to create a php website based on folders.
I have a code so far that shows the names of folder in a selection box. What I would like to achieve now is how i get the images inside the folder after I click on submit. I know how to get the images with a glob function. What I don't know is how to get the value of each specific folder name. How would I do that?
I have this code so far to get the names of the folders in the selection box:
<form action="test.php" method="post"> <select name="myDirs"> <option value="" selected="selected">Select a genre</option> <?php $dirs = glob("*", GLOB_ONLYDIR); foreach($dirs as $val){ echo '<option value="'.$val.'">'.$val."</option>\n"; } ?> </select> <input type="submit" name="submit2"> <?phpif (isset($_POST['submit2'])) Helllo Every1 well im kinda new to php and i needed some help i was working on a page all my text boxes and check boxes are at the bottom of my file and like this //====================================================================== </script> </head> <body> <div style="margin-left: 170px"> <input type="checkbox" id="getitems" checked value="1">Run Plugin? <input type="checkbox" id="sellitm" checked value="1">Sell Items?<br><br> Item Name:<br><input type="text" id="itemd" value=""><br><br>How Many Cycles?:<br><input type="text" id="runtm" value="10"></div> <div style="margin-left: 170px"><br> <button id="btn_save" style="color:white;background-color:#00660F;border-width:1px;border-style:solid; "> Save settings </button> </div> '; echo $this->ObjectTable(); echo ' </body> </html> '; } } ?> and well i decided to do away wit one of the text boxes and use a drop down list instead that is populate from a text file and the only code that i could find that i was able to get working was this 1 <?php $text = file_get_contents("itemlist.txt"); $array = explode("\n",$text); echo "<select>"; foreach ($array as $value) { echo "<option value='$value'>$value</option>"; } echo "</select>"; and the problem im having is with that one it just stays at the top of the page when loaded like i have no way to position it... and im really stuck i tried saving it in another php and i tried using <?php include(); ?> function but it did not work if any1 could help me out that would be awsome. T.I.A I have a page with 3 drop down lists one for day of the month, one for month and one for year. what I am trying to do is use something that will enable me to make each day from the selected dates to appear as individual days. So if someone selected 1st of September and then 23rd of September it would show 1 2 3 4 5 up to 23. I need to be able to put this in a database. The make date is easy and I think I need to use explode but when I have seen this it comes out with 1, 2, 3, 4, and I do not want to use the comer. This is what I am using for the dates. Code: [Select] <?php $d = $_POST['d']; $m = $_POST['m']; $y = $_POST['y']; $d1 = $_POST['d1']; $m1 = $_POST['m1']; $y1 = $_POST['y1']; $date = date ("M-d-Y", mktime(0, 0, 0, $m, $d, $y)); $date1 = date ("M-d-Y", mktime(0, 0, 0, $m1, $d1, $y1)); ?> It will also have prices with these dates so if the user puts in 20.00 for day 1 it would need to go in for the dates selected. ie 1st 20.00 2nd 20.00 and so on. Any ideas or help would be appreciated Many Thanks I have a drop down list which retrieves site name acronym and the url from the database. I need help in 2 things. 1.I do not want the url to be displayed in the drop down list. 2. When I hit submit I need to echo the sitename acronym as well as the url in a page called display.php. Here is my code so far: Code: [Select] <form action="display.php" method ="post"> <tr> <td>Category</td> <td> <select name="new_id"> <option value="">=============</option> <?php foreach($acronym as $key=>$value){ ?> <option value="<?php echo $value['site_id']; ?>"><?php echo $value['acronym']; ?></option> <option value="<?php echo $value['site_id']; ?>"><?php echo $value['url']; ?></option> <?php }?> </td> </tr> <input type="submit" name="submit" value="submit" /> </form> I have two basic dropdown lists in a form, my question is this: After selecting an item from the 1st dropdown list, the second dropdown list should automatically load only fields that are connected with the first selected item. (ex Site1 has Tank01 and Tank06, but Site2 has Tank03, Tank04 and also a Tank06). What is the script needed / or how do I change my script to accommodate this? Here is the basic script I use for the second dropdown list: <?php include("../xxx.php"); $cxn = mysqli_connect($host,$user,$password,$dbname); $query = "SELECT DISTINCT `diesel_tank_id` FROM `diesel_tank` ORDER BY `diesel_tank_id`"; $result = mysqli_query($cxn,$query); while($row = mysqli_fetch_assoc($result)) { extract($row); echo "<option value='$diesel_tank_id'>$diesel_tank_id</option>\n"; } ?> I have a drop down list that contains expiration dates in the format 01/12 and if the user selected a certain drop down list I would like that same date selected. Does anyone know the code to do this? Thanks. I'm doing this activity where a user chooses a base timezone and when the user clicks convert the current time in the selected GMT will be converted to GMT-11 to GMT+13. As of now, I have these codes: act09_view.php: Code: [Select] <?php session_start(); $s="GMT "; echo "Select the base time zone:</br>"; for($n=-11;$n<=13;$n++) { if ($n>=0) $s="GMT +"; $gmt[]=$s . $n . "</br>"; } echo "<select name='gmt'>"; foreach ($gmt as $value) { echo '<option value="' . $value . '">' . $value . '</option>\n'; } echo '</select>'; //$_SESSION['value']=$value; ?> <form action="act09_process.php"> </br><input type='submit' value='Convert'/> </form> act09_process.php: Code: [Select] <?php session_start(); //$value=$_SESSION['value']; //echo $value; date_default_timezone_set('Asia/Manila'); $gmttime=date('M j, Y g:i:s A'); echo "The current date and time at" . " is " . $gmttime; ?> I've tried using session variables. I think I executed them incorrectly. The output is supposed to look like this: I'm useing a simple HTML drop-down list box. But now I want to be able to and an editable drop-down box so that if the particular item in the drop-down is not changed it won't update the database. But if a new value is selected it will update the DB with the new value.
I am not clear on a couple of things. should the valuse of the drop down be in a seperate DB table. And then the script to change the new value or keep the old.
I've googled this and can't seem to find a workable solution.
Thanks in advance,
|