Jump to content

craygo

Staff Alumni
  • Posts

    1,972
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by craygo

  1. Why even put the POST in an array in the first place??
  2. $count = mysql_num_rows($result); Ray
  3. try this <?php $time1 = "1:30"; $time2 = "2:41"; $t1 = explode(":", $time1); $t2 = explode(":", $time2); echo date("G:i:s", mktime($t1[0]+$t2[0], $t1[1]+$t2[1] , 0))."<br />"; // output 4:11:00 ?> Ray
  4. do it in one query if(mysql_result(mysql_query("SELECT * FROM `products` WHERE `barcode`='{$barcode}'"), 0)){ mysql_query("UPDATE `products` SET `price`= $price, `quantity`=(`quantity` + $quantity) WHERE `barcode`='{$barcode}'") or die(mysql_error()); } else { //Nope, add a new one. mysql_query("INSERT INTO products (id, name, barcode, price, quantity) VALUES('$id', '$name', '$barcode', '$price', '$quantity') ") or die( mysql_error()); } Ray
  5. you can use the span tag and some funky css <style> .numberofposts { font-size: 18px; color: red; } .numberofposts span { font-size: 20px; color: green; font-weight: bold; } </style> <?php $numberofposts = 40; echo "<div class =\"numberofposts\">Number of posts: <span>" .$numberofposts."</span></div>"; ?> in the style ".numberofposts span" you are formatting the span tag INSIDE the numberofposts class. So only the span tags withing this particular div will have the format. Ray
  6. you have to put the email in another input field to be passed by the second form. You should also use some checks so you don't get errors. I have error reporting on so I get all kinds of warnings when I run your code. <?php if(!isset($_POST['email'])){ ?> <form method="post" name="test" action=""> Enter your new email address here: <input type ="text" size="30" name ="email"> <input type="submit" value="GO!"> </form> <?php } else { if(!isset($_POST['yes_no']) && isset($_POST['email'])){ $email=$_POST['email']; $change['email'] = trim((!empty($_POST['email'])) ? $_POST['email']: $_GET['email']); if(strlen($change['email']) > 3){ ?> <form method="post" action="" name="yes/no"> <input type=hidden name=email value="<?php echo $change['email']; ?>" /> NEW E-Mail: <?php echo $change['email']; ?><br /> Yes<input type="radio" name="yes_no" value="yes"> No<input type="radio" name="yes_no" value="no"> Confirm changes: <input type="submit" value ="Confirm"> </form> <?php } } else { $email = $_POST['email']; echo" Your email address is: $email";// $email should be displaying the new email address. but after yes_no submit, no data is shown why? Huh echo " Why is this bloody not displaying the set varable!!! $email"; } } ?> Ray
  7. Just write a custom function. Here is one and you can expand on the formats <?php function curr_format($curr, $amount){ switch ($curr){ case "EUR": $ret = "€".number_format($amount, 2, ",", " "); break; case "US": $ret = "&#36;".number_format($amount, 2, ".", ","); break; } return $ret; } echo curr_format("EUR", "2568.2523"); // output is €2 568,25 ?> Ray
  8. I have a custom made one for my clan. It grabs data from our database and creates the picture. Go to hlstatsx and download the current release, Look in the web folder and you will have a file called sig.php. That file creates the picture from data retrieved. Will get you going at least.
  9. Might be your query. You have already linked the tables with the inner join, no need to do it again in the where clause. try like this $query = "SELECT orderdetails.Ordernum, orderdetails.MenuItemID, orderdetails.CustFName, orderdetails.CustSName, orderdetails.StreetAddr, orderdetails.itemQuantity, orderdetails.itemcost, menuitemdetails.MenuItemName, menuitemdetails.MenuItemDesc, menuitemdetails.MenuItemType FROM orderdetails RIGHT JOIN menuitemdetails ON orderdetails.MenuItemID=menuitemdetails.MenuItemID WHERE orderdetails.OrderNum = '".$_SESSION['order']."' and MenuItemType = '".$itemtype[$i]."'"; Ray
  10. i think you may have you tables a little mixed up. If your main table is traff and the linked table is comments, and there can be more than one comment per row, you need to change the way the link is. You need to drop the CELLID from the traff table and add the BSCID to the comments table. That way there can be more that one comment per row in the traff table. As you have it now there can be one comment to many traff rows. Ray
  11. Here is some code for you to try. I pieced this together from some site I found. I hope you can figure it out to apply to your own tables and fields. <script type="text/javascript" language="JavaScript"> <!-- Copyright 2006,2007 Bontrager Connection, LLC // http://bontragerconnection.com/ and http://www.willmaster.com/ // Version: July 28, 2007 var cX = 0; var cY = 0; var rX = 0; var rY = 0; function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;} function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;} if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; } else { document.onmousemove = UpdateCursorPosition; } function AssignPosition(d) { if(self.pageYOffset) { rX = self.pageXOffset; rY = self.pageYOffset; } else if(document.documentElement && document.documentElement.scrollTop) { rX = document.documentElement.scrollLeft; rY = document.documentElement.scrollTop; } else if(document.body) { rX = document.body.scrollLeft; rY = document.body.scrollTop; } if(document.all) { cX += rX; cY += rY; } d.style.left = (cX+10) + "px"; d.style.top = (cY+10) + "px"; } function HideContent(d) { if(d.length < 1) { return; } document.getElementById(d).style.display = "none"; } function ShowContent(d) { if(d.length < 1) { return; } var dd = document.getElementById(d); AssignPosition(dd); dd.style.display = "block"; } function ReverseContentDisplay(d) { if(d.length < 1) { return; } var dd = document.getElementById(d); AssignPosition(dd); if(dd.style.display == "none") { dd.style.display = "block"; } else { dd.style.display = "none"; } } //--> </script> </head> <body> <table width="300" align="center" /> <tr> <td>MakeID</td> <td>Make</td> <td>Veh Type</td> </tr> <?php // database connection here function create_div($width, $fields, $table, $w_field, $w_value, $unique){ $f = implode("`, `", $fields); $sql = "SELECT `$f` FROM `$table` WHERE `$w_field` = '$w_value'"; $res = mysql_query($sql) or die(mysql_error()); $div = "<div id=\"data".$unique."\" style=\"display:none; position:absolute; border-style:solid; background-color:white; padding: 0px; width:".$width."px\" />\n"; while($r = mysql_fetch_assoc($res)){ foreach($fields as $name){ $div .= $r[$name]." "; } $div .= "<br />"; } $div .= "</div>\n"; return $div; } $sql = "SELECT * FROM makes"; $res = mysql_query($sql) or die(mysql_error()); $i=0; $fields = array("model_id", "model_name"); while($r = mysql_fetch_assoc($res)){ echo create_div("200", $fields, "models", "makeid", $r['make_id'], $i); ?> <tr> <td><?php echo $r['make_id']; ?></td> <td><a onmouseover="ShowContent('data<?php echo $i; ?>'); return true;" onmouseout="HideContent('data<?php echo $i; ?>'); return true;" href="javascript:ShowContent('data<?php echo $i; ?>')"><?php echo $r['make_name'];?></a> </td> <td><?php echo $r['veh_type']; ?></td> </tr> <?php $i++; } ?> </table> </body> </html> If you need help let me know Ray
  12. Well that is why your implode function is failing. There is no array to implode. Post the code for your form.
  13. you would need to either call the function 8 times or change the function to give you 8 images in an array. Personally I would store the 8 images in an array then call them from the array. <?php error_reporting(0); function get_pic(){ $dir = "files"; if ($handle = opendir($dir)) { $count=0; /* Dit is de juiste manier om door een directory te wandelen. */ while (false !== ($file = readdir($handle))) { if(getimagesize("$dir/".$file)) { $count++; $dirlist[$count]="$dir/".$file; } } closedir($handle); for($i=0; $i<8; $i++){ $filenr = rand(1,$count); $images[] = $dirlist[$filenr]; } return $images; } } $pics = get_pic(); // now your 8 images would be this echo "<a href=\"".$pics[0]."\" /><img src=\"".$pics[0]."\" cellpadding=\"0\" cellspacing=\"0\" width=\"200\" height=\"200\" /></a>\n"; echo "<a href=\"".$pics[1]."\" /><img src=\"".$pics[1]."\" cellpadding=\"0\" cellspacing=\"0\" width=\"200\" height=\"200\" /></a>\n"; echo "<a href=\"".$pics[2]."\" /><img src=\"".$pics[2]."\" cellpadding=\"0\" cellspacing=\"0\" width=\"200\" height=\"200\" /></a>\n"; echo "<a href=\"".$pics[3]."\" /><img src=\"".$pics[3]."\" cellpadding=\"0\" cellspacing=\"0\" width=\"200\" height=\"200\" /></a>\n"; echo "<a href=\"".$pics[4]."\" /><img src=\"".$pics[4]."\" cellpadding=\"0\" cellspacing=\"0\" width=\"200\" height=\"200\" /></a>\n"; echo "<a href=\"".$pics[5]."\" /><img src=\"".$pics[5]."\" cellpadding=\"0\" cellspacing=\"0\" width=\"200\" height=\"200\" /></a>\n"; echo "<a href=\"".$pics[6]."\" /><img src=\"".$pics[6]."\" cellpadding=\"0\" cellspacing=\"0\" width=\"200\" height=\"200\" /></a>\n"; echo "<a href=\"".$pics[7]."\" /><img src=\"".$pics[7]."\" cellpadding=\"0\" cellspacing=\"0\" width=\"200\" height=\"200\" /></a>\n"; ?> Ray
  14. yes but if you echo it out are you getting anything print_r($_POST['products']); Ray
  15. You would be better off making it a function then assigning the random picture name to a variable so it will be clickable. <?php error_reporting(0); function get_pic(){ $dir = "files"; if ($handle = opendir($dir)) { $count=0; /* Dit is de juiste manier om door een directory te wandelen. */ while (false !== ($file = readdir($handle))) { if(getimagesize("$dir/".$file)) { $count++; $dirlist[$count]="$dir/".$file; } } closedir($handle); $filenr = rand(1,$count); return ($dirlist[$filenr]); } } $pic = get_pic(); echo "<a href=\"$pic\" /><img src=\"$pic\" cellpadding=\"0\" cellspacing=\"0\" width=\"200\" height=\"200\" /></a>\n"; ?> Ray
  16. do you have a products array being set from your POST form??
  17. Use single or double quotes around strings if ($_GET['ads']== 'en') You forgot a single quote in your query $sql="insert into `settings` set adsense = '$acode'";
  18. What error are you getting. Just a quick look, you may want to enclose your variables in single quotes. $product['rec'] and $_POST['products']. Ray
  19. if you use some error checking you will see your problem $query = mysql_query($sql)or die(mysql_error()); once you see the error code you would find out that WHERE clauses are seperated by AND not a comma as well as you added an extra semi colon WHERE userid = '" . $id . "' AND id = '" . $accountid . "'"; Ray
  20. As long as php has permisission to create a new folder it should be no problem. How are you getting the users name? Are they already logged in?? is the name in a session variable??
  21. try this out. <?php require_once('odbc.php'); function get_seconds($t){ $seconds = 0; if(is_array($t)){ foreach($t as $v){ $array = array(); $pt1 = array(); $pt2 = array(); $array = explode(':', $v); $pt1[] = $array[0]; $pt2 = explode("'", $array[1]); $time = array_merge($pt1, $pt2); $sec = $time[2]; $min = $time[1]*60; $hour = $time[0]*60*60; $seconds += ($sec+$min+$hour); } } else { $array = explode(':', $t); $pt1[] = $array[0]; $pt2 = explode("'", $array[1]); $time = array_merge($pt1, $pt2); $sec = $time[2]; $min = $time[1]*60; $hour = $time[0]*60*60; $seconds += ($sec+$min+$hour); } return $seconds; } if(isset($_POST['submit'])) { $id = $_POST['id']; $ex = $_POST['ex']; if($id!="" & $ex!="") { echo "<b>Total number of calls for : ".$id."<br></b>"; $unixtime = time(); echo "" . date("F j, Y, g:i a",$unixtime) . "<br><br>"; $time = array(); $sql = "SELECT `Date`, `Extension`, `Duration` (SELECT COUNT(`Extension`) FROM `AllInfo` WHERE AllInfo.Date=#$id# AND AllInfo.Extension='$ex') AS `count` FROM `AllInfo` GROUP BY AllInfo.Date, AllInfo.Extension HAVING (((AllInfo.Date)=#$id#) AND ((AllInfo.Extension)='$ex'))"; // `Extension` = '$ex' AND `Date` = #$id# "; //GROUP BY Date, Extension"; $result = odbc_exec($odbc, $sql) or die(odbc_error()); echo "<center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"borderTable\"><tr><th class=\"borderTable\"> Extension </th><th class=\"borderTable\"> Time </th><th class=\"borderTable\">Total Dials</th><th class=\"borderTable\">Total Talk Time</th></tr>"; while($row = odbc_fetch_array($result)) { $cur_ext = $row['Extension']; $cur_date = $row['Date']; $t_sql = "SELECT `Duration` FROM `AllInfo` WHERE `Extension` = '$cur_ext' AND Date = #$cur_date# GROUP BY `Date`, `Duration`"; $t_res = odbc_exec($odbc, $t_sql) or die(odbc_error()); while($tr = odbc_fetch_array($t_res)){ $time[] = $tr['Duration']; } echo "<tr>"; echo "<td class=\"borderTable\"><center>$ex</center></td class=\"borderTable\">"; echo "<td class=\"borderTable\"><center>00:01-23:59</center></td class=\"borderTable\">"; echo "<td class=\"borderTable\"><center>".$row['count']."</center>"; $seconds = get_seconds($time); echo "<td class=\"borderTable\"><center>".date("H:i:s", mktime(0, 0, $seconds))."</center></td class=\"borderTable\"></table><p></p>"; } // end while } // end if } // end if ?> Ray
  22. To better help you out, if you don't mind sending me the access file with just the table in question withe some sample data. I can help you a lot better. Just PM me the file if you like Ray
  23. Well to be honest, even if you did it wouldn't help. Working with remote files is not one of php's strong points or any web based language for that matter. You won't be able to browse shared directories on the windows box from the linux box. Only way to do something like that would be to setup an FTP server on the windows server and have linux connect to it through some login script. Even then transferring the files would be a nightmare. You would have to transfer the file to the linux box through ftp then download the file from the linux box.
  24. try this out <p><?php require_once('odbc.php'); function get_seconds($t){ $seconds = 0; if(is_array($t)){ foreach($t as $v){ $array = array(); $pt1 = array(); $pt2 = array(); $array = explode(':', $v); $pt1[] = $array[0]; $pt2 = explode("'", $array[1]); $time = array_merge($pt1, $pt2); $sec = $time[2]; $min = $time[1]*60; $hour = $time[0]*60*60; $seconds += ($sec+$min+$hour); } } else { $array = explode(':', $t); $pt1[] = $array[0]; $pt2 = explode("'", $array[1]); $time = array_merge($pt1, $pt2); $sec = $time[2]; $min = $time[1]*60; $hour = $time[0]*60*60; $seconds += ($sec+$min+$hour); } return $seconds; } if(isset($_POST['submit'])) { $id = $_POST['id']; $ex = $_POST['ex']; if($id!="" & $ex!="") { echo "<b>Total number of calls for : ".$id."<br></b>"; $unixtime = time(); echo "" . date("F j, Y, g:i a",$unixtime) . "<br><br>"; $time = array(); $sql = "SELECT Date, Extension, Duration FROM AllInfo WHERE Extension = '$ex' AND Date=#$id# GROUP BY Date, Extension"; $result = odbc_exec($odbc, $sql) or die(odbc_error()); echo "<center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"borderTable\"><tr><th class=\"borderTable\"> Extension </th><th class=\"borderTable\"> Time </th><th class=\"borderTable\">Total Dials</th><th class=\"borderTable\">Total Talk Time</th></tr>"; while($row = odbc_fetch_array($result)) { $cur_ext = $row['Extension']; $cur_date = $row['Date']; $t_sql = "SELECT Duration FROM AllInfo WHERE Extention = '$cur_ext' AND Date = '#$cur_date#'"; $t_res = odbc_exec($odbc, $t_sql) or die(mysql_error()); while($tr = odbc_fetch_array($t_res)){ $time[] = $tr['Duration']; } echo "<tr>"; echo "<td class=\"borderTable\"><center>$ex</center></td class=\"borderTable\">"; echo "<td class=\"borderTable\"><center>00:01-23:59</center></td class=\"borderTable\">"; echo "<td class=\"borderTable\"><center>".$row['TotalNumberOfCalls']."</center></td class=\"borderTable\">"; $seconds = get_seconds($time); echo "<td class=\"borderTable\"><center>".date("H:i:s", mktime(0, 0, $seconds))."</center></td class=\"borderTable\"></table><p></p>"; } // end while } // end if } // end if ?> There was an error in my previous code so may want to copy and paste this in. Ray
  25. since you are grouping the results, you are not going to get what you want out of this the way it is. Let me ask you this. Do you want the total time by date or by extension?? also do you want it to look something like this Date: 07/23/2008 Ext: 111 time: 1:20'23 calls: 22 Ext: 123 time: 2:20'21 calls: 45 Total: 3:40'44 Ray
×
×
  • 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.