Jump to content

alexruimy

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

alexruimy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [code=php:0] $search=$_POST["search"]; $result = mysql_query("SELECT * FROM joborder WHERE companyname LIKE '%$search%'"); $num = mysql_num_rows($result); if ($num == "0"){ echo "You needs to be revisin' yo search, fool."; } else { while($r=mysql_fetch_array($result)) {   $companyname=$r["companyname"];   $posdes=$r["positiondescription"];   $firstname=$r["firstname"];   $date=$r["date"];   $email=$r["email"];   $id=$r["orderid"];   $local=$r["nearestlocation"];     echo " $companyname"; } }[/code] [hr] I imagine that may work.
  2. Thanks both for the quick replies. I would've tried to look it up but I wasn't sure of what to call it.
  3. [code=php:0] $search = "dark"; $data = //(do Fread stuff here to get your log file); $pieces = explode("\n",$data); $count = count($pieces); for ($i=0;$i<=$count;$i++){ if (strpos($pieces[$i], $search){ echo "$pieces[$i]<br>/n"; } }[/code] [hr] I haven't tested this, as I'm just writing it in QuickReply, but something along those lines should work.
  4. I have code that looks like this: [hr] [code=php:0]$result  =  move_uploaded_file($temp_name, $file_path);   if (!chmod($file_path,0777))     $message = "change permission to 777 failed.";   else     $message = ($result)?"$file_name uploaded successfully." :               "Something is wrong with uploading a file.";[/code] [hr] Just wondering what the ($result)? part is.  My guess is that it's equivalent to the following: [hr] [code=php:0]if ($result){ $message = "$file_name uploaded successfully."; } else {$message = "Something is wrong with uploading a file."};[/code] [hr] Am I on the right track? Can someone elaborate for me as to what this is?
  5. Gaah, I can't figure this damn thing out. I found this at php.net, but can't figure out how to apply it: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Sometimes, you might want to search values in array, that does not exist. In this case php will display nasty warning: Wrong datatype for second argument in call to in_array() . In this case, add a simple statement before the in_array function: if (sizeof($arr_to_searchin) == 0 || !in_array($value, $arr_to_searchin)) { ... } In this case, the 1st statement will return true, omitting the 2nd one[/quote]
  6. Assuming the exact contents of your log.txt file are [code]username - Dave Smith age - 34[/code] Try this: [code]<? $file = "log.txt"; $size = filesize($file); $fh = fopen ($file, 'r'); $data = fread ($fh, $size); fclose($fh); $lines = explode("\n",$data); $pieces = explode(" - ",$lines[0]); $username = $pieces[1]; echo $username; ?>[/code]
  7. I'm sure there's something wrong here on a basic level that I'm just unaware of. Here're a few lines of code that aren't functioning properly. The error I'm getting is [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: in_array(): Wrong datatype for second argument in...[/quote] The relevant code is: [code]$check = array(        "service" => "Service",        "centrifuge" => "Centrifuge",        "support" => "Support",        "disinfection" => "Disinfection",        "main" => "Main",        "northcontrol" => "North Control"); function echotitle($b){    if (in_array($b, $check)) {       echo " - ". ($check[$b]) . " Building";       } else {       echo "Overview";} }[/code] I'm aware this may not be the most efficient way to make what I'm trying to make happen, but I'm stuck on this now, and really want to make it work. I just learned the "=>" thing in arrays, and I'm trying to put it to use. My guess is that that's where the problem lies. Any thoughts?
  8. Okay, I was playing around with it and I got it. It had to do, I believe, with my including the "stats.php" file. Here's the corrected code, also available at [a href=\"http://artelcommunications.net/test/view2.php\" target=\"_blank\"]http://artelcommunications.net/test/view2.php[/a] [code]<html> <head> <title>NYC DEP Extensions Chart</title> <style> body {background-color:black;} * {font-family: verdana, arial, sans-serif; font-size:12px; color:white;} .hover {font-weight:bold; font-size:14px;} a:hover {background-color:9999ff; color:black;} .heading {font-size:16px; font-weight:bold; text-align:center;} .td1 {background-color:#808080;} .td2 {background-color:#636363;} .hidden {display:none;} </style> <script type="text/javascript"> <!-- function hide( id, id2 ) { document.getElementById(id).style.display = 'block'; document.getElementById(id2).style.display = 'none'; } //--> </script> </head> <body> <table width="80%" align="center" cellspacing="0"> <tr> <td class="heading" colspan="6">NYC DEP Phone Extensions</td> </tr> <tr> <td colspan="6"> <div class="hidden" id="stats"><? include("stats2.php"); ?> <div onclick="hide('show','stats');"><a>(Hide Stats)</div></a></div> <div onclick="hide('stats','show');" id="show"><a>(Show Stats)</a></div></td> </tr> <tr> <td colspan="6" align="center"><br> <a href="export.php?orderby=<? echo $orderby; ?>">Export to Excel</a></td> </tr> <tr> <td class="1"><b><a href="view2.php?orderby=ext">Ext</a></b></td> <td class="1"><b><a href="view2.php?orderby=building">Building</a></b></td> <td class="1"><b><a href="view2.php?orderby=type">Phone</a></a></b></td> <td class="1"><b><a href="view2.php?orderby=room">Room</b></td> <td class="1"><b><a href="view2.php?orderby=floor">Floor</a></b></td> <td class="1"><b><a href="view2.php?orderby=elevation">Elevation</a></b></td> </tr> <? if (!$sort){ $sort = "ASC"; } if ($sort == "ASC"){ $sort2 = "DESC"; } if ($sort == "DESC"){ $sort2 = "ASC"; } $username="52542m"; $password="atsfsdfm"; $database="sdfsdfdf"; $heh="asdfsdfict"; mysql_connect($heh,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); if (!$orderby){ $query = "SELECT * FROM extensions ORDER BY `ext` $sort"; $result = mysql_query($query); } if ($orderby){ $orderby= "ext"; $query = "SELECT * FROM extensions ORDER BY `" . $_GET['orderby']. "` $sort"; $result = mysql_query($query); } $num=mysql_num_rows($result); echo "$query"; ?> <? $i=0; $i2 = 1; while ($i < $num) { if ($i2 % 2 == 0 ) { $incl = "class=\"td1\""; } else { $incl = "class=\"td2\""; } $ext=mysql_result($result,$i,"ext"); $building=mysql_result($result,$i,"building"); $type=mysql_result($result,$i,"type"); $room=mysql_result($result,$i,"room"); $floor=mysql_result($result,$i,"floor"); $el=mysql_result($result,$i,"elevation"); echo "<tr> <td $incl>$ext</td> <td $incl>$building</td> <td $incl>$type</td> <td $incl>$room</td> <td $incl>$floor</td> <td $incl>$el</td> </tr> "; $i++; $i2++; } mysql_close(); ?> </table> </body> </html>[/code] Thanks all for your help.
  9. [!--quoteo(post=383845:date=Jun 14 2006, 11:05 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 14 2006, 11:05 AM) [snapback]383845[/snapback][/div][div class=\'quotemain\'][!--quotec--] error trapping example... [code]$result = mysql_query($query) or die("error: ". mysql_error(). " with query ". $query); // that helps[/code] OK, I see that the echo'd query changes properly and that the displayed data never changes regardless of what 'order' I wanted. That looks as though the data are being displayed without regard to the echo'd query - which makes me wonder if there's another query (without any sort instruction) being used to actually retrieve the data for display. I'm not sure you've posted the relevant part of your code - all the way from the query to actually displaying the tabular data. If you have, aplogies; if you haven't can we see? [/quote] If I didn't post the relevant part, I'm gonna feel like an idiot :-P. Anyway, here's the entire page: [code]<? if (!$sort){ $sort = "ASC"; } if ($sort == "ASC"){ $sort2 = "DESC"; } if ($sort == "DESC"){ $sort2 = "ASC"; } $username="sdf"; $password="sdfdfsd"; $database="sdfsdf"; $heh="sdfsdf"; mysql_connect($heh,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); if (!$orderby){ $query = "SELECT * FROM extensions ORDER BY `ext` $sort"; $result = mysql_query($query); } if ($orderby){ $orderby= "ext"; $query = "SELECT * FROM extensions ORDER BY `" . $_GET['orderby']. "` $sort"; $result = mysql_query($query); } $num=mysql_num_rows($result); echo "$query"; ?> <html> <head> <title>NYC DEP Extensions Chart</title> <style> body {background-color:black;} * {font-family: verdana, arial, sans-serif; font-size:12px; color:white;} .hover {font-weight:bold; font-size:14px;} a:hover {background-color:9999ff; color:black;} .heading {font-size:16px; font-weight:bold; text-align:center;} .td1 {background-color:#808080;} .td2 {background-color:#636363;} .hidden {display:none;} </style> <script type="text/javascript"> <!-- function hide( id, id2 ) { document.getElementById(id).style.display = 'block'; document.getElementById(id2).style.display = 'none'; } //--> </script> </head> <body> <table width="80%" align="center" cellspacing="0"> <tr> <td class="heading" colspan="6">NYC DEP Phone Extensions</td> </tr> <tr> <td colspan="6"> <div class="hidden" id="stats"><? include("stats.php"); ?> <div onclick="hide('show','stats');"><a>(Hide Stats)</div></a></div> <div onclick="hide('stats','show');" id="show"><a>(Show Stats)</a></div></td> </tr> <tr> <td colspan="6" align="center"><br> <a href="export.php?orderby=<? echo $orderby; ?>">Export to Excel</a></td> </tr> <tr> <td class="1"><b><a href="view.php?orderby=ext">Ext</a></b></td> <td class="1"><b><a href="view.php?orderby=building">Building</a></b></td> <td class="1"><b><a href="view.php?orderby=type">Phone</a></a></b></td> <td class="1"><b><a href="view.php?orderby=room">Room</b></td> <td class="1"><b><a href="view.php?orderby=floor">Floor</a></b></td> <td class="1"><b><a href="view.php?orderby=elevation">Elevation</a></b></td> </tr> <? $i=0; $i2 = 1; while ($i < $num) { if ($i2 % 2 == 0 ) { $incl = "class=\"td1\""; } else { $incl = "class=\"td2\""; } $ext=mysql_result($result,$i,"ext"); $building=mysql_result($result,$i,"building"); $type=mysql_result($result,$i,"type"); $room=mysql_result($result,$i,"room"); $floor=mysql_result($result,$i,"floor"); $el=mysql_result($result,$i,"elevation"); echo "<tr> <td $incl>$ext</td> <td $incl>$building</td> <td $incl>$type</td> <td $incl>$room</td> <td $incl>$floor</td> <td $incl>$el</td> </tr> "; $i++; $i2++; } mysql_close(); ?> </table> </body> </html>[/code]
  10. Right, I am echoing the query on the page. [a href=\"http://artelcommunications.net/test/view.php\" target=\"_blank\"]http://artelcommunications.net/test/view.php[/a] What's SQL Error Trapping? Thanks again.
  11. The URL. I haven't cleaned that page up yet. I suppose it is prone to errors..
  12. Done. And did nothing. :( I appreciate everyone's help on this. I wish this stupid junk was easier.
  13. Okay, if you go back to the page, I set the sqlquery to call the $query variable : [code]if (!$orderby){ $query = "SELECT * FROM extensions ORDER BY 'ext' $sort"; $result = mysql_query($query); echo "!, $query"; } if ($orderby){ $orderby= "ext"; $query = "SELECT * FROM extensions ORDER BY '" . $_GET['orderby']. "' $sort"; $result = mysql_query($query); echo "$query"; }[/code]
  14. [!--quoteo(post=383797:date=Jun 14 2006, 10:11 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 14 2006, 10:11 AM) [snapback]383797[/snapback][/div][div class=\'quotemain\'][!--quotec--] As a debugging aid, echo the query ahead of the table display. At least then you will know for certain just what query is being run - and it may not be the query that you expect. [/quote] Good idea. I had done that initially, and it looked right, but now $query no longer exists, because I'm using $result = mysql_query("SELECT * FROM extensions ORDER BY '" . $_GET['orderby'] . "' $sort"); in lieu of it.
×
×
  • 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.