PHP - Display Remote Mysql Data On Different Websites
I have created 5 websites under 5 different domains. Contents of this websites' are similar and using a same template for each one. Now I need to create an admin panel to control these websites. PHP and MySql I will use for this backend.
My problem is how can I manage these five website with one backend? Reason is I will use different domain for my backend. My all 5 client will use this same backend system to manage their own website.
So can I know from the professionals here, is it possible to display mysql data on these 5 website. If it is possible then how?
Any links to article or tutorials would be welcome and appreciated.
NOTE: I checked
mysql federated storage enginebut no idea? Is it the way where do I need to go? Thank you. Similar TutorialsI'm not sure what I'm doing wrong here... This is my index <html <head> <title>Admin applications</title> </head> <body text="#000000"> <center> <?php include("connect.php"); echo "<table cellpadding='3' cellspacing='2' summary='' border='3'>"; echo "<tr><td>Real name:<br><br>"; echo $row['real_name']; echo "</td><td>Age:<br><br>"; echo $row['age']; echo "</td><td>In-Game Name:<br><br>"; echo $row['game_name']; echo "</td><td>Steam ID:<br><br>"; echo $row['steamid']; echo "</td><td>Agreement:<br><br>"; echo $row['agreement']; echo "</td><td>Will use vent:<br><br>"; echo $row['vent']; echo "</td><td>Activity:<br><br>"; echo $row['activity']; echo "</td><td>Why this person wants to be an admin:<br><br>"; echo $row['why']; echo "</td></tr></table>"; ?> </center> </body> </html> and this is my database connect <?php $database="admin"; mysql_connect ("localhost", "root", "waygan914"); @mysql_select_db($database) or die( "Unable to select database"); mysql_query("SELECT * FROM applications"); ?> The database table "applications" has 8 fields, and 2 records, but when I view the page i get the table but no data: I am managing a shop website which is using php and mysql for data. The website has a section that will display the related products with the one that you are watching. Now my problem is that if there are more than 5 items it will continue to display all the items in one row with the consequent that the page will not display well. I need to find a way to begin a new row after the 5th item so it will display 5 items in each row. this is my current code that is responsible for showing the related items. There is also a picture attached with the problem. while ($row = mysql_fetch_array($retd)) { $code = $row["code"]; $name = $row["name"]; echo("<td width=150 align=center>"); echo ("<a href=../products/info.php?scode=$code><img src=pictures/$code.gif border=0 alt=Item $name</a>"); echo ("<br><a href=../products/info.php?scode=$code><span class=fs13>$name</span></a>"); echo("</td>"); } Does anyone know how can I do this? Morning all, and Evening everyone else. Im using the following Query to display information from a table Code: [Select] <? include "config.php"; $query1="Select *,DATE_FORMAT(date_posted,'%W,%d %b %Y') as thedate FROM article WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) ORDER BY date_posted DESC LIMIT 1 "; $blogarticles = mysql_query($query1) or die(mysql_error()); $num = mysql_num_rows($blogarticles); ?> What I am wanting to find out, is as the blog post itself could be pages long at times, is the anyway that further down the page where I actually call the data up onto the page itself I can limit how much of it is displayed? Ive succesfully added a limit to how many records are shown with the "DES LIMIT 1", is there something I can add to my query, or further down in my displaying table (which I will code just below here) to limit the lines/characters on display until the full article is opened? Display table: Code: [Select] <table width="75%" border="0" cellspacing="1" align="left"> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <? if($num > 0){ while($row_articles = mysql_fetch_assoc($blogarticles)){ ?> <tr class="title"> <td><?=$row_articles['title'];?> </td> </tr> <tr> <td> </td> </tr> <tr class="tbody"> <td><?=$row_articles['comments'];?></td> </tr> <tr> <td> </td> </tr> <tr class="links"> <td>Date posted: <?=$row_articles['date_posted'];?> | <a href="comments.php?aid=<?=$row_articles['artid'];?>&cid=<?=$row_articles['categoryID'];?>">Comments(<? //echo $row_articles['artid']; //$thenum=row_articles['artid']; $getcomments = "SELECT * FROM article WHERE artchild='".$row_articles['artid']."'"; if(!$theResult=mysql_query($getcomments)){ echo mysql_error(); }else{ $num_comments=mysql_num_rows($theResult); echo $num_comments; } ?>) </a></td> </tr> <tr class="links"> <td> </td> </tr> <tr class="links"> <td> </td> </tr> <? } }else{ ?> <tr><td><p>There are no articles available at present</p></td></tr> <? } ?> <tr> </tr> </table> Just to clarify 'comments' is the table field that holds the blog data, it also holds comments on the blog, but the child ID is what differentiates them from one another. Thanks in advance for your help ladies & gents Tom Hi guys I need your help. I would like the data from the column "user_login" being seen as an email link. How can I do that? Thousand Thanks Code: [Select] while($rows=mysql_fetch_array($result)){ ?> <tr> <td><span class="style10"><? echo $rows['user_id']; ?></span></td> <td><span class="style10"><? echo $rows['user_first_name']; ?></span></td> <td><span class="style10"><? echo $rows['user_surname']; ?></span></td> <td><span class="style10"><? echo $rows['user_login']; ?></span></td> <td align="center"><a href="update.php?id=<? echo $rows['user_id']; ?>" class="style10">update</a></td> </tr> <?php } im making a game and i need to show a users money but i dont know how help? Hi all, I am trying to get data from MySQL to display in a html table in TCPDF but it is only displaying the ID. $accom = '<h3>Accommodation:</h3> <table cellpadding="1" cellspacing="1" border="1" style="text-align:center;"> <tr> <th><strong>Organisation</strong></th> <th><strong>Contact</strong></th> <th><strong>Phone</strong></th> </tr> <tbody> <tr>'. $id = $_GET['id']; $location = $row['location']; $sql = "SELECT * FROM tours WHERE id = $id"; $result = $con->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { '<td>'.$location.'</td> <td>David</td> <td>0412345678</td> </tbody>'; } } '</tr> </table>'; Anyone got any ideas? I have got connection to the the mysql database, how do I get the data from the database to display on the webpage Hey in my edit page i have 2 radio buttons in my form and i need to make sure the same value is still selected how can i do that? thanks i have a mysql table which contains name like mid mname 101 AAA 102 BBB 103 CCC now i have to print this name in a html table like AAA, BBB, CCC i am getting this by while loop in a variable but when loop changes then value also change so please tell me how i get this only in one variable & print I had this working, but when I try and get fancy and use AJAX the data doesn't display. I think this is a PHP problem though. My code for the select form including AJAX code Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB"> <head> <title>AJAX Example</title> <link rel="stylesheet" type="text/css" href="Form.css" media="screen" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("tr:odd").addClass("odd"); }); </script> <script type="text/javascript"> function showPlayers(str) { var xmlhttp; if (str=="") { document.getElementById("DataDisplay").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); else {// code for IE6, IE5 } xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("DataDisplay").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","Query.php?category_id="+str,true); xmlhttp.send(); } </script> </head> <body> <h1">AJAX Example</h1> <?php #connect to MySQL $conn = @mysql_connect( "localhost","username","pw") or die( "You did not successfully connect to the DB!" ); #select the specified database $rs = @mysql_SELECT_DB ("MyDB", $conn ) or die ( "Error connecting to the database test!"); ?> <form name="sports" id="sports"> <legend>Select a Sport</legend> <select name="category_id" onChange="showPlayers(this.value)"> <option value="">Select a Sport:</option> <?php $sql = "SELECT category_id, sport FROM sports ". "ORDER BY sport"; $rs = mysql_query($sql); while($row = mysql_fetch_array($rs)) { echo "<option value=\"".$row['category_id']."\">".$row['sport']."</option>\n "; } ?> </select> </form> <br /> <div id="DataDisplay"></div> </body> </html> Query.php <?php #get the id $id=$_GET["category_id"]; #connect to MySQL $conn = @mysql_connect( "localhost","username","pw") or die( "Error connecting to MySQL" ); #select the specified database $rs = @mysql_SELECT_DB ("MyDB", $conn ) or die ( "Could not select that particular Database"); #$id="category_id"; #create the query $sql ="SELECT * FROM sports INNER JOIN players ON sports.category_id = players.category_id WHERE players.category_id = '".$id."'"; echo $sql; #execute the query $rs = mysql_query($sql,$conn); #start the table code echo "<table><tr><th>Category ID</th><th>Sport</th><th>First Name</th><th>Last Name</th></tr>"; #write the data while( $row = mysql_fetch_array( $rs) ) { echo ("<tr><td>"); echo ($row["category_id"] ); echo ("</td>"); echo ("<td>"); echo ($row["sport"]); echo ("</td>"); echo ("<td>"); echo ($row["first_name"]); echo ("</td>"); echo ("<td>"); echo ($row["last_name"]); echo ("</td></tr>"); } echo "</tr></table>"; mysql_close($conn); ?> I think the problem is either with this part in the AJAX Code: [Select] xmlhttp.open("GET","Query.php?category_id="+str,true); or most likely in my Query.php code when I wasn't using AJAX and using POST it worked fine, but adding the AJAX stuff and GET it doesn't work. When I echo out the SQL the result is Code: [Select] SELECT * FROM sports INNER JOIN players ON sports.category_id = players.category_id WHERE players.category_id = '' so the category_id is not being selected properly and that is the primary key/foreign key in the MySQL table which connects the JOIN. I have 2 websites currentweb.com copyweb.com (say) Using php can I update 2 databases and upload files in both these 2 websites ( for both these web sites I have user id and password exmaple I am uploading a file (Image), in currentweb.com can I upload it to copyweb.com at the same ( I have database and ftp password for this ) If Yes Please help with code is it possible to collect data from another website and insert it into my db?, lets say for example: http://www.imdb.com/title/tt0285331/episodes#season-1 could i somehow get the Episode name eg: Quote Episode 1: 12:00 a.m.-1:00 a.m. and the description Quote Jack Bauer is called to his office because there's a threat on the life of a US Senator who's running for President; Jack also discovers that his daughter has skipped out her bedroom window. and place that into a table in my db? any help would be great. hello dear php-freaks
well this is just a question that came up to my mind today:
can we put amazon-customer reviews on private websites just ran across this statement: aybe. I wrote the original answer below earlier. I don't have time to look into this right now because I'm no longer on a project concerned with Amazon reviews, but their webpage at Product Advertising API states "The Product Advertising API helps you advertise Amazon products using product search and look up capability, product information and features such as Customer Reviews..." as of 2011-12-08. So I hope someone looks into it and posts back here; feel free to edit this answer. derived he https://stackoverflo...9451851#9451851 so what is the case: just let us know ? Well there are some plugins out there that do that: eg. for wordpress we can use ScrapeAZon. I guess that it does exactly what many many are loooking for. cf https://wordpress.or...on/screenshots/ On a shortnote: probably it is not allowed in some states - in others it probalby will be allowed. What do you say.. Hello!
I have five websites on a single server, and each website uses the same geographic data, for instance US zip codes and city/state latitudes and longitudes. Each website uses it's own copy of these "large" tables.
I would like to avoid having to maintain the same data in 5 databases, but I am more concerned with database performance, e.g., the speed at which the data is retrieved for each website.
Question: Should I set up a new separate database that contains the shared tables for all websites and allow each website to connect to this new database for shared data? Or is it better for each website have it's own copy of the duplicate tables?
Thanks for any info!
Cheers
i have 8 division (div), i want to display 4 rows in 4 division and the remain 4 rows in the next 4 division here is my code structure for carousel
<div class="nyie-outer"> second row third row
fourth row fifth row sixth row seven throw eighth row
</div><!--/.second four rows here-->
sql code
CREATE TABLE product( php code
<?php how can i echo that result in those rows
Hi, I am planning to display remote images with the following code but it seems to return errors. <?php $image_dir = 'http://www.domain.com/images/' ; $dir_handle = opendir( $image_dir ); $count = 0 ; $display = '' ; while( $filename = readdir($dir_handle)){ if( preg_match( '/$[a-z0-9]{4}_th\.jpg$/' , $filename ) ){ $display .= " <img src='$image_dir$filename' /> " ; $count++ ; if( $count % 10 == 0 ){ $count=0; $display .= "<br />"; } } } closedir( $dir_handle ); echo $display ; ?> I am thinking might be the $image_dir cannot use address format.... Errors is as follow Quote Warning: opendir(http://www.foo.com/images/) [function.opendir]: failed to open dir: not implemented in /home/jch02140/public_html/test.php on line 3 Warning: readdir(): supplied argument is not a valid Directory resource in /home/jch02140/public_html/test.php on line 6 Warning: closedir(): supplied argument is not a valid Directory resource in /home/jch02140/public_html/test.php on line 16 Hello, this script originally works by reading a physical copy of 'bans.txt' located in the same directory. How could I get it to read the remote bans.txt located here and parse info from it like the on-site copy? the remote file: http://108.163.211.219/bans.txt Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Data Tables and Cascading Style Sheets Gallery</title> <style>/* Tema: Soft Table - A Simple table style with the use of the soft brown color Author: Newton de G?es Horta Site: -- Country Origin: Brazil */ table { font-size:0.9em; font-family: Arial, Helvetica, verdana sans-serif; background-color:#fff; border-collapse: collapse; width: 100%; } caption { font-size: 25px; color: #1ba6b2; font-weight: bold; text-align: left; background: url(http://www.nghorta.com/csstg/header_bg.jpg) no-repeat top left; padding: 10px; margin-bottom: 2px; } thead th { border-right: 1px solid #fff; color:#fff; text-align:center; padding:2px; text-transform:uppercase; height:25px; background-color: #a3c159; font-weight: normal; } tfoot { color:#1ba6b2; padding:2px; text-transform:uppercase; font-size:1.2em; font-weigth: bold; margin-top:6px; border-top: 6px solid #e9f7f6; } tbody tr { background-color:#fff; border-bottom: 1px solid #f0f0f0; } tbody td { color:#414141; padding:5px; text-align:left; } tbody th { text-align:left; padding:2px; } tbody td a, tbody th a { color:#6C8C37; text-decoration:none; font-weight:normal; display:block; background: transparent url(http://www.nghorta.com/csstg/links_yellow.gif) no-repeat 0% 50%; padding-left:15px; } tbody td a:hover, tbody th a:hover { color:#009193; text-decoration:none; } /* tr:nth-child(even) { background-color: grey; } */ </style></head> <body> <table summary="Submitted table designs"> <thead><tr> <th style="font-size:12px" scope="col"><center>Nickname</center></th> <th style="font-size:12px" scope="col"><center>Admin</center></th> <th style="font-size:12px" scope="col"><center>Banned</center></th> <th style="font-size:12px" scope="col"><center>Reason</center></th> <th style="font-size:12px" scope="col"><center>SteamID</center></th> <th style="font-size:12px" scope="col"><center>Length</center></th> <th style="font-size:12px" scope="col"><center>Status</center></th> </tr></thead> <tbody> <!-- <tr><th scope="row" id="r100"><a href="100.php">rows table template</a></th> <td><a href="http://www.adobati.it">Omar '0m4r' Adobati</a></td><td>Italy</td> <td>Simple, clean and a quite classic table template :)</td> <td><a href="http://www.adobati.it/labs/CSSTable/0m4r.table.css" title="Download the rows table template CSS file">Download</a></td> <td>test</td> <td>test2</td> </tr> --> <?php // Credits to justin as he was able to understand my messy PHP code and do this much better code for me. function buildBanList($arr) { $filename = "bans.txt"; $bans = array(); $tmp_array = array(); // Build Ban Array if (file_exists($filename)) { foreach( $arr as $line ) { if( substr(trim($line), 0, 7) == '"STEAM_' ) { $tmp_array["user_steamid"] = str_replace('"', '', trim($line)); } if( substr(trim($line), 0, 6) == '"time"' ) { $tmp = explode(' ', trim($line)); $tmp_array["user_bantime"] = str_replace('"', '', $tmp[1]); } if( substr(trim($line), 0, 15) == '"modified_time"' ) { $tmp = explode(' ', trim($line)); $tmp_array["user_modified"] = str_replace('"', '', $tmp[1]); } if( substr(trim($line), 0, 7) == '"unban"' ) { $tmp = explode(' ', trim($line)); $tmp_array["user_unban"] = str_replace('"', '', $tmp[1]); } if( substr(trim($line), 0, 7) == '"admin"' ) { $tmp = explode('" "', trim($line)); $tmp2 = explode('(', $tmp[1]); $tmp_array["admin_name"] = str_replace('"', '', $tmp2[0]); } if( substr(trim($line), 0, 6) == '"name"' ) { $tmp = explode('" "', trim($line)); $tmp_array["user_name"] = str_replace('"', '', $tmp[1]); } if( substr(trim($line), 0, 8) == '"reason"' ) { $tmp = explode('" "', trim($line)); $tmp_array["user_reason"] = str_replace('"', '', $tmp[1]); } // Save ban record to main array once detected end. if( substr(trim($line), 0, 1) == '}' ) { // If console ban then set required fields. if( $tmp_array["admin_name"] == "") $tmp_array["admin_name"] = "Console"; array_push($bans, $tmp_array); $tmp_array = array(); } } } //Sort Array by Ban Date $tmp = array(); foreach($bans as &$ma) $tmp[] = &$ma["user_bantime"]; array_multisort($tmp, SORT_DESC, $bans); return $bans; } //Begin Presentation $file = file("./bans.txt"); date_default_timezone_set("Europe/London"); $bans = buildBanList($file); foreach ($bans as $ban) { echo '<tr> '; // Output if ($ban["user_name"] != '') echo '<td style="text-align:center; font-size: 12px">'.$ban["user_name"].'</td><td style="text-align:center; font-size: 12px" class="admin">'; else echo '<td style="text-align:center; font-size: 12px"><span style="color:#FF0000">N/A</span></td><td style="text-align:center; font-size: 12px" class="admin">'; echo $ban["admin_name"].'</td><td style="text-align:center; font-size: 12px">'.date('H:i - d/m/y',$ban["user_bantime"]).'</td>'; /* Unban date. if ($ban["user_unban"] != "0") { echo date('H:i - d/m/y',$ban["user_unban"]); } else { echo "Never"; }*/ echo '<td style="text-align:left; font-size: 11px">'.$ban["user_reason"].'</td>'; // Status $today = strtotime("now"); echo '</td><td style="text-align:center; font-size: 12px">'.$ban["user_steamid"].' </td>'; // Ban Length $date1 = date('y-m-d H:i:s',$ban["user_bantime"]); $date2 = date('y-m-d H:i:s',$ban["user_unban"]); $to_time=strtotime($date1); $from_time=strtotime($date2); $ban_length = round(abs($to_time - $from_time) / 60,0); if ($ban["user_unban"] != "0") { // Days if ($ban_length >= 1440) { $ban_length = round(abs($to_time - $from_time) / 24 / 60 / 60,0); // Years couldn't be arsed to think of another way to do it. if ( $ban_length >= 365 ) { $ban_length = round(abs($to_time - $from_time) / 360 / 24 / 60 / 60,0); if ($bans_length > 1) echo "<td style=\"text-align:center; font-size: 12px\">".$ban_length." Years </td>"; else echo "<td style=\"text-align:center; font-size: 12px\">".$ban_length." Year </td>"; } else echo "<td style=\"text-align:center; font-size: 12px\">".$ban_length." Days </td>"; } // Hours else if ($bans_length >= 60) { $ban_length = round(abs($to_time - $from_time) / 60 / 60,0); if ($bans_length > 1) echo "<td style=\"text-align:center; font-size: 12px\">".$ban_length." Hours </td>"; else echo "<td style=\"text-align:center; font-size: 12px\">".$ban_length." Hour </td>"; } else echo "<td style=\"text-align:center; font-size: 12px\">".$ban_length." Minutes </td>"; } else { echo "<td style=\"text-align:center; font-size: 12px\">Permanent</td>"; } if ($ban["user_unban"] == "0") echo '<td style="text-align:center; font-size: 12px"><span style="color:#FF0000">Banned</span></td>'; else if ( $today > $ban["user_unban"] ) echo '<td style="text-align:center; font-size: 12px"><span style="color:#008000">Expired</span></td>'; else echo '<td style="text-align:center; font-size: 12px"><span style="color:#FF0000">Banned</span></td>'; echo '</tr>'; } ?></table> <center><p>Web-based ULX bans by Russy.</p></center> </div> </body> </html> I've tried experimenting w/ stuff like Code: [Select] $filename = "http://108.163.211.219/bans.txt"; $contents = file_get_contents($filename); but it doesn't seem to want to work. Hello, is it possible to retrieve data from remote form, from another domain that I can't control. I want to type in number in my local form text field and then post it to remote form and retrieve data. I know how to retrieve data from local mysql, but don't know how to retrieve it from remote form. Remote form: http://www.otto.de/is-bin/INTERSHOP.enfinity/WFS/Otto-OttoDe-Site/de_DE/-/EUR/PV_DirectOrder-Start?ls=0#lmPromo=la,3,hk,home,fl,Sidebar_Bestellen Working number: 31477682 I want to type in 31477682 on my local text field and retrieve data(price, color, status like "lieferbar") from another domain. http://www.sambob.info/phpfreaks/table.htm the above link is an example of an html table i am trying to pull data out of i need help on starting a code the will pull that first and last name out of that table so in this case i need it to pull out John doe does any one have any idea on how to do this thank you for your help Bob Hi guys I need some help with slow connection to remote mysql database.
I've been after this for a couple of days. I've been reading around but I didn't find any solution which helped me. I have this scenario:
Server A e-commerce running mysql database running Server B e-commerce running remote connection to server A database The two e-commerce are identical. On server A it runs very quick, on server B the connection to mysql database it's about 16 times slower. Some complex queries and mixes queries don't get resolved and let the page go in timeout. I tried a test php script where I connect to mysql and I run a simple query (some classes are required before the query). On server A execution time is 0.107 seconds while on server B it is 1.788 seconds. I tried to have the same test with both firewall (server A and B) turned off but the results is exactly the same. I added in my.cnf of server A skip-name-resolve and restarted mysql but this didn't really change anything I am logging slow queries and none from server B are recorded in the file Running the same query from remote ssh connection from server B to server A's mysql is very fast Connection is set to persistent on server B's e-commerce Both server have centos 6.2 installed with WHM/Cpanel, configurations are basically the same. Do I miss something obvious? |