Reputation Activity
-
Blofeld reacted to Jay Gilford in Nested list php while loop problemI take it this is how you want the output to be formatted (with the subnav ul within the <li> of it's parent)
<?php $results = array( array( 'name' => 'home', 'subpage' => 0 ), array( 'name' => 'about', 'subpage' => 0 ), array( 'name' => 'about-sub', 'subpage' => 1 ), array( 'name' => 'about-another-sub', 'subpage' => 1 ), array( 'name' => 'page', 'subpage' => 0 ), array( 'name' => 'page-sub1', 'subpage' => 1 ) ); $pageTree = sortPages($results); $menuHTML = recurseMenu($pageTree); var_dump($menuHTML); function sortPages($array) { $results = array(); foreach($array as $r) { if(!$r['subpage']) { $results[] = array( 'name' => $r['name'], 'subpages' => array() ); } else { $results[(count($results) - 1)]['subpages'][] = array( 'name' => $r['name'], 'subpages' => array() ); } } return $results; } function recurseMenu($array, $level = 0) { $output = '<ul class="level-' . $level . '">'; foreach($array as $item) { $output .= '<li>' . $item['name']; if(!empty($item['subpages'])) { $output .= recurseMenu($item['subpages'], $level + 1); } $output .= '</li>'; } $output .= '</ul>'; return $output; }
-
Blofeld got a reaction from Demonolith in Facebook feed on my siteyou are running the code in between script tags instead of php tags.
get rid of these:
<script></script>
and do this instead...
<?php //code here ?>
-
Blofeld got a reaction from Demonolith in Facebook feed on my siteYou will have to output that URL in an img tag
-
Blofeld got a reaction from Demonolith in Facebook feed on my siteif(isset($json_output['data'][$i]['picture'])){ echo '<br /><img src="'.$json_output['data'][$i]['picture'].'" alt="" />'; }
-
Blofeld got a reaction from Demonolith in Facebook feed on my siteJust lump the whole lot together and put it in your page where you want the feed to appear. Then style it to suit the rest of your page. Don't forget to add your own codes in and app id where stated (in uppercase) otherwise it won't work.
When you are working on it, it may be best to change the cache time to 1 so that you can see your code changes in real time. Then when you are happy with it, set it to cache for as long as you like.
-
Blofeld got a reaction from Demonolith in Facebook feed on my siteI wrote a little tutorial that does exactly what you are looking for. It can be altered easily to include images too.
http://www.deanblog.co.uk/article/13/adding-a-facebook-status-feed-to-your-website-with-php
-
Blofeld got a reaction from timtamboy63 in There's some blank space at the bottom of my footerimg{display:block;} might work
Also, try removing the whitespace between img and footer.
-
Blofeld got a reaction from timtamboy63 in There's some blank space at the bottom of my footerActually, I tell a lie! I reckon it's cos your footer isn't clearing the padding of the floated divs. Try
footer:after{ content:" "; display:block; clear:both; }
-
Blofeld got a reaction from Allstar in Repeated Paypal IPN responsesHave you checked the IPN history in the paypal account (sandbox one in this case)? It sounds like the script is not completing and will continue trying until it can. Anything other than a 200 response will make it retry I think.
-
Blofeld got a reaction from SniderDK in Repeated Paypal IPN responsesHave you checked the IPN history in the paypal account (sandbox one in this case)? It sounds like the script is not completing and will continue trying until it can. Anything other than a 200 response will make it retry I think.
-
Blofeld got a reaction from abeer in data not displaying from databaseThe one with the while() statement I posted should have worked. I didn't look through your DB images to see what table 'dtl' was on. Just assumed you would replace that with the result you were after. So, if you want to return all of the results, you can still use the while() statement and limit them in your sql query using LIMIT
-
Blofeld got a reaction from abeer in data not displaying from databaseThat isn't enough to show anything. You need to fetch the info and echo it the way you want it.
e.g.
<?php mysql_connect("localhost", "dhaka", "dhaka") or die("Connection Failed"); mysql_select_db("dhaka")or die("Connection Failed"); $query = "SELECT * FROM dhaka"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)){ echo $row['dtl'] . "<br />"; }
-
Blofeld reacted to DigitalSquid in Odd problem in chromeTry adding:
overflow: hidden;
To the CSS for #main-container. That should make sure the footer always clears the floated elements in that div.
-
Blofeld got a reaction from stjohn in doing the same thing twice.You seemed to miss of your if else brackets to and also didn't have the ID field in uppercase where it should have been.
You code can be shortened a lot like this:
Index.php <body> <?php // ************* You should put this in a separate file and either require() or include() it e.g. "connectDB.php" $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } // ***************** End **************************** //and possibly this line as well if you only use one db mysql_select_db("gwines_test") or die(mysql_error()); //****** Run this once.... $result = mysql_query("SELECT ID,Name FROM products") or die('Blah ' . mysql_error()); $product_id=0; while($row = mysql_fetch_array($result)) { $product_id=$row['ID']; $navList .= "<li><a href=\"product.php?id=" . $product_id . "\">". $row['Name'] ."</a></li>"; } //*** this next part seems to be unused and can be deleted: $i=0; $num=mysql_num_rows($result); ////// Finding all the information in the table and counting the rows mysql_data_seek($result, 0); //***end of uselessness ***** ?> <div id="wrapper"> <div id="content"> <div id="header"> <div id="menu"> <ul> <li><a href="#">Home</a></li> <li><a href="#">Products</a> <ul> <?php echo $navList; ?> </ul> </li> </div> </div> <div id="main"> <h1>"Wine is a pleasure that transports us from the present to the past" </h1> <ul> <?php //I added the ul tags too!! echo $navList; ?> </ul> </div>
Product.php <body> <?php // get database connect info require("connectDB.php"); if(is_numeric($_GET['id'])) { //since you are calling from the url directly to the sql query, use mysql_real_escape_string() for some security $product_id= mysql_real_escape_string($_GET['id']); } else{ $product_id = -1; } // I also notice in your index page your 'id' field in the DB is uppercase so change it to that. $result = mysql_query("SELECT ID, name, producttype, description, winery, imgloc, thumbloc FROM products WHERE id='" . $product_id . "'") or die('Blah ' . mysql_error()); $product_id=0; while($row = mysql_fetch_array($result)) { $product_id=$row['ID']; $navList .= "<li><a href=\"product.php?id=" . $product_id . "\">". $row['Name'] ."</a></li>"; } ?> <div id="wrapper"> <div id="menu"> <li><a href="#">Products</a> <ul> <?php echo $navList; ?> </ul> </li> </div> <div id="main"> <?php echo "<h4>" . $row['name'] . "</h4><br/>"; ?> <img src="images/line.png" width="613" height="2" /> <?php echo '<img src="' . $row['imgloc'] . '" id="prod_img" /><br/>'; echo "<h5>" . $row['name'] . "</h5>"; echo "<p>Description: " . $row['description'] . "<br/>"; echo "Winery: " . $row['winery'] . "<br/>"; echo "<a href=\"index.php\">[Go Back]</a></p>"; ?> </div>
-
Blofeld got a reaction from notidaho in Can I use 1 database for many clients?Why not store the mysql login/connect info in a file on the server outside of the public root, and have a php script (with the login authorisation included in it of course) which exports the relevant client's data as a .csv - then you can simply provide a link to it from within each client's admin area e.g. "Download Database Backup"
-
Blofeld got a reaction from mrhints in PHP Drop Down MYSQL User Search (Problem)untested but should work
<?php $country = mysql_real_escape_string($_POST['country']); $age = mysql_real_escape_string($_POST['age']); $gender = mysql_real_escape_string($_POST['gender']); $query = mysql_query("SELECT * FROM members WHERE country = '$country' AND age = '$age' AND gender = '$gender' "); //loop through matches and echo results while($row = mysql_fetch_assoc($query)){ $name = $row["name"]; $country = $row["country"]; $age = $row["age"]; $gender = $row["gender"]; echo "$name, $gender, aged $age from $country<br />"; } ?>
-
Blofeld got a reaction from mrhints in PHP Drop Down MYSQL User Search (Problem)$country = mysql_real_escape_string($_POST['country']); $age = mysql_real_escape_string($_POST['age']); $gender = mysql_real_escape_string($_POST['gender']); mysql_query("SELECT * FROM table_name WHERE country = '$country' AND age = '$age' AND gender = '$gender' ");
then a while() loop etc...
-
Blofeld reacted to Steppio in Web Designer/Developer BlogThat sounds like the perfect way to approach a project; too many times i've took on a site that simply MUST have advanced jQuery / SQL triggered Flash events / ranking system for extensive blog / user profiles / all other farts and whistles that in the end take me 4 months to plan and by that point i cant be bothered anymore (the thought of build time alone making me feel quite ill). Building from scratch may take a little longer, but what price can you put on knowing your own code / understanding how your site works?
However much it costs to get somebody else to do it is the answer to that, but if you can do it yourself its always better I wish you the best of luck with your project and i've bookmarked it so i'll keep checking back.
-
Blofeld got a reaction from vambo in Footer text not centeringAdd clear:both; to .footer{}
-
Blofeld got a reaction from pbb76 in Backing up large MYSQL DatabaseNever come across the problem myself, but how about scrapping the cron (or changing it to daily) and writing a script so that the db is backed up after X amount of INSERTs/UPDATEs?
Or take it a step further and only back up the parts that have changed?
-
Blofeld reacted to SniderDK in Backing up large MYSQL DatabaseI use mysql replication for data you really cant lose like e-commerce data, it gives you a almost instant backup.
it is said that data is not saved until its saved in 2 places or more
-
Blofeld got a reaction from DaveJ in Website RedesignI actually thought it looked quite pleasant whilst it was loading and then the black border appeared! Without that, it looks much better in my opinion.
-
Blofeld got a reaction from J90 in portfolio redesign.. again!The fact is though, it doesn't matter how good a site is...if their wife doesn't like it, it's scrapped!
-
Blofeld got a reaction from J90 in portfolio redesign.. again!Like I usually have to try and convince my clients...you don't have to like it, your potential customers do!
-
Blofeld reacted to MikeChipshop in portfolio redesign.. again!Welcome to hell!