Jump to content

Displaying PHP results


dfwcomputer

Recommended Posts

hi,

i have a php page that is know working exactly the way i want it (thanks to thorpe...see link below).......but would like some help on formatting the result output......Does anyone know of a good tutorial on this...

[url=http://www.phpfreaks.com/forums/index.php?topic=119590.0]http://www.phpfreaks.com/forums/index.php?topic=119590.0[/url]


Thanks
Link to comment
https://forums.phpfreaks.com/topic/31647-displaying-php-results/
Share on other sites

i would just like to change the output....i.e. what it looks like....also i added else else echo "<p>is not a cheater.</p>"; at the bottom so if nothing was found it displayed that...but it didn't work....

[code]
<?php
  function ischeater($search,$type) {
    switch ($type) {
      case 'GUID':
        $pos = 2;
        break;
      case 'UserName':
        $pos = 3;
        break;
      case 'IP Address':
        $pos = 4;
        break;
case 'MAC':
        $pos = 5;
        break;
    }
    $files = array('aci.txt','aon.txt','aasa.txt');
foreach ($files as $file) {
  $lines = file($file);
  foreach ($lines as $line) {
    $line = str_replace('"','',$line);
    $tmp = explode(' ',$line);
    if ($tmp[$pos] == $search) {
      return $line;
    }
  }
}
    return false;
}
  if (isset($_POST['Submit'])) {
  if ($line = ischeater($_POST['textfield'],$_POST['select'])) {
 
    echo $_POST['textfield']." is a cheater.<br /><h2>See Details Below</h2><br /> ";
    echo $line;
else echo "<p>is not a cheater.</p>";
  }
}
?>
[/code]

thanks
[code=php:0]
if (isset($_POST['Submit'])) {
  if ($line = ischeater($_POST['textfield'],$_POST['select'])) { 
    echo $_POST['textfield']." is a cheater.<br /><h2>See Details Below</h2><br /> ";
    echo $line;
  } else {
    echo "<p>is not a cheater.</p>";
  }
}
[/code]
thanks i'll do that.....can you double check what i have...but it seems right....

[code]
<?php
  function ischeater($search,$type) {
    switch ($type) {
      case 'GUID':
        $pos = 2;
        break;
      case 'UserName':
        $pos = 3;
        break;
      case 'IP Address':
        $pos = 4;
        break;
case 'MAC':
        $pos = 5;
        break;
    }
    $files = array('aci.txt','aon.txt','aasa.txt');
foreach ($files as $file) {
  $lines = file($file);
  foreach ($lines as $line) {
    $line = str_replace('"','',$line);
    $tmp = explode(' ',$line);
    if ($tmp[$pos] == $search) {
      return $line;
    }
  }
}
    return false;
}
  if (isset($_POST['Submit'])) {
  if ($line = ischeater($_POST['textfield'],$_POST['select'])) { 
    echo $_POST['textfield']." is a cheater.<br /><h2>See Details Below</h2><br /> ";
    echo $line;
  } else {
    echo "is not a cheater.";
  }
}
?>


[/code]
You need to keep proper indentation to make it easy to read / maintain.

[code]
<?php
  function ischeater($search,$type) {
    switch ($type) {
      case 'GUID':
        $pos = 2;
        break;
      case 'UserName':
        $pos = 3;
        break;
      case 'IP Address':
        $pos = 4;
        break;
      case 'MAC':
        $pos = 5;
        break;
    }
    $files = array('aci.txt','aon.txt','aasa.txt');
    foreach ($files as $file) {
      $lines = file($file);
      foreach ($lines as $line) {
        $line = str_replace('"','',$line);
        $tmp = explode(' ',$line);
        if ($tmp[$pos] == $search) {
          return $line;
        }
      }
    }
    return false;
  }
 
  if (isset($_POST['Submit'])) {
    if ($line = ischeater($_POST['textfield'],$_POST['select'])) { 
      echo $_POST['textfield']." is a cheater.<br /><h2>See Details Below</h2><br /> ";
      echo $line;
    } else {
      echo "is not a cheater.";
    }
  }
?>
[/code]

but yeah... I dont see any errors.
ok....great site by the way....but i want to learn to incorporate it into php....I'm quite good with html/xhtml but putting them together seems to be the trouble....

e.g.

[code]<?php
  function ischeater($search,$type) {
    switch ($type) {
      case 'GUID':
        $pos = 2;
        break;
      case 'User Name':
        $pos = 3;
        break;
      case 'IP Address':
        $pos = 4;
        break;
case 'MAC':
        $pos = 4;
        break;
    }
    $files = array('aasa.txt','aci.txt','aon.txt');
foreach ($files as $file) {
  $lines = file($file);
  foreach ($lines as $line) {
    $line = str_replace('"','',$line);
    $tmp = explode(' ',$line);
    if ($tmp[$pos] == $search) {
      return $line;
    }
  }
}
    return false;
  }
  if (isset($_POST['Submit'])) {
  if ($line = ischeater($_POST['textfield'],$_POST['select'])) {
    echo $_POST['textfield']." is a cheater.<br /><h2>See Details Below</h2><br /> ";
    echo $line;
  } else {
    echo "is not a cheater.";
  }
}
?>[/code]

you'll notice [code]echo $_POST['textfield']." is a cheater.<br /><h2>See Details Below</h2><br /> ";[/code]

i got that to work and it know outputs like this;

[img]http://farm1.static.flickr.com/138/335765674_2081f801a4_o.jpg[/img]

I would like to add a background colour to the php page and maybe "Results" above

[code]a54f64fe1563456cb67d8fc2aec04607 is a cheater.[/code]

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.