Jump to content

mrwhale

Members
  • Posts

    42
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.mrwhale.com

Profile Information

  • Gender
    Male

mrwhale's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Use a while instead of for. The way your are doing it is wierd :p
  2. Best way to do it is with javascript in my opinion.
  3. This should work: [code]<?php $query = mysql_query( "select * from table" ); while( $row = mysql_fetch_array( $query ) ) { if( $row[work] == 1 ? $work = 15 : $work = 10 ); $new = ( ( 100 / $row[maxprogress] ) * $work ) + $row[progress]; if( $new > $row[maxprogress] ? $new = $row[maxprogress] : $new = $new ); mysql_query( "update table set progress = '$new' where id = '$row[id]'" ); } ?>[/code]
  4. Easiest way to reload: [code]<script language='javascript'> window.location.href='http://www.yoursite.com/index.php?page=blah'; </script>[/code]
  5. if its saying array, then thats means you have to write something like $usrname[0] or $usrname[1] instead usually ;)
  6. here: [code]mysql.php ---------------- <?php // put all the stuff u wanna include here ?> yourfile.php ---------------- <?php include_once( "mysql.php" ); // your files contents ?>[/code]
  7. http://www.php.net/date Everything you need to know about date formating ;)
  8. This is something basic to give you an idea, it requires a correct password to be able to edit a username. :) [code]<?php mysql_connect( "localhost", "username", "password" ); mysql_select_db( "database" ); if( $_POST['edit'] ) { $password = $_POST['password']; $check_password = mysql_fetch_array( mysql_query( "select * from admin where password = '$password'" ) ); if( $check_password ) { $username = $_POST['username']; mysql_query( "update users set username = '$username'" ); echo "Username was updated sucessfully."; } else { echo "Your password was incorrect."; } } ?> <form method='post'> Admin pass (needed to edit) <input type='password' name='password'><br><br><br> <b>EDIT:</b><br> Username: <input type='text' name='username'><br> <input type='submit' name='edit' value='EDIT'> </form>[/code]
  9. file_exists only works within your own site and cannot include http://blah.com so use this instead [code]<?php print '<br />'; print '<center>'; $thesrc = $_GET['src']; if( parse_url( $thesrc ) ) { print '<font face="Tahoma" size="2">Valid image source</font>'; print '<br /><br />'; print '<img src="' .$thesrc. '" />'; } else { print '<br />'; print '<center>'; print '<font face="Tahoma" size="2">Invalid image source</font>'; } print '</center>'; ?>[/code]
  10. This should work: [code]<?php switch( $field ) { case "0": $WHERE = "WHERE Name LIKE '%$search%' and OBS LIKE '%$search%' and Dept LIKE '%$search%'"; break; case "1": $WHERE = "WHERE Name LIKE '%$search%'"; break; case "2": $WHERE = "WHERE OBS LIKE '%$search%'"; break; case "3": $WHERE = "WHERE Dept LIKE '%$search%'"; break; } $query = "select * from DB1 " . $WHERE; $result = mysql_db_query( "DB", $query ); ?>[/code]
  11. Could you explain what you mean a bit better?
  12. This should work. [code]<?php mysql_connect( "localhost", "usernameHIDDEN", "passwordHIDDEN" ); mysql_select_db( "tableHIDDEN" ); $query = mysql_query( "SELECT * FROM items ORDER BY name" ); echo "<table>"; while( $row = mysql_fetch_array( $query ) ) {       $x++;       if( $x == 1 ) echo "<tr>";       echo "<td>" . $row['name'] . "</td>";       if( $x == 3 )       {             echo "</tr>";             $x = 0;       } } echo "<table>"; ?>[/code]
  13. I made this for you. :) Just edit the settings, this code grabs the html and echos it, you have the option of echoing the tags or not aswell ;) Have fun! In this example it gets all the bold html tags on the page and echos them on a seperate line :) then it removes the tags, leaving just the infor in between the tags here it is in action: http://www.business-tycoon.com/example.php [code]<?php $config['url']       = "http://www.business-tycoon.com"; // url of html to grab $config['start_tag'] = "<b>"; // where you want to start grabbing $config['end_tag']   = "</b>"; // where you want to stop grabbing $config['show_tags'] = 0; // do you want the tags to be shown when you show the html? 1 = yes, 0 = no class grabber { var $error = ''; var $html  = ''; function grabhtml( $url, $start, $end ) { $file = file_get_contents( $url ); if( $file ) { if( preg_match_all( "#$start(.*?)$end#s", $file, $match ) ) { $this->html = $match; } else { $this->error = "Tags cannot be found."; } } else { $this->error = "Site cannot be found!"; } } function strip( $html, $show, $start, $end ) { if( !$show ) { $html = str_replace( $start, "", $html ); $html = str_replace( $end, "", $html ); return $html; } else { return $html; } } } $grab = new grabber; $grab->grabhtml( $config['url'], $config['start_tag'], $config['end_tag'] ); echo $grab->error; foreach( $grab->html[0] as $html ) { echo htmlspecialchars( $grab->strip( $html, $config['show_tags'], $config['start_tag'], $config['end_tag'] ) ) . "<br>"; } ?>[/code]
×
×
  • 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.