PHP - Only Some Images Show Up?????
Why is it that only certain images come through. I made sure all extensions were there but some jpegs come through others don't some pngs not others. Any thoughts?
Code: [Select] <?php $hostname='yobb'; $username='ybbb'; $password='Anbbbb!'; $dbname='b29'; $usertable='bbbb; $myconn=mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); if ((($_FILES["file"]["type"] =="image/gif") || ($_FILES["file"]["type"] =="image/jpeg") || ($_FILES["file"]["type"] =="image/pjpeg") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"]< 200000)) { if ($_FILES["file"]["error"] >0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br/>"; } else { if (file_exists("uploads/" . $_FILES["file"]["name"])) { echo "File already exists. Choose another name."; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]); } } } else { echo "Invalid file"; } $path="uploads/" . $_FILES["file"]["name"]; $name=$_POST["name"]; $state=$_POST["state"]; if (!myconn) { die ('Could not connect: ' . $mysql_error()); } $db_selected=mysql_select_db('your1729',$myconn); if (!$db_selected) { die ('Can\'t use your1729 : ' . mysql_error()); } mysql_query("INSERT INTO photo(name,photopath,state) VALUES ('$name','$path','$state')") or die(mysql_error()); mysql_close($myconn); ?> Similar TutorialsI built a CMS system using CKEditor and KCFinder that store information od a databse via textarea/php. So far so good!
The issue comes to when I want to store and display images that link to themselves. The way I am storing images is exactly the same: There is a textarea where I insert an image via KCFinder/CKEditor. The image is uploaded to the server and the path stored at the database. Later I try to pick up that path from the database to display the image and because I want the image to link to itself, I try to use the same method to insert the url on the link. Problem? The link is missing and the images are not displaying.
Can anyone point me the error and suggest any solution? I would be so thankful! CODE: try { $DBH = new PDO('mysql:host=localhost;dbname=yourdb;charset=utf8', 'user', 'password'); $DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $STH = $DBH->prepare('SELECT * FROM php_maskiner ORDER BY timestamp DESC'); $STH->execute(); $STH->setFetchMode(PDO::FETCH_OBJ); while($row = $STH->fetch()) { $title = $row->title; $entry = $row->entry; $images = $row->images; $img_url = $row->images; $img_pack = '<div class="mask3 span3"> <a rel="prettyPhoto" href="'.$img_url.'"><img src="'.$images.'"></a> </div>'; } $DBH = null; } catch (PDOException $e) { echo '<div class="alert alert-standard fade in"> <a class="close" data-dismiss="alert" href="#">×</a> <strong>Can\'t read the database!</strong> </div><br />'.$e; } <?php echo '<article class="span12 post"> '.$img_pack.' <div class="inside"> <div class="span8 entry-content"> <div class="span12"> <h2>'.$title.'</h2> <p>'.$entry.'</p> </div> </div> </div> </article>'; ?> Thanks in advance! I can't get images to show up in my script. They show up as broken images and I can figure it out. I think it's a problem with (') or this (").
Any help would be appreciated.
$query = 'SELECT * FROM images'; $stmt = $dbh->prepare($query); $stmt->execute(); $counter = 0; $numberperrow = 3; while($row = $stmt->fetch()) { if($counter < $numberperrow) { echo '<img src='.$row['image_th'].' width=200>'; /**$counter = $counter + 1;**/ echo ' '; $counter = $counter + 1; }else{ echo '<br>'; $counter = '1'; echo '<img src='.$row['image_th'].' width=200>'; echo ' '; } } } catch(PDOException $e) { echo $e->getMessage(); } 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.'" />';} ?> Hello i have a fade in image on my home page id=1 but when i go to about page id=2 i want it to go i have tryed to us Code: [Select] if($id == 1){ show rollover }else{ do somthing } that works but when i open the website up it gives me an error because i have not selected a page for the id is there away round this any help would be great thanks Hi All, I am trying to develop an application that show's where PC's are located in an office. Basically, what I want to be able to do, is to overlay avatar-like images over a main floorplan layout, and place them in a position, depending on thier x/y co-ordinates, which would be retreived from a database. Is this possible using PHP at all? Thanks in advance Matt I'm have trouble getting my script to show images in a table across the screen. I want to show the picture and have the description shown below it. Right now it shows it in a column with the name next to it. Any help would be greatly appreciated. Thanks in advance. Below is the script. <?php include 'config1.php'; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE year = '1954'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 3; echo "<table>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div> <a><img src="<?php echo $tn; ?>"</a><a><?php echo $title; ?></a></div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> </table> I want to show a cookie of a referral's username on a sign up page. The link is like this, www.mysite.com/signup?ref=johnsmith. The cookie doesn't show if I go to that url page. But it does show up once I reload the page. So I'm wondering if it's possible to show the cookie the first time around, instead of reloading the page? Here is my code. // This is in the header $url_ref_name = (!empty($_GET['ref']) ? $_GET['ref'] : null); if(!empty($url_ref_name)) { $number_of_days = 365; $date_of_expiry = time() + 60 * 60 * 24 * $number_of_days; setcookie( "ref", $url_ref_name, $date_of_expiry,"/"); } else if(empty($url_ref_name)) { if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; } } else {} // This is for the sign up form if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; ?> <fieldset> <label>Referred By</label> <div id="ref-one"><span><?php if(!empty($user_cookie)){echo $user_cookie;} ?></span></div> <input type="hidden" name="ref" value="<?php if(!empty($user_cookie)){echo $user_cookie;} ?>" maxlength="20" placeholder="Referrer's username" readonly onfocus="this.removeAttribute('readonly');" /> </fieldset> <?php }
I am displaying rows from a database onto a page using: while($row=mysql_fetch_array($query)){ echo $row['name']; } I need to figure out how to limit the rows shown to the page to 100. And if there are 100 rows on the page, a link will be displayed at the bottom, that says "Next 100". Then this will display the next 100 rows. Can you give an example how to do this please? Thanks Hi, I would like to do the following but not sure how. If the you/user is on index.php of http://www.domain.com/ show one page If not show another How would I do this? Thanks Hi , I know my code sucks but i'm learning fast!! I'm trying to show a form if the qty value in a database == 10 or a different form if the value ==20. I tried but failed. Any help really appreciated. Code: [Select] <?php require_once('Connections/book.php'); ?> <?php $colname_cardpayment = "-1"; if (isset($_GET['orderid'])) { $colname_cardpayment = (get_magic_quotes_gpc()) ? $_GET['orderid'] : addslashes($_GET['orderid']); } mysql_select_db($database_book, $book); $query_cardpayment = sprintf("SELECT * FROM cards WHERE orderid = '%s' ORDER BY qty ASC", $colname_cardpayment); $cardpayment = mysql_query($query_cardpayment, $book) or die(mysql_error()); $row_cardpayment = mysql_fetch_assoc($cardpayment); $totalRows_cardpayment = mysql_num_rows($cardpayment); // Database connect $con = mysql_connect("mysql1.myhost.ie","admin_book","root123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); //Parse Values from Coupon.php Form $orderid = mysql_real_escape_string(trim($_POST['orderid'])); $name = mysql_real_escape_string(trim($_POST['name'])); $surname = mysql_real_escape_string(trim($_POST['surname'])); $add1 = mysql_real_escape_string(trim($_POST['add1'])); $add2 = mysql_real_escape_string(trim($_POST['add2'])); $town = mysql_real_escape_string(trim($_POST['town'])); $county = mysql_real_escape_string(trim($_POST['county'])); $postcode = mysql_real_escape_string(trim($_POST['postcode'])); $phone = mysql_real_escape_string(trim($_POST['phone'])); $email = mysql_real_escape_string(trim($_POST['email'])); $letterstyle = mysql_real_escape_string(trim($_POST['letterstyle'])); $sql="INSERT INTO custdetails (orderid, name, surname, add1, add2, town, county, postcode, phone, email, letterstyle) VALUES ('$orderid','$name','$surname','$add1','$add2','$town','$county','$postcode','phone','$email','$letterstyle')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Digital Scribe Books</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('images/buttons/home_over.png','images/buttons/books_over.png','images/buttons/cards_over.png','images/buttons/letters_over.png')"> <div id="snow"> <div id="wrapper"> <div id="header"> <div id="logo"><img src="images/digital_scripe.png" width="218" height="91" /></div> <div id="menu"><a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/buttons/home_over.png',1)"><img src="images/buttons/home_act.png" name="Home" width="131" height="132" border="0" id="Home" /></a><a href="books.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Books','','images/buttons/books_over.png',1)"><img src="images/buttons/books_act.png" name="Books" width="131" height="132" border="0" id="Books" /></a><a href="cards.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Cards','','images/buttons/cards_over.png',1)"><img src="images/buttons/cards_act.png" name="Cards" width="131" height="132" border="0" id="Cards" /></a><a href="letters.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Letters','','images/buttons/letters_over.png',1)"><img src="images/buttons/letters_act.png" name="Letters" width="131" height="132" border="0" id="Letters" /></a></div> </div> <div id="content"> <?php echo 'Order ID is : '. $orderid . '.<br />'; if ($row2['qty'] == 10) echo "<div> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="accounts@agraphics.ie"> <input type="hidden" name="lc" value="IE"> <input type="hidden" name="item_name" value="10 Christmas Cards"> <input type="hidden" name="item_number" value="<? echo $orderid; ?>"> <input type="hidden" name="amount" value="12.99"> <input type="hidden" name="currency_code" value="EUR"> <input type="hidden" name="button_subtype" value="services"> <input type="hidden" name="shipping" value="2.99"> <input type="hidden" name="return" value="http://www.digitalscribe/thanks.php"> <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </div>"; if ($row2['qty'] == 20) echo "<div> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="accounts@agraphics.ie"> <input type="hidden" name="lc" value="IE"> <input type="hidden" name="item_name" value="20 Christmas Cards"> <input type="hidden" name="item_number" value="<? echo $orderid; ?>"> <input type="hidden" name="amount" value="21.99"> <input type="hidden" name="currency_code" value="EUR"> <input type="hidden" name="button_subtype" value="services"> <input type="hidden" name="shipping" value="2.99"> <input type="hidden" name="return" value="http://www.digitalscribe/thanks.php"> <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </div>"; ?> </div> <div id="footer" class="clear"><div id="sign"><div id="sign_text">Personalised<br /> Books</div> </div></div> </div></div> </body> </html> <?php mysql_free_result($cardpayment); ?> I have this script from http://lampload.com/...,view.download/ (I am not using a database) I can upload images fine, I can view files, but I want to delete them. When I press the delete button, nothing happens
http://www.jayg.co.u...oad_gallery.php
<form>
<?php $dir = dirname(__FILENAME__)."/images/gallery" ; $files1 = scandir($dir); foreach($files1 as $file){ if(strlen($file) >=3){ $foil = strstr($file, 'jpg'); // As of PHP 5.3.0 $foil = $file; $pos = strpos($file, 'css'); if ($foil==true){ echo '<input type="checkbox" name="filenames[]" value="'.$foil.'" />'; echo "<img width='130' height='38' src='images/gallery/$file' /><br/>"; // for live host //echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/ $file' /><br/>"; } } }?> <input type="submit" name="mysubmit2" value="Delete"> </form>
any ideas please?
thanks
I can't understand for the life of me - why the value for the variable: $total_vit_k is 2 in the red box: http://content.screencast.com/users/rockstarvisible/folders/Jing/media/beafff1f-2168-47b8-91bb-950ace0722c2/2012-03-21_1437.png. The reason why I can't understand this is because $total_vit_k is the weekly total for everything from jan 29 to feb 4 but there's no values for those dates logged in the mysql table it's pulling from. Please help me. It should be displaying 0 Mcg in the red box but it isn't. I know it's something wrong in my code. When I echo out all the values in the while loop like below, the browser echos out nothing for the queries from jan 29 2012 to feb 4 2012. code below is from file 2: Code: [Select] while ($row = mysql_fetch_assoc($query_run)){ echo "<br /><br /><b><i>" . '$sql_food ' . $sql_food."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . '$sql_total_servings ' . $sql_total_servings."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . '$sql_day ' . $sql_day."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . '$sql_month ' . $sql_month."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . '$sql_year ' . $sql_year."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . '$sql_vit_k ' . $sql_vit_k."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . ' $sql_servings ' . $sql_servings."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . ' $total_vit_k ' . $total_vit_k."</b></i><br /><br/ >"; include 'inside_while.acc-over.php'; } full code for file2: Code: [Select] <?php if(!function_exists('getWeeklyVitK') ){ function getWeeklyVitK($value, $bday, $bmonth, $byear, $eday, $emonth, $eyear){ //initialize the variables so no errors occur $query_month =$bmonth; $query_year =$byear; $query_day = $bday; //initialize variables $total_vit_k = 0; //$total_cal = 0; //$total_protein = 0; //$total_fiber = 0; //$total_carbs = 0; //$total_sugar = 0; //$total_sodium = 0; //$total_chol = 0; if ($value==1){ echo "Something went wrong - tell pavankat[at]gmail."; break; } if ($value==2){ // if $value = 2 // end day >= start day // end month = start month // end year = start year $day_temp = $eday; while($bday<=$day_temp){ $query_day = $bday; //redeclare the mysql query include 'acc-over-sql-queries.php'; if ($query_run = mysql_query($query_value2)){ while ($row = mysql_fetch_assoc($query_run)){ include 'inside_while.acc-over.php'; } } $bday++; } return round($total_vit_k, 2); } if ($value==3){ // if $value = 3 // end day and beg day don't matter // end month > beg month // end year = beg year for($bmonth; $bmonth<=$emonth; $bmonth++){ $query_month = $bmonth; $days_in_month = date('t',mktime(0,0,0,$query_month,1,$byear)); $day_temp = $days_in_month; echo "<br />day_temp variable:<u> ".$day_temp. "</u><br />"; while($bday<=$day_temp){ $query_day = $bday; //redeclare the mysql query include 'acc-over-sql-queries.php'; echo "<br />".'$query_value3:' . $query_value3 . "<br />"; if ($query_run = mysql_query($query_value3)){ while ($row = mysql_fetch_assoc($query_run)){ echo "<br /><br /><b><i>" . '$sql_food ' . $sql_food."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . '$sql_total_servings ' . $sql_total_servings."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . '$sql_day ' . $sql_day."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . '$sql_month ' . $sql_month."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . '$sql_year ' . $sql_year."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . '$sql_vit_k ' . $sql_vit_k."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . ' $sql_servings ' . $sql_servings."</b></i><br /><br/ >"; echo "<br /><br /><b><i>" . ' $total_vit_k ' . $total_vit_k."</b></i><br /><br/ >"; include 'inside_while.acc-over.php'; } } $bday++; } $bday = 1; } //return round($total_vit_k, 2); return $total_vit_k; } if ($value==4){ // if $value = 4 // end day and beg day dont matter // end month and beg month dont matter // end year > beg year for($byear; $byear<=$eyear; $byear++){ $query_year = $byear; $month_temp = 12; while($bmonth<=$month_temp){//while loop starts $query_month = $bmonth; //cycle through the days $days_in_month = date('t',mktime(0,0,0,$query_month,1,$byear)); $day_temp = $days_in_month; while($bday<=$day_temp){ $query_day = $bday; //redeclare the mysql query include 'acc-over-sql-queries.php'; if ($query_run = mysql_query($query_value4)){ while ($row = mysql_fetch_assoc($query_run)){ include 'inside_while.acc-over.php'; } } //-----------------------------------$bday++ unless stuff if ($byear < $eyear){ $bday++; }else if ($byear == $eyear){ if ($bmonth < $emonth){ $bday++; }else if($bmonth == $emonth){ if ($bday < $eday){ $bday++; }else if($bday == $eday){ $bday = $day_temp+1; } } } //-----------------------------------$bday++ unless stuff }//while day loop end $bday = 1; //-----------------------------------$bmonth++ unless stuff if ($byear < $eyear){ $bmonth++; }else if ($byear == $eyear){ if ($bmonth < $emonth){ $bmonth++; }else if($bmonth == $emonth){ $bmonth = 13; } } //-----------------------------------$bmonth++ unless stuff }//while loop ends if ($byear <= $eyear){ $bmonth = 1; } } return round($total_vit_k, 2); } } } ?> full code for the contents of the while loop: Code: [Select] <?php $sql_food = $row["name"]; $sql_year = $row["calendar_year"]; $sql_month = $row["calendar_month"]; $sql_day = $row["calendar_day"]; $sql_total_servings = $row["total_servings"]; $sql_vit_k = $row["vit_k"]; $sql_vit_k = $sql_vit_k/$sql_total_servings; $sql_servings = $row["servings"]; if ($sql_servings == 0){ $total_vit_k += $sql_vit_k; }else{ $total_vit_k += $sql_vit_k * $sql_servings; } ?> full code for the sql query getting included in the previous file: Code: [Select] $query_value3 = "SELECT foods.id, users_calendar.id, `name`, `source`,`vit_k`, `cal`,`protein`, `fiber`, `carbs`, `sugar`, `sodium`, `chol`, `total_servings`, `calendar_month`, `calendar_day`, `calendar_year`, `servings` FROM `foods` LEFT JOIN users_calendar ON foods.id=users_calendar.food_id WHERE users_calendar.user_id =". $_SESSION['user_id']." && " . $query_day . "=calendar_day && ".$query_month."=calendar_month && ".$byear."=calendar_year ORDER BY users_calendar.id"; Hi I have made a view all albums page for my website and I want it to only show 10 records. If there are more than 10 I would like a next or previous button to appear and for them to take you to the next 10 records or previous 10 records. Please can somebody show me where I can learn how to do this? I know it has something to do with msql_num_rows so I have a variable called $numrows I'll post the code I currently have here <form name="view_all_albums_frm" id="view_all_albums_frm"> <table width="793" border="0" cellspacing="5" id="all_albums_tbl" cellpadding="0"> <tr> <th scope="col">ID</th> <th scope="col">Album</th> <th scope="col">Album Description</th> <th scope="col">Edit</th> <th scope="col">Delete</th> </tr> <tr> <?php $qGetAlbums = ("SELECT * FROM albums ORDER BY `id` asc"); $rGetAlbums = mysql_query($qGetAlbums) or die(mysql_error()); $numrows = mysql_num_rows($rGetAlbums); while($AllAlbums = mysql_fetch_assoc($rGetAlbums)) { ?> <th height="26" scope="col"><?php echo $AllAlbums['id']; ?></th> <th height="26" scope="col"><?php echo $AllAlbums['album_name']; ?></th> <th scope="col"><?php echo $AllAlbums['album_description']; ?></th> <th scope="col"> </th> <th scope="col"> </th> </tr> <?php } ?> </table> </form> I'm going insane. whenever I select Oct, Nov, Dec from the drop down it doesn't show the corresponding month appropriately. I do this in the code and it shows 10, 11 or 12 corresponding to oct, nov, dec but then it shows no month if it's october, january if it's november or december. Help me please. echo '<br /><br /> form month var dump: '; var_dump($form_month); Code: [Select] $time = time(); $actual_month = date('m', $time); $actual_year = date('Y', $time); $word_month = date('M', $time); $word_year = date('Y', $time); if (isset($_POST['form_month']) && isset($_POST['form_year']) && !empty($_POST['form_month']) && !empty($_POST['form_year']) ) { $form_month = $_POST['form_month']; //multidimensional array but it should have only one value in it at a time I think $form_year = $_POST['form_year']; echo '<br /><br /> form month var dump: '; var_dump($form_month); //echo '<br /><br />'. $form_month['1']; $insert_month = $form_month['0']; //maybe this will work $insert_year = $form_year; }else{ $insert_month = $actual_month; $insert_year = $actual_year; } // I don't know how to convert the number 01 to Jan - so i'm doing this: $wtf_word_month = ""; switch ($insert_month) { case 1: $wtf_word_month = "Jan"; break; case 2: $wtf_word_month = "Feb"; break; case 3: $wtf_word_month = "Mar"; break; case 4: $wtf_word_month = "Apr"; break; case 5: $wtf_word_month = "May"; break; case 6: $wtf_word_month = "June"; break; case 7: $wtf_word_month = "July"; break; case 8: $wtf_word_month = "Aug"; break; case 9: $wtf_word_month = "Sep"; break; case 10: $wtf_word_month = "Oct"; break; case 11: $wtf_word_month = "Nov"; break; case 12: $wtf_word_month = "Dec"; break; } ?> <h2><?php echo $wtf_word_month ." ". $insert_year; ?></h2> <form id="form_month_changer" action="account-overview.php" method="POST"> Choose a month: <select name="form_month"> <option value="<?php echo '$insert_month'; ?>" ><?php echo $wtf_word_month; ?></option> <option value="1">Jan</option> <option value="2">Feb</option> <option value="3">Mar</option> <option value="4">Apr</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">Aug</option> <option value="9">Sept</option> <option value="10">Oct</option> <option value="11">Nov</option> <option value="12">Dec</option> </select> Choose a year <input type="text" name="form_year" maxlength="4" size="4" value="<?php echo $insert_year; ?>"> <input type="submit" value="Show me the calendar"> </form> <?php echo draw_calendar($insert_month,$insert_year); ?> Hi can any one help iv built a cms but when i had a page how easy is it to have a show or hide while making changes to the page many thanks for any help Code: [Select] $card1 = rand(1,3); $card2 = rand(1,3); /// check money win //////// if($card1 == "1" && $card2 == "1" ){ echo "You won 100$?"; exit; mysql_query("UPDATE card SET money='$win_money' WHERE name='$name'"); } My code works wonderfully prob tho how can I show the odds of winning out of 100 to my suer? I found this function and take no credit for it, I'm trying to get it to show HH:MM:SS when I have the total number of seconds, but nothing is showing on the screen function sec2hms ($sec, $padHours = false) { // start with a blank string $hms = ""; // do the hours first: there are 3600 seconds in an hour, so if we divide // the total number of seconds by 3600 and throw away the remainder, we're // left with the number of hours in those seconds $hours = intval(intval($sec) / 3600); // add hours to $hms (with a leading 0 if asked for) $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT). ":" : $hours. ":"; // dividing the total seconds by 60 will give us the number of minutes // in total, but we're interested in *minutes past the hour* and to get // this, we have to divide by 60 again and then use the remainder $minutes = intval(($sec / 60) % 60); // add minutes to $hms (with a leading 0 if needed) $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ":"; // seconds past the minute are found by dividing the total number of seconds // by 60 and using the remainder $seconds = intval($sec % 60); // add seconds to $hms (with a leading 0 if needed) $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT); // done! return $hms; } The part of the code to show the data is below: Code: [Select] while ($row = mysql_fetch_array($result)) { $sec = time() - strtotime($row['starttime']); echo $sec; // print to screen to make sure $sec had a value sec2hms($sec); } Any guidance on where I went wrong? Hi All, I want to be able to show selected pages of my website as PDF using a 'PDF' button much like this site does: http://www.westmeon.org.uk/index.php?option=com_content&task=blogsection&id=8&Itemid=35 I presume that I will need to install some sort of software on my server (which runs the latest PHP, MySQL etc.) but after hours of searching online I cannot find a simple way of doing this. Does anyone have any suggestions or pointers for how I can do this? FYI my website is written in PHP drawing data from a MySQL database. Regards, Neil The school district that I work for has been using a slide show PHP script that I designed, which uses random images from a database. I have now been asked to build in an option where they can enter text into the database and the script takes the text and either creates an image that is 1000pixels wide and 700 pixels tall with the text filled in the image or it just have the text re-sized to fit a text box with the same dimensions as above, so the students can see the text displayed from down the hall on the monitors. I would also like the script to have the ability to explode the text so the words can stay large in case of the user entering a long winded entry. Thank you in advance for any help. i am doing a little project but I get stuck on a problem. How do I show the content of my SQL database in PHP or HTML. I want it to show the title at the top, the text in the middle and maybe a price at the bottom. How do I do that? I can't seem to find a tutorial which covers only that, and I don't have the time to search each tutorial for some usefull information right now. And a second thing I want is that it will show the database in one list on a specific webpage. So people can look trough the list and find the thing they want and than click on it so they awill get directed to that item from the database. |