dreamwest
Members-
Posts
1,223 -
Joined
-
Last visited
Never
Everything posted by dreamwest
-
Simplest join possible $result = mysql_query("SELECT * FROM term_taxonomy AS a, terms as b WHERE a.term_id=b.term_id");
-
Write to database instead of file. Ive tried experiments on speed with ifelse and functions - ifelse wins so you cant do much there. If your using this to display content use flush(); to output the outlay as fast as possible
-
You could have spaces in you keyword column _ppi Try: SELECT * FROM `keywords` WHERE `keyword` LIKE 'ppi'
-
Another way to do it to query the database and write the whole thing to a file /*************** config ***************/ $mysql_host=''; $mysql_database='' database name $mysql_username=''; // user name $mysql_password=''; // password $storing_dir = ""; // directory path with an ending slash /******************* end config ************/ $file_name = $mysql_database."_".date('YmdHis').".sql"; $link = mysql_connect($mysql_host, $mysql_username, $mysql_password); if (!$link) { fwrite($fh, 'Could not connect: ' . mysql_error()); exit(); } $db_selected = mysql_select_db($mysql_database, $link); if (!$db_selected) { fwrite($fh, 'Can\'t use $mysql_database : ' . mysql_error()); exit(); } $myFile = $storing_dir . $file_name; $fh = fopen($myFile, 'w') or die("can't open file"); _mysqldump($mysql_database); fclose($fh); function _mysqldump($mysql_database) { global $fh; _mysqldump_schema_structure($mysql_database); $sql="show tables;"; $result= mysql_query($sql); if( $result) { while( $row= mysql_fetch_row($result)) { _mysqldump_table_structure($row[0]); _mysqldump_table_data($row[0]); } } else { $content = "/* no tables in $mysql_database */\n"; fwrite($fh, $content); } mysql_free_result($result); } function _mysqldump_schema_structure($schema) { global $fh; fwrite($fh, "/* database : `$schema` */\n"); $sql="show create schema `$schema`; "; $result=mysql_query($sql); if( $result) { if($row= mysql_fetch_assoc($result)) { fwrite($fh, $row['Create Database'].";\n\n"); } } fwrite($fh, "USE `$schema`; \n\n"); mysql_free_result($result); } function _mysqldump_table_structure($table) { global $fh; fwrite($fh, "/* Table structure for table `$table` */\n"); fwrite($fh, "DROP TABLE IF EXISTS `$table`;\n\n"); $sql="show create table `$table`; "; $result=mysql_query($sql); if( $result) { if($row= mysql_fetch_assoc($result)) { fwrite($fh, $row['Create Table'].";\n\n"); } } mysql_free_result($result); } function _mysqldump_table_data($table) { global $fh; $sql="select * from `$table`;"; $result=mysql_query($sql); if( $result) { $num_rows= mysql_num_rows($result); $num_fields= mysql_num_fields($result); if( $num_rows > 0) { fwrite($fh, "/* dumping data for table `$table` */\n"); $field_type=array(); $i=0; while( $i < $num_fields) { $meta= mysql_fetch_field($result, $i); array_push($field_type, $meta->type); $i++; } //print_r( $field_type); fwrite($fh, "insert into `$table` values\n"); $index=0; while( $row= mysql_fetch_row($result)) { fwrite($fh, "("); for( $i=0; $i < $num_fields; $i++) { if( is_null( $row[$i])) fwrite($fh, "null"); else { switch( $field_type[$i]) { case 'int': fwrite($fh, $row[$i]); break; case 'string': case 'blob' : default: fwrite($fh, "'".mysql_real_escape_string($row[$i])."'"); } } if( $i < $num_fields-1) fwrite($fh, ","); } fwrite($fh, ")"); if( $index < $num_rows-1) fwrite($fh, ","); else fwrite($fh, ";"); fwrite($fh, "\n"); $index++; } } } mysql_free_result($result); fwrite($fh, "\n"); }
-
how do divide search results to multiple pages
dreamwest replied to kartul's topic in PHP Coding Help
You need to $_GET the page and use startfrom in your query http://site.com/index.php?q=searching&page=3 This is an example //get the total for the search here $total = //query here $tpage = ceil( $total / 30 ); $startfrom = ( $page - 1 ) * 30; $sql = "SELECT * FROM table where something ='query' LIMIT {$startfrom}, 30"; $result = mysql_query( $sql ); //now page stuff $content_count = mysql_num_rows( $result ); $start_num = $startfrom + 1; $end_num = $startfrom + $content_count; $prev = $page - 1; $next = $page + 1; $adjust = 9; if ( 1 < $page ) { $page_links .= "<a class=pagination_prev href='".$prev."'><< Prev</a><a class=pagination_next href='1'>1</a>...."; } $k = $page - $adjust; for ( $page ; $k <= $page + $adjust; ++$k ) { if (( 0 < $k ) && ( $k <= $tpage ) ) { if(($page)==($k)){ $page_links.="<span class=\"pagination_active\"> ".$k." </span>"; } else { $page_links .= "<a class=pagination href='".$k."'>{$k}</a>"; } } } if ( $page < $tpage ) { $page_links .= ".....<a class=pagination_next href='".$tpage."'>".$tpage."</a><a class=pagination_next href='".$next."'>Next >></a>"; } -
Really!? What about this... RewriteRule ^([^/\.]+)/(.*)/(.*) index.php?section=$2&action=$3&root=$1 [L,QSA] I win
-
how do divide search results to multiple pages
dreamwest replied to kartul's topic in PHP Coding Help
Your over complicating it. You just need the total and page reference And dont forget ceil Example: $page = 1; $tpage = ceil( $total_pics / 30 ); $startfrom = ( $page - 1 ) * 30; $start_num = $startfrom + 1; $end_num = $startfrom + $total_pics; $prev = $page - 1; $next = $page + 1; $adjust = 9; if ( 1 < $page ) { $page_links_pics .= "<a class=pagination_prev href='/hdpics/".$prev."'><< Prev</a><a class=pagination_next href='/hdpics/1'>1</a>...."; } $k = $page - $adjust; for ( $page ; $k <= $page + $adjust; ++$k ) { if (( 0 < $k ) && ( $k <= $tpage ) ) { if(($page)==($k)){ $page_links_pics.="<span class=\"pagination_active\"> ".$k." </span>"; } else { $page_links_pics .= "<a class=pagination href='/hdpics/".$k."'>{$k}</a>"; } } } if ( $page < $tpage ) { $page_links_pics .= ".....<a class=pagination_next href='/hdpics/".$tpage."'>".$tpage."</a><a class=pagination_next href='/hdpics/".$next."'>Next >></a>"; } -
RewriteRule ^index/login/members index.php?section=members&action=login [L,QSA]
-
STR Replace Used To Delete Everything Between 2 Tags
dreamwest replied to Brandon_R's topic in PHP Coding Help
$stuff = '<!-- open tag --> <a href="http://www.phpfreaks.com>PHP Freaks</a> <!-- / open tag -->'; $no_stuff = explode( "<a href="http://www.phpfreaks.com>PHP Freaks</a>", $stuff); echo $no_stuff[0] . $no_stuff[2]; -
All hail Bing!
-
function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); }
-
in this case yes ... in all cases ... maybe not. that is why people are trying to give him a solution that works in ALL cases just explode the href=" part to get the url Now say after me $message = 'Regex is the best ! All hail explode'; $value=explode("!", $message); $value = trim($value[1]); echo $value;
-
Apparently its the same thing: href="http://www.mysite.com/?d=9FDS32S" target="_blank">http://www.mysite.com/?d=9FDS32S</a>
-
<a href="something.php">DOWNLOAD</a> will become DOWNLOAD See my second post
-
Of course it does....and this assumes this is a link $message = '<a rel="nofollow" href="http://www.mysite.com/?d=9FDS32S" target="_blank">http://www.mysite.com/?d=9FDS32S</a>'; $value=explode("</a>", $message); $value=explode(">", $value[0]); $value = trim($value[1]); echo $value;
-
$message = '<a rel="nofollow" href="http://www.mysite.com/?d=9FDS32S" target="_blank">http://www.mysite.com/?d=9FDS32S</a>'; $value=explode('target="_blank">', $message); $value=explode("</a>", $value[1]); $value = trim($value[0]); echo $value;
-
[SOLVED] Subdomain > Directory Problem
dreamwest replied to therealwesfoster's topic in Apache HTTP Server
Make css and images ...everything thats included, a full url http://site.com/style.css -
I have a really long document, but only need a single word/s within two specific tags words here..... <link>only get this line</link> lots of words here..... How can i just get what is within the <link> tags??
-
# permanently redirect from www domain to non-www domain RewriteEngine on Options +FollowSymLinks RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ [NC] RewriteRule ^(.*)$ http://domain.tld/$1 [R=301,L] OR # redirect from old domain to new domain RewriteEngine On RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L] OR # redirect an entire site via permanent redirect Redirect permanent / http://www.domain.com/
-
I deliberately left this out so you can test the dynamic rule Now you just need the default ive changed it so it wont conflict with any other rule. #default for all sections -> http://site.com/type=news or http://site.com/type=forum RewriteRule ^type=(.*) index.php?type=$1 [L,QSA]