PHP - Show Alphanumric List Of Db Entries Fails If Nothing Starts With One Letter
I have got this far that my code shows the list but say nothing starts with the letter 'y' then all of the 'x' and 'z' are grouped in the list.
can anyone suggest a better way to have the list show correctly. the 'multiItemBoxes' css class is a rounded box that shows around each letter group. here is me code. Code: [Select] // $letters = array(); $letters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ "; $L = 1; ?><div class="multiItemBoxes"><? // place first part of DIV. $previousLetter = "/"; // set previousLetter to the letter before '0' zero. used as a dummy string. while($results = mysql_fetch_assoc($getResults)) { if ($previousLetter == "/") { ?><strong style="font-size: 15pt;"><? echo(strtoupper($results['productTitle'][0])); ?></strong><br /><? } if (strtoupper($results['productTitle'][0]) == $letters[$L]) { ?></div><? // this is the ending of the DIV. If needed. ?><br class="clearfloat" /> <? if (strtoupper($results['productTitle'][0]) != " ") { ?><div class="multiItemBoxes"><strong style="font-size: 15pt;"><? echo(strtoupper($results['productTitle'][0])); ?></strong><br /><? $L++; } // this is the extra DIV start if not at end of DB list. } ?><a href="<? echo("cart.php?query=" . $results['Pid']); ?><? echo("&"); ?>i=y"><? echo(htmlspecialchars($results['productTitle'])); ?></a><br /><? $previousLetter = $results['productTitle'][0]; } // end of while ?></div><br class="clearfloat" /><? // Similar Tutorialshi, I have a list of towns and need to get the first letter from each town and just display it once before the start of that lettered group ie; what I have: Aberdeen Arundel Aberyswith Bath Bristol Brighton Cardiff coventry what I would like: A Aberdeen Arundel Aberyswith B Bath Bristol Brighton C Cardiff coventry here is the code which writes out my list: Code: [Select] <ul class="edgetoedge"> <?php while($row1 = mysql_fetch_array($locals)) { echo '<li class="forward"><a href="townpubs.php?RSTOWN='.$row1['RSTOWN'].'" rel="external">'.$row1['RSTOWN'].'<small class="listcounter">'.$row1['PubCount'].'</small></a></li>'; } ?> </ul> This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=325939.0 Hello... I have a .txt database with ~100 records. I only want to show the 15 records that are at the top (referring to reading order of the file). Here is my php code to display the records. http://www.flcbranson.org/mobile.php?content=mobile-freedownloads.php if you want to see the results of the code, below. Code: [Select] <?php $index_file = 'services/series/Index-Date.txt'; $fd = fopen($index_file, 'r'); if ($fd) { while (!feof ($fd)) { $seriestitle = trim(fgets($fd, 1024)); // Series Title if(feof ($fd)) break; $seriessubtitle = trim(fgets($fd, 1024)); // Series subtitle $seriesinfo = trim(fgets($fd, 1024)); // Series Info (Church name) $serieslocation = trim(fgets($fd, 1024)); // City, State $seriesindex = trim(fgets($fd, 1024)); // Series index file $seriesstatus = trim(fgets($fd, 1024)); //Online Only? $divider = trim(fgets($fd, 1024)); // Divider $seriestitle2 = $seriestitle; $seriestitle3 = str_replace("'", "%27", $seriestitle); // Kind of makes the alt= below work "God's Will" ends up being "God%27s Will" but without is "God" if(strstr($seriestitle,"<")) { $seriestitle2 = strip_tags($seriestitle); } $seriestitle2 = urlencode($seriestitle2); if(file_exists("images/ProductCovers/".substr($seriesindex,0,-4).".jpg")) { echo "<img src='images/ProductCovers/".substr($seriesindex,0,-4).".jpg' width='115' height='150' border='0' alt='".substr($seriestitle3,7)."'><br />"; } } fclose ($fd); } ?> I'm assuming that "for" would do the trick, but when I tried I got 10 copies of every record. Hehehe... I'm guessing that it's a quick fix. Thanks... JJ I coded the following but some parts are not working (the "curveball" mentioned at the end). How would YOU do this? I have a page (A) displaying a form with a textarea field using a WYSIWYG interface. The user will enter a list of unordered items and upon submit the string will look something like this: This is my list of food items: <ul> <li> Lettuce </li> <li> Tomatoes </li> <li> Eggs </li> <ul> Upon submit, I need to give each list item an unique id and store this id along with the text next to it in a separate table: List_item_id List_item_text List_item_state food_1 Lettuce food_2 Tomatoes food_3 Eggs The user will then land in another page with a form displaying the list. The text is now in the page itself and not in a textarea. Instead of the bullets a dropdown list appears, and the user can select "buy" or "sell" for each list item. This page (B) looks something like this: <form> This is my list of food items: <br><select name="food_1"> <option value="buy">Buy</option> <option value="sell">Sell</option> </select> Lettuce <br><select name="food_2"> <option value="buy">Buy</option> <option value="sell">Sell</option> </select> Tomatoes <br><select name="food_2"> <option value="buy">Buy</option> <option value="sell">Sell</option> </select> Eggs <input type=submit value="submit"> </form> When the user hits "submit" the table with the list items will be updated with the values selected in the dropdown list: List_item_id List_item_text List_item_state food_1 Lettuce Buy food_2 Tomatoes Buy food_3 Eggs Sell The next time the user goes to Page B the list will remember the states. Here's the curveball: At any point the user may click on "EDIT LIST" on Page B so they may add more items (at the begining, middle or end of the string). On edit mode the list items should appear as bullets again inside the WYSIWYG interface. Keep in mind that some of the text in the string may not be a list item (ie, "this is my list of food...") hello, im trying to see if there is a function that can get the value of the last row in mysql and see what is in field initial (this is letters A-Z) and make it one letter higher. then, when it reaches letter Z, wrap around to A again. I would appreciate your assistance, there are tons of login scripts and they work just fine. However I need my operators to login and then list their activities for the other operators who are logged in to see and if desired send their clients on the desired activity. I have the login working like a charm and the activities are listed just beautifully. How do I combine the two tables in the MySQL with PHP so the operator Logged in can only make changes to his listing but see the others. FIRST THE ONE script the member logges in here to the one table in MSQL: <?php session_start(); require_once('config.php'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $login = clean($_POST['login']); $password = clean($_POST['password']); if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'Password missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: login-form.php"); exit(); } $qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'"; $result=mysql_query($qry); if($result) { if(mysql_num_rows($result) == 1) { session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_MEMBER_ID'] = $member['member_id']; $_SESSION['SESS_FIRST_NAME'] = $member['firstname']; $_SESSION['SESS_LAST_NAME'] = $member['lastname']; session_write_close(); header("location: member-index.php"); exit(); }else { header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?> ................................................. ................................ Now I need the person who logged in to the table above to be able to make multiple entries to the table below <? $ID=$_POST['ID']; $title=$_POST['title']; $cost=$_POST['cost']; $activity=$_POST['activity']; $ayear=$_POST['aday']; $aday=$_POST['ayear']; $seats=$_POST['special']; $special=$_POST['seats']; mysql_connect("xxxxxx", "xxx350234427", "========") or die(mysql_error()); mysql_select_db("xxxx") or die(mysql_error()); mysql_query("INSERT INTO `activity` VALUES ('ID','$title', '$cost','$activity', '$aday', '$ayear', '$special', '$seats')"); Print "Your information has been successfully added to the database!" ?> Click <a href="member-profile.php">HERE</a> to return to the main menu <?php ?> I am using Concrete5 on a site I'm working on. Below is the News List display view.php file needed in the block to display the content from news pages. The code allows images entered in the WSYIWYG to appear in the RSS list. I want to know how I can edit the code below, so it shows only the these images from the $content not the text. Can anybody help me on this? Thanks <?php defined('C5_EXECUTE') or die("Access Denied."); $html = Loader::helper('html'); $uh = Loader::helper('concrete/urls'); $bt = BlockType::getByHandle('news_list'); global $c; $rss_address = $controller->getRssUrl().'?ctID='.$ctID.'&bID='.$bID ; if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } // if ?> <div class="newsflash"> <div class="headtitle"> <h1><?php echo $rssTitle ?></h1> </div> <?php if (!function_exists('newslistParse')) { function newslistParse($url,$thumbnail,$thumbwidth,$time,$content,$title,$date){ //###################################################################################// //here we lay out they way the page looks, html with all our vars fed to it // //this is the content that displays. it is recommended not to edit anything beyond // //the content parse. Feel free to structure and re-arrange any element and adjust // //CSS as desired. // // available vars: $url,$thumbnail,$thumbwidth,$time,$content,$title,$date // //###################################################################################// ?> <div class="newsflashcontain"> <div class="title"> <?php echo $title ; ?> </div> <div class="time"> <?php echo $date ; ?><?php echo $time ; ?> </div> <div class="description"> <?php echo $content; ?> </div> </div> <?php //#####################################################################################// //this is the end of the recommended content area. please do not edit below this line // //#####################################################################################// } } $db = Loader::db(); //go grab the posts, check if they are current, return only current posts Loader::model('newzy','simplenews'); $news = NewsCheck::getCurrentBlocks($ctID,$ordering); //count the number of current posts returned $pcount = count($news); //if no events are returned, then we display a user defined message if($pcount==0){ echo $nonelistmsg; } //now calc the last page $lastpage = ceil($pcount/$num); //set the current page min max keys -1 as array key's start @ 0 $sKey = $num * ($pageno-1) ; $eKey = ($num * ($pageno-1)) + ($num-1) ; //take each current post and treat it like a query, for each one do X foreach($news as $key => $row){ //check for external URL, if none, rout to parent page if(!empty($row['urlLink'])){ $url = $row['urlLink']; }else{ $url = $controller->grabURL($row['cParentID']); } //check if thumbnail is there, if so get it, if not, null if($row['graphic']>0){ $thumbnail = $controller->getThumbnail($row['graphic']); }else{ $thumbnail = NULL; } //set vars $time = $controller->replaceTimeString($row['nbID']); $date = $row['sdt']; $title = $row['title']; //$content = strip_tags($controller->translateFrom($row['content'])); $content = $controller->translateFrom($row['content']); //if truncation is enabled if($truncateSummaries == 1){ if (strlen($content) >= $truncateChars){ //truncate to suplied truncation value //$content = substr($content,0,$truncateChars).'.....'; $content = wordwrap($content, $truncateChars); $content = substr($content, 0, strpos($content, "\n")).'.....'; } } //check if paging is enabled if($isPaged){ //check to make sure the array key is within the range if($key >= $sKey && $key <= $eKey){ newslistParse($url,$thumbnail,$thumbwidth,$time,$content,$title,$date); } //if paging is not selected, use number of items designated in the list block }else{ $i += 1; newslistParse($url,$thumbnail,$thumbwidth,$time,$content,$title,$date); //once we reach the set number stop the script if($i >= $num){ break; } } } ?> </div> <?php //is iCal feed option is sellected, show it if($showfeed==1){ ?> <div class="rssfeed"> <img src="<?php echo $uh->getBlockTypeAssetsURL($bt, 'rss.png');?>" width="14" height="14" alt="rss feed" /> <a href="<?php echo $rss_address ; ?>" id="getFeed">Get this Feed</a> <link href="<?php echo $controller->getRssUrl();?>" rel="alternate" type="application/rss+xml" title="<?php echo t('RSS');?>" /> </div> <?php } //$c = Page::getCurrentPage(); $link = Loader::helper('navigation')->getLinkToCollection($c); $link = $controller->URLfix($link); //if pagination is set, if it is needed, show it if($isPaged==1){ if ($pcount > $num) { echo '<div id="pagination">'; if ($pageno == 1) { echo " FIRST PREV "; } else { echo '<a href="'.$link.'pageno=1">FIRST </a>'; $prevpage = $pageno-1; echo '<a href="'.$link.'pageno='.$prevpage.'"> PREV</a>'; } // if echo ' ( Page '.$pageno.' of '.$lastpage.' ) '; if ($pageno == $lastpage) { echo " NEXT LAST "; } else { $nextpage = $pageno+1; echo '<a href="'.$link.'pageno='.$nextpage.'">NEXT </a>'; echo '<a href="'.$link.' pageno='.$lastpage.'"> LAST</a>'; } // if echo '</div>'; } } if (isset($bID)) { echo '<input type="hidden" name="bID" value="'.$bID.'" />';} ?> hi, at the moment, my page only works with the County: Angus (2nd in the list) List of Counties County List Angus County List The code for my Pubs page is below..., I think I need to change the hard coded bit that reads: Code: [Select] echo "<ul title=\"Pubs in Angus\" id=\"Angu\">"; and the SQL string: Code: [Select] $query = "SELECT * FROM pubs WHERE rsCounty = 'Angus' LIMIT $offset, $rowsPerPage"; pubs page Code: [Select] <?php include_once("config.php"); include_once("functions.php"); // Check user logged in already: checkLoggedIn("no"); //doCSS(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My Pub Space</title> <link rel="stylesheet" type="text/css" href="stylesheets/style1.css" title="default" /> <meta name="viewport" content="width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.0; user-scalable=0;"/> <link rel="apple-touch-icon" href="../iui/iui/mps-icon.png" /> <style type="text/css" media="screen">@import "../iui/iui/iui.css";</style> <script type="application/x-javascript" src="../iui/iui/iui.js"></script> <meta name="apple-touch-fullscreen" content="YES" /> <script type="text/javascript" src="js/jva.js"></script> </head> <body> <? $offset = (isset($_GET['start'])) ? (int)$_GET["start"] : 0; $rowsPerPage = (isset($_GET['count'])) ? (int)$_GET["count"] : 10; $query = "SELECT * FROM pubs WHERE rsCounty = 'Angus' LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die(mysql_error().'<br>SQL: ' . $query); //looping counties $query1 = "SELECT rsCounty, COUNT(PUBID) AS County_Count FROM pubs GROUP BY rsCounty"; $result1 = mysql_query($query1) or die(mysql_error().'<br>SQL: ' . $query1); $County1 = $result1['rsCounty']; $CountyCount = $result1['County_Count']; ?> <div class="toolbar"> <h1 id="pageTitle">Select County</h1> <a id="backButton" class="button" href="#"></a> <a class="button" href="logout.php" target="_self">Logout</a> </div> <ul title="Select County" id="county" selected="true"> <?php while ($row = mysql_fetch_assoc($result1)){ $RSCOUNTY1 = $row['rsCounty']; $RSCOUNTY1short = substr($row['rsCounty'],0,4); $CountyCount = $row['County_Count']; echo <<<EOF <li><a href="#$RSCOUNTY1" class="digg-count">$CountyCount</a> <a href="#$RSCOUNTY1short">$RSCOUNTY1</a></li> EOF; } echo "</ul>"; // start East Sussex echo "<ul title=\"Pubs in Angus\" id=\"Angu\">"; while($row = mysql_fetch_array($result)){ $PUBID = $row['PUBID']; $rsPubName = $row['rsPubName']; $rsAddress = $row['rsAddress']; $rsPostCode = $row['rsPostCode']; $rsTel = $row['rsTel']; $rsTown = $row['rsTown']; $rsCounty = $row['rsCounty']; // how many rows we have in database // print the link to access each page $self = $_SERVER['PHP_SELF']; $next = "<li><a href=\"all.php?start=" . ($offset + $rowsPerPage) . "&count={$rowsPerPage}\" target=\"_replace\">View More</a></li>"; //div container of header and information echo <<<EOF <li><a href="viewpub.php?PUBID=$PUBID">$rsPubName</a></li> EOF; if ($_SESSION["RSUSER"] == "admin") { echo "<a href=\"edit.php?PUBID=$PUBID\" class=\"small\">edit this pub</a>"; } } echo $next; echo "</ul>"; // End East Sussex ?> </body> </html> Please help?! hi, I would like to show a list of pubs in a town that the user has selected from the drop down list http://www.mypubspace.com/dashtest/order.html it is all there working but in a different way If you type Brighton into the Town search, it shows a list of pubs in that town, GREAT! If you click the 'show towns list' link, a drop down appears, (this is where my problem is) When you click the town, I would like to get the list of pubs in that town basically get rid of the form where you type in the box and click the button here is my code HTML and Javascript Code: [Select] <html> <body> <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function ajaxFunction(){ var townRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari townRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ townRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ townRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server townRequest.onreadystatechange = function(){ if(townRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = townRequest.responseText; } } var name = document.getElementById('name').value; var county = document.getElementById('county').value; var town = document.getElementById('town').value; var queryString = "?name=" + name + "&county=" + county + "&town=" + town; townRequest.open("GET", "http://www.mypubspace.com/dashtest/pubs.php" + queryString, true); townRequest.send(null); } function townlistFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxTownlist'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("GET", "http://www.mypubspace.com/dashtest/town-select.php", true); ajaxRequest.send(null); } function countylistFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxCountylist'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("GET", "http://www.mypubspace.com/dashtest/county-select.php", true); ajaxRequest.send(null); } function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } //--> </script> <a href="#" onClick="townlistFunction();">show towns list</a> <a href="#" onClick="countylistFunction();">show counties list</a> <div id="ajaxTownlist"></div> <div id="ajaxCountylist"></div> <form name='myForm'> Pub Name: <input type='text' id='name' /> <br /> County: <input type='text' id='county' /> <br /> Town: <input type='text' id='town' /> <input type='button' onclick='ajaxFunction()' value='Query MySQL' /> </form> <div id='ajaxDiv'></div> </body> </html> here is my pubs.php code Code: [Select] <?php $dbhost = "xxx"; $dbuser = "xxx"; $dbpass = "xxx"; $dbname = "xxx"; //Connect to MySQL Server mysql_connect($dbhost, $dbuser, $dbpass); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query String $name = $_GET['rsPubName']; $sex = $_GET['rsTown']; $wpm = $_GET['rsCounty']; // Escape User Input to help prevent SQL Injection $name = mysql_real_escape_string($name); $town = mysql_real_escape_string($town); $county = mysql_real_escape_string($county); //build query $query = "SELECT * FROM pubs WHERE rsTown = '$town'"; $qry_result = mysql_query($query) or die(mysql_error()); //Build Result String $display_string = "<table>"; $display_string .= "<tr>"; $display_string .= "<th>Region</th>"; $display_string .= "<th>Pub Name</th>"; $display_string .= "<th>Town</th>"; $display_string .= "<th>County</th>"; $display_string .= "</tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td>$row[Region]</td>"; $display_string .= "<td>$row[rsPubName]</td>"; $display_string .= "<td>$row[rsTown]</td>"; $display_string .= "<td>$row[rsCounty]</td>"; $display_string .= "</tr>"; } $display_string .= "</table>"; echo $display_string; ?> here is my town_select.php code Code: [Select] <?php $dbhost = "xxx"; $dbuser = "xxx"; $dbpass = "xxx"; $dbname = "xxx"; //Connect to MySQL Server mysql_connect($dbhost, $dbuser, $dbpass); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query String $town = $_GET['rsTown']; // Escape User Input to help prevent SQL Injection $town = mysql_real_escape_string($town); //build query $query = "SELECT DISTINCT rsTown, COUNT(PUBID) As PubCount FROM pubs GROUP BY rsTown ORDER BY rsTown ASC"; $qry_result = mysql_query($query) or die(mysql_error()); // Insert a new row in the table for each person returned $display_string .= "<form name=\"form3\" method=\"post\" action=\"\">"; $display_string .= "<select name=\"menu2\" onChange=\"MM_jumpMenu('parent',this,0)\" class=\"textbox\">"; $display_string .= "<option value=\"\">Search by Town...</option>"; while($row = mysql_fetch_array($qry_result)){ $display_string .= '<option value="rsTown='.$row['rsTown'].'" onclick=\"ajaxFunction()\" id=\"town\">'.$row['rsTown'].' ('.$row['PubCount'].')</option>'; } $display_string .= "</select>"; $display_string .= "</form>"; echo $display_string; ?> I'm working on a register script which has an array of strings that a username can not start with, but the script I'm using checks to see if the items in the array are anywhere in the username. Here's my code. $blockedWordsInUsername = array('mod', 'm0d', 'admin', 'adm1n', '4dm1n'); foreach($blockedWordsInUsername as $username) { if(strstr($_POST['username'], $username) == true && !$error) { $error = '<p style="text-align: center;">Sorry, that username is no longer available.</p>'; } } What I'm trying to do is make it so your name can't start with the items in the array. hey guys, I am having a small problem and I can't wrap my head around it. I want users to be able to upload up 10 photos in the database and what I want to do is check the database to see how many pics they have already and if they have 10, just show the photo with action items but if they have 7 for example, show the 7 pictures and three upload fields, if they have 4, show the pics and 6 fields and so on... let me know what you guys think and some help. Thanks in advance guys, you always come through... Hello All, I have read through this script a million times, and I can not for the life of me figure out how the script decides which day of the week to start on. Right now the week starts on Monday (which goes against every other calendar we use). I need to figure out how to make the week start on Sunday. Here's the script: <style type='text/css'> .outofrange { background-color: #d9cdb3; } .currentday { background-color: #ccc; } </style> <?PHP $Year = preg_replace("/[^0-9]/","",$_GET['year']); $Month = preg_replace("/[^0-9]/","",$_GET['month']); if ($Month == "") { $Month = date("n"); } if ($Year == "") { $Year = date("Y"); } if ($Month==0) { $Month=12; $Year--; } if ($Month==13) { $Month=1; $Year++; } $myServer = "xxxxxx"; $myUser = "xxxxxx"; $myPass = "xxxxxx"; $myDB = "Calendar"; //connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); //select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); //declare the SQL statement that will query the database $query = " SELECT * FROM calendar WHERE school = '00' "; //execute the SQL query and return records $result = mssql_query($query); //display the results while($row = mssql_fetch_array($result)) { if (date("Y",strtotime($row['date']))==$Year) { $Event[date("z",strtotime($row['date'])+1)+1] .= $row['event'] . "<br />" . "<font color='#" . $row['colors'] . "'>" . $row['location'] . "</font>" . "<p>"; } } $Timestamp = strtotime("$Year-$Month-01"); for ($Day=1;$Day<=32;$Day++) { if (checkdate($Month,$Day,$Year)) { $LastDayInMonth = $Day; } } $FirstDayInMonth = date("N",$Timestamp); for ($MakeCal=$FirstDayInMonth;$MakeCal<=$FirstDayInMonth+$LastDayInMonth;$MakeCal++) { //echo "$MakeCal<br />"; } $WeeksNeeded = ceil(($FirstDayInMonth+$LastDayInMonth)/7); echo "<div align='center'><span class='bodyb'>" . date("F Y",$Timestamp) . "</span></div><p>"; echo "<table width='100%' border='0'> <tr> <td align='left' valign='top'><a href='index.php?month=" . (($Month)-1) . "&year=$Year' class='monthview'>Previous Month</a></td> <td align='right' valign='top'><a href='index.php?month=" . (($Month)+1) . "&year=$Year' class='monthview'>Next Month</a></span></td> </tr> </table>"; echo "<p>"; //Main Table starting with days of week through the month views// echo "<table width='615px' cellspacing='0' cellpadding='2' border='1' bordercolor='#666666'> <tr> <th>Monday</th> <th>Tuesday</th> <th>Wednesday</th> <th>Thursday</th> <th>Friday</th> <th>Saturday</th> <th>Sunday</th> </tr> "; for ($DoWeeks=1;$DoWeeks<=$WeeksNeeded;$DoWeeks++) { for ($DoDays=1;$DoDays<=7;$DoDays++) { $CurrentDay++; if ($CurrentDay < $FirstDayInMonth) { echo "<td width='10%' class='outofrange'> </td>"; } else { if (($CurrentDay-$FirstDayInMonth)+1>$LastDayInMonth) { echo "<td width='10%' class='outofrange'> </td>"; } else { $DayOfYear = date("z",strtotime("$Year-$Month-" . (($CurrentDay-$FirstDayInMonth)+1))) + 1; if ($DayOfYear==date("z")+1 && date("Y")==$Year) { echo "<td width='10%' height='100' valign='top' class='currentday'><strong>" . (($CurrentDay-$FirstDayInMonth)+1) . "</strong><br />"; } else { echo "<td width='10%' height='100' valign='top'><strong>" . (($CurrentDay-$FirstDayInMonth)+1) . "</strong><br />"; } if ($Event[$DayOfYear]!="") { echo $Event[$DayOfYear] . $Location[$DayOfYear] . "<p /></font>"; } echo "</td>"; } } } echo "</tr><tr>"; } echo "</table><p>"; show list of files uploaded by current session user to the database. I want to show different users when they log in to the website...they can see a list of old files that they have uploaded. can anyone tell me the code/script to this.....please, ty This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=306153.0 Hello. I have made a very simple calendar with the help of a tutorial. http://www.codewalkers.com/c/a/Date-Time-Code/Simple-PHP-Calendar/ Now the problem is, that the week start with Sunday, insted of Monday. The table is looks like this (See attached image) The code is: <?php date_default_timezone_set('Europe/Helsinki'); //This gets today's date $date =time () ; //This puts the day, month, and year in seperate variables $day = date('d', $date) ; $month = date('m', $date) ; $year = date('Y', $date) ; //Here we generate the first day of the month $first_day = mktime(0,0,0,$month, 1, $year) ; //This gets us the month name $title = date('F', $first_day) ; //Here we find out what day of the week the first day of the month falls on $day_of_week = date('D', $first_day) ; //Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; } //We then determine how many days are in the current month $days_in_month = cal_days_in_month(0, $month, $year) ; //Here we start building the table heads echo "<table border=1 width=294>"; echo "<tr><th colspan=7> $title $year </th></tr>"; echo "<tr><td width=42>S</td><td width=42>M</td><td width=42>T</td><td width=42>W</td><td width=42>T</td><td width=42>F</td><td width=42>S</td></tr>"; //This counts the days in the week, up to 7 $day_count = 1; echo "<tr>"; //first we take care of those blank days while ( $blank > 0 ) { echo "<td></td>"; $blank = $blank-1; $day_count++; } //sets the first day of the month to 1 $day_num = 1; //count up the days, untill we've done all of them in the month while ( $day_num <= $days_in_month ) { echo "<td> $day_num </td>"; $day_num++; $day_count++; //Make sure we start a new row every week if ($day_count > 7) { echo "</tr><tr>"; $day_count = 1; } } //Finaly we finish out the table with some blank details if needed while ( $day_count >1 && $day_count <=7 ) { echo "<td> </td>"; $day_count++; } echo "</tr></table>"; ?> So what I want is that the week starts from Monday, not Sunday. what php function would I need to use to let's say I have a string I went to the Store And I want to pass that string, or any string through some type of function that would output: I Went To The Store How in the world could I do this? am I overthinking this or is this extremely difficult? hello, i have the following, which is sorting by id number with a horizontal line between. im trying to make it so that it is sorted by supplier with lines between each letter. Code: [Select] <?php if ($PreviousID!=0 && $ManID != $PreviousID) {?> <hr /> <?PHP } $PreviousID = $ManID; include 'config.php'; include 'javascript.php'; @mysql_select_db ("citycore", $conn) OR DIE (mysql_error()); $sql = "SELECT * FROM supplier ORDER BY supplier"; $result = @mysql_query($sql, $conn) or die(mysql_error()); //$row2 = mysql_query($sql, $conn); $PreviousID=0; while ($row = mysql_fetch_array($result)) { $ManID = $row['id']; $id=$row['id']; $supplier=$row['supplier']; $address=$row['address']; $city=$row['city']; $province=$row['province']; $postal=$row['postal']; $phone2=$row['phone2']; $phone=$row['phone']; $fax=$row['fax']; $email=$row['email']; ?> <div align="center"> <table border="1" width="95%" style="border-collapse: collapse"> <tr> <td><?php echo $row['supplier'];?></td> <td><a href="http://mapof.it/<?php echo($address .' ' .$city .',' .' ' .$province .' ' .$postal); ?>" target="_blank"><?php echo($address .' ' .$city .',' .' ' .$province .' ' .$postal); ?></a></td> </tr> </table> </div> <?PHP } ?> i want it so that the 1st letter in this text box when it Submited gets saved to the db as 1st letter <input name="title" type="text" id="title" size="50" /> This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=350684.0 I want to be able to replace, let's say, every fifth letter from a string. The string is unknown, though, it could come from database, or a POST form. So I'm unsure if I could use str_replace. I think I may need to use preg_replace(), but I'm not not sure. |