Jump to content

bateman

Members
  • Posts

    15
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

bateman's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. the glob was showing the file names, and the foreach you posted worked, now I just need to format it for my needs (the substr and such, which I've already tested). Right now I have it outputing to the screen, but once it's done, it's going to be a cron update page. Thank you
  2. So I've tried 6 different methods of pulling the data from the xml but each time I get nothing. I KNOW it's going to be something stupidly simple, but at the moment I'm stumpped. Here is the code I'm working with, and not that it's not complete as I still need to write in the glob code to limit the results to a single date. Edit: the print is commented because I used it to show me that the xml is reading. $date = date("Y-m-d"); //echo $fdate; $glob = "./fromdb/TimesheetBackup_" . $date. "*.xml"; foreach (glob ($glob) as $result) { echo $result; $xml = simplexml_load_file($result); $count = 0; //print_r($xml);// "<br> $xml"; foreach ($xml->tasks[] as $tasks): $starttimeb = $tasks['startDate']; $starttime = substr($starttimeb, -8, -1); $endtime = $tasks->key->endDate; echo $starttime; echo "<br> $endtime"; endforeach; } and a sample of the xml (end of a 48 record xml) <task> <taskId>f620bba390874d9fa41ddc4384ac0ba0</taskId> <projectId>7ab307cc59e84219b5e1b7b6215a7400</projectId> <description></description> <location>552 Pandora Ave, Victoria, BC V8W 1N7</location> <startDate>2014-01-02T13:15:00</startDate> <endDate>2014-01-02T16:33:00</endDate> <deleted>false</deleted> <endTime>0</endTime> <startTime>0</startTime> <lastUpdate>1388709184182</lastUpdate> <paid>0</paid> <feeling>0</feeling> </task> </tasks> </timesheet> I'm trying to get this to work with a xml that's created by the android app Timesheet. This is from it's auto backup system so I have no control over the output of the xml.
  3. That code there would work just fine, however, that's not the code your having issues with. It sounds like it's locked into the first image from the database. Are you trying to show just one image or a gallery?
  4. I've got a site running, and I would like to add up the totals from each location to one number, now I know it can be done, I just don't know how it'll work with my current code (see below) <table summary="" border="1" width="1100"> <tr> <td>Date</td> <!-- <td>Employee</td> --> <td>Store</td> <td>Customers</td> <td>Quotes</td> <td>Phone Calls</td> <td>Services In</td> <td>Services Out</td> <td>Invoices</td> <td>Conversion</td> <td>End of Day</td> <td>Emails</td> <td colspan=3>Notes</td> </tr> <? $x = 1; $y=1; $lastdate=0; while ($list = mysql_fetch_assoc($query)) { $dateadd = $list['dateadd']; $dateb = strtotime($list['dateadd']); $date = date("M j Y", $dateb);$date2 = date("Y-m-d", $dateb); $firstname = $list['firstname'];$lastname = $list['lastname'];$store = $list['store'];$customers = $list['cust'];$sales = $list['sales'];$invoices = $list['invoices'];$sin = $list['servin'];$sout = $list['servout'];$eod = $list['eod']; $phone = $list['phone']; $notes = $list['notes']; $emails = $list['emails']; if ($store == "1") {$storename = "Broadmead";} elseif ($store == "2") {$storename = "Duncan";} elseif ($store == "3") {$storename = "Surrey";} elseif ($store == "4") {$storename = "Sooke";} elseif ($store == "5") {$storename = "Nanaimo";} elseif ($store == "6") {$storename = "Shelbourne";} ?> <?php if ($lastdate == $date) { ?> <tr> <td width="125"><?=$date;?></td> <!-- <td width="125"><?=$firstname;?> <?=$lastname;?></td> --> <td width="100"><?=$storename;?></td> <td width="71"><?=$customers;?></td> <td width="71"><?=$sales;?></td> <td width="80"><?=$phone;?></td> <td width="80"><?=$sin;?></td> <td width="90"><?=$sout;?></td> <td width="71"><?=$invoices;?></td> <td width="71"><? $convbase = $sout+$sales; if (!$invoices==0 && !$customers==0) {$conv = $invoices / $customers * 100;} else {$conv=0;} echo money_format('%(#1n', $conv) . "\n"; ?>%</td> <td width="71">$<?echo money_format('%(#1n', $eod) . ""; ?><td> <td width="71"><?=$emails;?> </td> <td width="150"><?if (!$notes==NULL){echo $notes;} else {echo " ";}?></td> </tr> <?php } else { ?> <tr> <td colspan="9">Daily Total</td> <td><?echo money_format('%(#1n', $total) . ""; ?> </td> <td colspan="4"> </td> </tr> </table> <hr width="1100" align="left" color="0000ff"> <table summary="" border="1" width="1100"> <tr> <td width="125"><?=$date;?></td> <!-- <td width="125"><?=$firstname;?> <?=$lastname;?></td> --> <td width="100"><?=$storename;?></td> <td width="71"><?=$customers;?></td> <td width="71"><?=$sales;?></td> <td width="80"><?=$phone;?></td> <td width="80"><?=$sin;?></td> <td width="90"><?=$sout;?></td> <td width="71"><?=$invoices;?></td> <td width="71"><? $convbase = $sout+$sales; if (!$invoices==0 && !$customers==0) {$conv = $invoices / $customers * 100;} else {$conv=0;} echo money_format('%(#1n', $conv) . "\n"; ?>%</td> <td width="71">$<?echo money_format('%(#1n', $eod) . ""; ?><td> <td width="71"><?=$emails;?> </td> <td width="150"><?if (!$notes==NULL){echo $notes;} else {echo " ";}?></td> </tr> <?php } $lastdate = $date; } // end while ?> </table> Any help would be appreciated.
  5. the code is <?php $qty=$_POST['quantity']; $service=$_POST['service']; $reciept=$_POST['reciept']; if (service=SC1) {$desc="Hourly Service"; $price = "20";} elseif (service=SC2) {$desc="Hourly Service - Half hour"; $price = "10";} elseif (service=SC3) {$desc="Hourly Service - Extended area"; $price = "30";} elseif (service=SC5) {$desc="Virus Removal / Computer Cleanup"; $price = "40";} elseif (service=cl1) {$desc="Physical Cleaning of computer"; $price = "10";} elseif (service=ba1) {$desc="Data backup \$1 per 5gb"; $price = "1";} elseif (service=OS1) {$desc="Windows XP install"; $price = "50";} elseif (service=OS2) {$desc="Windows Vista install"; $price = "50";} elseif (service=OS3) {$desc="Windows 7 install"; $price = "50";} elseif (service=OS4) {$desc="Windows XP install - No disk"; $price = "50";} elseif (service=OS5) {$desc="Windows Vista install - No disk"; $price = "120";} elseif (service=OS6) {$desc="Windows 7 install - No disk"; $price = "250";} elseif (service=OS6) {$desc="Linux install"; $price = "50";} elseif (service=OS6) {$desc="Linux install - No disk"; $price = "60";} $total = $price * $qty; mysql_select_db($database_local, $local); { $sql=mysql_query("INSERT INTO service (qty, item, description, price, discount, total, reciept) VALUES('$qty','$service','$desc', '$price', '$discount', '$total', '$reciept') ") or die(mysql_error()); $result=mysql_query($sql); } I've looked it over myself and run a syntax checker, neither can find an error
  6. What you want to do is run an update, targeted just for that field. This is what I run (for last login) $lastlogin = date("Y-m-d H:i:s"); $sql="update users set lastlogin='$lastlogin' WHERE username='$un'"; Of course you can change the date field to the timestamp of your preference.
  7. Try this (cleared all the echo's where not needed) <?php //Check to see if the form has been submitted if (isset($_POST['submitted'])) { //Connect to the database require_once('/mysql_connect.php') ; //Create the query $query = "SELECT * FROM students WHERE student_id = {$_POST['student_name']}" ; $result = mysqli_query($dbc, $query) ; $num = mysqli_num_rows($result) ; if ($num >= 1) { //Query was successfull //Store all infomation in array //Display the students information $row = mysqli_fetch_array($result, MYSQLI_BOTH) ; ?> <p>Student ID: <b><?=$row['student_id'];?></b></p>' ; <p>Student Name: <b><?=$row['first_name'];?> <?=$row['last_name'];?></b></p> <p>Student Phone #: <b><?=$row['phone'];?></b></p> <p>Student Address: <b><?=$row['address'];?><br /><?=$row['city'];?>,<?=$row['state'] . ' ' . $row['postal_code'];?></b></p>' ; <?} else { //There was an error with the query ?> <p>There was an error with the query. Error # 1. The mysqli_error() is: <? mysqli_error($dbc); } } else { //The form has not been submitted //Display the form ?> <fieldset><legend>Please select a student from the drop down list.</legend> <form action="home.php" method="post"> <select name="student_name" size="1">' ; <?//Create the query $query = "SELECT student_id, first_name, last_name FROM students ORDER BY last_name" ; $result = mysqli_query($dbc, $query) ; $num = mysqli_num_rows($result) ; if ($num >= 1) { //Query was successfull //Fetch all of the results while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) { ?> <option value="<?=$row['student_id'];?>"><?=$row['last_name'];?>,<?=$row['first_name'];?></option>' ; <?} } else { //There was an error with the query ?><p>There was an error with the query. Error # 2. The mysqli_error() is: <? mysqli_error($dbc); } ?> </select> <p><input name="submit" type="submit" value="Submit"></p> <p><input name="submitted" type="hidden" value="true"></p> </form> <?} ?>
  8. ok, I figured it out. Thank you. that ID sort was kinda missed the first 10^8 times
  9. It is pulling from the database, I just didn't include that here. after inserting the or die it came back with
  10. alright, so I'm trying to pull data from 2 tables to create a list. I'm successful in phpmyadmin but it won't pull when I try from php. Here is the code I'm using $query2 = mysql_query("SELECT * FROM photog, shoot WHERE photog.actual=shoot.photog ORDER BY id Asc"); ... ... $x = 1; while ($list = mysql_fetch_assoc($query2)) { $photog = $list['photographer']; $link = $list['actual']; $picid = $list['image'];$shoot = $list['shoot']; $num = $list['num']; // echo data ?> <?=$photog;?><br><a href="model/index.php?p=<?=$link;?>&s=<?=$num;?>&i=1" ><?=$shoot;?></a><? echo ($x)? "<br><br>" : ""; $x++; } // end while Any help would be appreciated.
  11. bateman

    Gallery

    There is the Lazy gallery. http://www.forge22.com/lazy-gallery/preview/ or you can use my customized one which you can throw into your own template. You can see mine @ http://celebdb.outerregion.net or copy from here image_resize.php <?php /*============================================= Uber-Simple Photo Gallery by Sam Perkins-Harbin www.forge22.com Last Revision: 20 May, 2005 =============================================*/ $image = $_GET['i']; $max_width = $_GET['w']; $max_height = $_GET['h']; $picture_location = $image; $picture_save = str_replace($image, ".jpg", ".temp"); $im_size = GetImageSize ( $picture_location); $imageWidth = $im_size[0]; $imageHeight = $im_size[1]; $im2 = ImageCreateFromJPEG($picture_location); $x_ratio = $max_width / $imageWidth; $y_ratio = $max_height / $imageHeight; if ( ($imageWidth <= $max_width) && ($imageHeight <= $max_height) ) { $tn_width = $imageWidth; $tn_height = $imageWeight; } else if (($x_ratio * $imageHeight) < $max_height) { $tn_height = ceil($x_ratio * $imageHeight); $tn_width = $max_width; } else { $tn_width = ceil($y_ratio * $imageWidth); $tn_height = $max_height; } $im = imageCreateTrueColor( $tn_width, $tn_height ); ImageCopyResized ($im,$im2, 0, 0, 0, 0, $tn_width, $tn_height, $imageWidth, $imageHeight); Header("Content-type: image/jpeg"); Imagejpeg($im,'',100); //to print to screen Imagejpeg($im,$picture_save,100); ImageDestroy($im); ImageDestroy ($im2); ?> gallery.php <?php /*============================================= Drop-In Photo Gallery by Sam Perkins-Harbin www.forge22.com Last Revision: 26 November, 2005 You may modify this code as you wish, but please send me any modifications you do, and keep my URL on the footer! Rename this file index.php for it to automatically be your gallery, otherwise name it whatever you want. This file must be used with the resize_image.php file to create the thumbnails. This program uses the image resize script to generate thumbnails on the fly for a directory. It parses directory structure, and outputs navigation. Thumbnails are generated for each image in a directory. You can specify how many thumbs are displayed per page, thumbnail size, and if folder navigation should be on. CSS colors and layout are standard and editable as well. CSS generates paragraph size based on specified size of thumbnail. Each paragraph contains the thumbnail, image dimensions and image filesize. =============================================*/ $limit = 9; // number of thumbs to show per page. $w = 190; // max width of thumbnails. $h = 140; // max height of thumbnails. $show_folders = 0; // Set to 1 to show folder list, 0 to turn off $isize = 1; // Set to 1 to display image filesize $idim = 1; // Set to 1 to display image dimensions //============================================ // No further options below here. if($pg = $_GET['pg']) { $thumb = (($pg-1)*$limit); $i = $thumb; } //if($thumb = $_GET['thumb']) // $i = $thumb; else $i = 0; // get the directory name $dirlist = dirname($_SERVER['SCRIPT_NAME']); // split it up $subdir = explode("/", $dirlist); // reverse it so directory above images is listed $subdir = array_reverse($subdir); // page title name is root dir. $title = str_replace("_", " ", $subdir['0']); //$my_uri = "http://" . $_SERVER['HTTP_HOST'] . $HTTP_SERVER_VARS["SCRIPT_NAME"]; if(ereg("\.\.", $_GET['id'])) header ("Location: ?"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <style type="text/css"> h1 {font-size: 16px; margin: 1em; } #dirnav {height: 16px; position: relative; margin: auto auto 5px auto; clear: both; border-bottom: 1px solid #aaa; text-align: center; padding: 3px; } #dirnav ul, #dirnav li {margin: auto; padding: 0; list-style-type: none; } #dirnav li {float: left; text-align: center; } #dirnav a {display: block; padding: 2px 5px 2px 5px; } #thumbs {width: 100%; margin: 10px; border: 1px solid black; clear: both; text-align: center; } p.thumb {width: <? echo $w+18; ?>px; height: <? echo $h+32; ?>px; margin: 1em; padding: 3px; float: left; border: 1px solid #000; font-size: 12px; text-align: center; } #nav {position: relative; margin: auto; clear: both; border-top: 1px solid #aaa; text-align: center; } #nav ul, #nav li {margin: auto; padding: 0; list-style-type: none; } #nav li {float: left; text-align: center; } #nav li.current a.page {font-weight: bold; color: #ddd; } #nav a {} #nav a.page {display: block; padding: 2px 5px 2px 5px; } #nav a.prev, #nav a.next , #nav .prev, #nav .next {display: block; width: 65px; padding: 2px 5px 2px 5px; } #nav a:hover { } a {color: #999; text-decoration: none; } a:hover, a:active {color: #d0d0d0; } a img {border: 1px solid #777; } a:hover img {border: 1px solid #d0d0d0; } a.page {color: #999; } </style> </head> <body> <? //echo '<h1>Photo Gallery: '.$title.'</h1>'; //-------------------------------- Directory Navigation ----------------------------- function dir_list($dir) { global $title; $dlist = array(); if ($hdir = opendir('./'.$dir)) { while ($obj = readdir($hdir)) { if (((preg_match("/^\./",$obj)==0) && (!eregi('^(.*).[code=php:0]$', $obj))) && is_dir($dir.$obj)) //if(is_dir($dir.$obj)) $dlist[] = $obj; } closedir($hdir); } else die('Cannot list files for ' . $dir); asort($dlist); echo "<div id='dirnav'><ul>\n<li>Folders:</li>\n"; echo "<li> <a href='?'>$title » </a></li>\n"; $dirtree = explode("/", $_GET['id']); // parse directory tree from passed "d" if(!$_GET['id']) array_shift($dirtree); // remove redundant "." directory from tree foreach ($dirtree as $dirsub) { echo "<li> <a href='?d=$dirparent$dirsub'>$dirsub » </a></li>\n"; $dirparent .= $dirsub.'/'; } foreach ($dlist as $link) { echo "<li><a href='?d=$dir$link'>[$link]</a></li>\n"; } echo "</ul>\n</div>\n"; } //-------------------------------------Get image file size ---------------------------------- function getfilesize($size) { $units = array(' B', ' KB', ' MB', ' GB', ' TB'); for ($i = 0; $size > 1024; $i++) { $size /= 1024; } return round($size, 2).$units[$i]; } //-------------------------------------Set which folder we are viewing---------------- if($_GET['id']) { $d = $_GET['id'].'/'; $dd = 'id='.$_GET['id'].'&'; // for use in passing to URL strings $current_dir .= $d; } opendir($current_dir); if ($show_folders) dir_list($current_dir); //--------------------------------------- Create list of Images ------------------------ $list = array(); if ($dir = opendir('./'.$current_dir)) { while ($file = readdir($dir)) { //if((is_file($file)) && ((!eregi('^(.*).[code=php:0]$', $file)) && (!eregi('^(\.htaccess)$', $file)))) //if((eregi('^(.*).[jpg]$', $file)) && (!eregi('^(.*).[code=php:0]$', $file))) //if (eregi('^(([:alnum:])*)\.((j|J)(p|P)(g|G)))$', $file)) if (eregi('.jpg', $file)) //If file is a JPG $list[] = $file; } closedir($dir); } asort($list); // sort alpha $numtotal = count($list); //total number of thumbs if ($thumb) { $s = 0; while($s < $thumb) { array_shift($list); $s++; } } $numremain = count($list); // total remaining thumbs //-------------------------------------- Create Thumbnails and Gallery ------------------ foreach ($list as $pic) { $fp = $current_dir.$pic; if($i < $thumb+$limit) { //echo "<p class='thumb'><tt><a href='$current_dir$pic'><img src='tn/$pic' alt='$pic' /><br />$pic</a> - [".getfilesize(filesize($fp))."]</tt></p>\n"; $image = $currentdir.$pic; $i_size = getfilesize(filesize($fp)); $i_area = getimagesize($fp); $i_width = $i_area[0]; $i_height = $i_area[1]; //$i_mtime = date("d F Y ", filemtime($fp)); $name = str_replace('.jpg', '', $pic); echo "<p class='thumb'> <tt> <a href='$current_dir$pic'><img src='image_resize.php?i=$d$pic&w=$w&h=$h' alt='$pic' /><br /> $name<br /></a>\n"; if($idim) echo " [$i_width x $i_height]"; if($idim && $isize) echo " - "; if ($isize) echo " [$i_size]"; echo " <br /> </tt> </p>\n"; $i++; } } //---------------------------------------Page Navigation ----------------------------- $page = 0; if(!$pg) $pg = 1; echo "<div id='nav'>\n<ul>\n"; if($thumb > 0) echo "<li><a class='prev' href='?".$dd."pg=".($pg-1)."'>« Prev $limit</a></li>\n"; else echo "<li><div class='prev'>« Prev $limit</div></li>"; while($page*$limit < $numtotal) { $page ++; unset($cur); if($page == $pg) { $cur = ' class="current"'; } echo "<li$cur><a class='page' href='?".$dd."pg=$page'>[".($page)."]</a></li>\n"; } if($numremain > $limit) echo "<li><a class='next' href='?".$dd."pg=".($pg+1)."'>Next $limit »</a></li>\n"; else echo "<li><div class='next'>Next $limit »</div></li>\n"; echo "</ul></div>Photo Gallery by [<a href='http://www.forge22.com' target='_blank'>Forge22</a>]\n"; ?> </body> </html>
  12. I actually got it working without having to change all that. I'm simply gonna change my menu to include page &pg=1 (not hard with replace). Thank you for your help I did change it after I made this post and now I see why you said it. Thank you again.
  13. well it partially works. Looking to see if I can fix it on my own, thank you. If you want to see what it's doing click on the second link in my first post (showtmp)
  14. I've put in extra spaces here for ease of finding the code. <html> <?php require_once('connections/local.php'); ?> <?php mysql_select_db($database_local, $local); //if(isset($_REQUEST['id'])) { $query = mysql_query("SELECT * FROM mixed WHERE id = \"$_GET[id]\""); $row = mysql_fetch_assoc(mysql_query('SELECT * FROM `mixed`')); $result = mysql_fetch_assoc($query); // etc { } } ?> <head> <title>Outerregion Celebrity Database Version 2</title> <meta name="author" content="Earl Bateman"> <meta http-equiv="Content-Language" content="en" /> <meta name="description" content="Outerregion Celebrity Database is a recreation and expansion of Mikes Celebrity Picture Page which was closed down 2 years ago. Now with more then just pictures we include biographies, Birthdays, and in many cases full birth names."></head> <meta name="keywords" content="" /> <meta http-equiv="Expires" content="0" /> <meta name="Resource-Type" content="document" /> <meta name="Distribution" content="global" /> <meta name="Robots" content="index, follow" /> <meta name="Revisit-After" content="21 days" /> <meta name="Rating" content="general" /> <link rel="stylesheet" type="text/css" href="menu.css" media="screen" /> </head> <body bgcolor="#a3a9a9" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"> <!--Header--> <table width=945 border=0 align=center cellpadding=0 cellspacing=0 summary=""> <tr> <td width=944 height=119 background="images/top.jpg"> </td> </tr> <tr> <td height=40 width=900 background="images/menu.jpg" align="right" valign=top><?php include("menu.php"); ?></td> </tr> <tr> <td background="images/content.jpg" align=center valign=middle> <table border="0" summary="" width="900"> <tr> <td><table border="0" summary=""> <tr> <td width="230"> <B><?= $result['Name']; ?></B></td> <td>D.O.B.: <?= $result['dob']; ?> <br> </td> <td>Height: <?= $result['Height']; ?></td></tr> <tr> <td colspan="3"><hr color="c0c0c0">Bio:<br><?= $result['Bio']; ?></td></tr> <tr> <td colspan="5"><hr color="c0c0c0">Photos:<BR><?php include("$_GET[id]/gallery.php");?></td> </tr> </table></table> </td> </tr> <tr> <td width=944 height=44 background="images/bottom.jpg" align=center valign=middle colspan="3"><?php include("footer.php"); ?></td> </tr> </table> </body> </html>
  15. I run a php driven site and for most things I get by on my own (no small thanks to the people at this site about 2 years ago). Anyways I'm trying to figure out how to make the text from the bio (which is pulled from the database) to disappear after the first page. If your not sure what I'm talking about go to http://celebdb.outerregion.net/show.php?id=82 An example of what I want is http://celebdb.outerregion.net/showtmp.php?id=82&pg=2 but with a link to expand the bio if they like.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.