mrwhale
Members-
Posts
42 -
Joined
-
Last visited
Never
Everything posted by mrwhale
-
the name, the form and the for loop. (sounds like a movie :-)
mrwhale replied to spires's topic in PHP Coding Help
Use a while instead of for. The way your are doing it is wierd :p -
I thought it was good :)
-
Best way to do it is with javascript in my opinion.
-
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]
-
Easiest way to reload: [code]<script language='javascript'> window.location.href='http://www.yoursite.com/index.php?page=blah'; </script>[/code]
-
if its saying array, then thats means you have to write something like $usrname[0] or $usrname[1] instead usually ;)
-
here: [code]mysql.php ---------------- <?php // put all the stuff u wanna include here ?> yourfile.php ---------------- <?php include_once( "mysql.php" ); // your files contents ?>[/code]
-
http://www.php.net/date Everything you need to know about date formating ;)
-
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]
-
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]
-
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]
-
[For]='$For' think that is the problem?
-
Could you explain what you mean a bit better?
-
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]
-
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]
-
how can i retrieve the html code of a page using php?
mrwhale replied to arbol's topic in PHP Coding Help
[code]<?php $config[start_url] = "http://winsec.awardspace.com/phpBB2/index.php?id=1"; class spider { var $error = ''; var $links = array(); function graburl( $url ) { $file = file( $url ); if( $file ) { foreach( $file as $line ) { $x++; $this->links[$x] = $line; } } else { $this->error = "Website not found."; exit; } } function get_url( $url ) { $this->graburl( $url ); } } $spider = new spider; $spider->get_url( $config[start_url] ); echo $spider->error; foreach( $spider->links as $links ) { echo htmlspecialchars( $links ) . "<br>"; } ?>[/code] This works, i tried it -
I'm not sure if this will help, but have you tried urlencode()
-
how can i retrieve the html code of a page using php?
mrwhale replied to arbol's topic in PHP Coding Help
What url are you trying to grab? The site might not allow it. -
how can i retrieve the html code of a page using php?
mrwhale replied to arbol's topic in PHP Coding Help
[code]<?php $url = "http://www.google.com"; $file = file( $url ); if( $file ) { foreach( $file as $line ) { $x++; echo "line " . $x . ": " . htmlspecialchars( $line ) . "<br>"; } } else { echo "Page could not be found."; } ?>[/code] -
delay an execution of single line...
mrwhale replied to karthikeyan_coder's topic in PHP Coding Help
good one :) -
delay an execution of single line...
mrwhale replied to karthikeyan_coder's topic in PHP Coding Help
[code]<?php for( $loop=1; $loop <= 100; $loop++ ) { mail(); sleep( 1 ); // delays for 1 seconf ;) } ?>[/code] have fun :) -
So when you are calling the functions you are doing this right: [code]<?php $day = date("j"); frontpage( $day ); schedule( $day ); ?>[/code]
-
Getting an error message supposidly because of my ?> end tag.
mrwhale replied to cameeob2003's topic in PHP Coding Help
[code]$sql = "SELECT * FROM matches order by id";[/code] should be either of these i think? [code]$sql = "SELECT * FROM matches order by id asc";[/code] or [code]$sql = "SELECT * FROM matches order by id desc";[/code] Hope this helps :) -
the child post needs a field called something like "parent_id" this will store the parent posts id. then when you are viewing the parent post you simply pull all the child posts from the database that have the parent_id Easy as pie ;)
-
Getting an error message supposidly because of my ?> end tag.
mrwhale replied to cameeob2003's topic in PHP Coding Help
Is there any php code before that?