PHP - Moved: [theory] Making A Conditioned Blog
This topic has been moved to Application Design.
http://www.phpfreaks.com/forums/index.php?topic=357178.0 Similar TutorialsThis topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=323879.0 Hi am in the middle of making a blog but am having problems with one page am working on if anyone can help me please. What is am looking for is to post username and avatar instead of just the username. I have already paid some guy to work on this but he didnt get back to me and ihave no more cash to give for the code to be finished so i would really appreciate if someone could help to finish this off please thanks. this is the where the username and text shows which i would like avatar to show as well. Code: [Select] <?php $query = yasDB_select("SELECT * FROM user WHERE username = '$user'"); $row = $avatarfile; $query = yasDB_select("SELECT * FROM topic WHERE userid = '$id' ORDER BY id DESC LIMIT 5"); if($query->num_rows == 0) { ?> <div id="memberstext">This topic has no comments, be the first to add one!</div> <?php } else { while($row = $query->fetch_array(MYSQLI_ASSOC)) { $text = $row['comment']; $text = str_replace(':D','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/biggrin.gif" title="biggrin" alt="biggrin" />',$text); $text = str_replace(':?','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/confused.gif" title="confused" alt="confused" />',$text); $text = str_replace('8)','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/cool.gif" title="cool" alt="cool" />',$text); $text = str_replace(':cry:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/cry.gif" title="cry" alt="cry" />',$text); $text = str_replace(':shock:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/eek.gif" title="eek" alt="eek" />',$text); $text = str_replace(':evil:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/evil.gif" title="evil" alt="evil" />',$text); $text = str_replace(':lol:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/lol.gif" title="lol" alt="lol" />',$text); $text = str_replace(':x','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/mad.gif" title="mad" alt="mad" />',$text); $text = str_replace(':P','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/stlyes/images/smileys/razz.gif" title="razz" alt="razz" />',$text); $text = str_replace(':oops:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/redface.gif" title="redface" alt="redface" />',$text); $text = str_replace(':roll:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/rolleyes.gif" title="rolleyes" alt="rolleyes" />',$text); $text = str_replace(':(','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/sad.gif" title="sad" alt="sad" />',$text); $text = str_replace(':)','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/smile.gif" title="smile" alt="smile" />',$text); $text = str_replace(':o','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/surprised.gif" title="surprised" alt="surprised" />',$text); $text = str_replace(':twisted:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/twisted.gif" title="twisted" alt="twisted" />',$text); $text = str_replace(':wink:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/wink.gif" title="wink" alt="wink" />',$text); if ( $row['useavatar'] == '1' ) { $avatarimage = $siteurl . 'avatars/' . $row['avatarfile']; } else { $avatarimage = $siteurl . 'avatars/useruploads/noavatar.gif'; } ?> <div id="box"> <div class="name"><img src="<?php echo $avatarimage;?>" height="40" width="40" align="left"><br /><?php echo $row['name'];?></div> <div class="comment_text"><?php echo $text;?></div></div> This is the form part of it to add the text Code: [Select] <div id="box2"> <form name="addcomment" method="post" action=""> <strong>Message:</strong><br /> <textarea name="comment" rows="3" cols="40" id="comment_message"></textarea><br /> <input name="userid" type="hidden" value="<?php echo $id;?>" /> <input type="hidden" name="timestamp" id="timestamp" value="<?php echo time(); ?>" /> </center> <!-- start of smiles --> <div id="smiles"><center> <a href="javascript:addsmilie(' :D ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/biggrin.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :? ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/confused.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' 8) ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/cool.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :cry: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/cry.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :shock: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/eek.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :evil: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/evil.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :lol: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/lol.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :x ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/mad.gif';?>" border="0" /></a><br /> <a href="javascript:addsmilie(' :P ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/razz.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :oops: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/redface.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :roll: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/rolleyes.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :( ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/sad.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :) ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/smile.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :o ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/surprised.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :twisted: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/twisted.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :wink: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/wink.gif';?>" border="0" /></a> </center></div> <input name="name" type="hidden" value="<?php echo $_SESSION['user'];?>" /><br /> <input name="addcomment" type="submit" value="Add Comment" style="border: 1px solid #000; margin-top: 2px;" /> </form></div> This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=311235.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=347050.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=343263.0 Although this is the PHP coding section i couldn't think of a better place to post this, it has more to do with theory or a way for me to achieve what I want rather than a piece of code which I cant get to work. I have been working on this project, sort of a note taking application. When a new note is added to the database, after the ajax, the page is refreshed and then the new note appears along with the note title in the navigation pane. My problem is when I put the site up on my web server it runs more slowly so when the page is refreshed after the ajax the data is not yet in the database so it needs a second manual refresh for the data to appear. I tried delaying the refresh a tenth of a second and it sort of worked but I ran into problems when actually trying to implement it. But after getting frustrated, I have decided that my refresh workaround isn't very elegant. Is there a technique or method I could use to have certain parts 'refresh' without actually refreshing? I'm sure it is possible and probably quite simple I can think of lots of times when this sort of thing would be needed. Even just making a comment on facebook the whole page isn't refreshed, it just appears. Or rather somehow knows there is new data in the database and updates its self. But this is my first real php project so I'm still learning how everything is done. hey, i need some help if possible. I basicly have 2 tables, one has the blog posts and one has the blog comments. I'm trying to display the latest 5 blog posts (which works) but underneath each of the blog posts i need to display about 3 of the latest comments for that post but it isn't showing any. any ideas? here's my code: Code: [Select] <? session_start(); $myusername = $_SESSION['myusername']; $db_host = 'localhost'; $db_user = 'HIDDEN'; $db_pwd = 'HIDDEN'; $database = 'tjwebsol_dev'; $table = 'posts'; $table2 = 'blog_comments'; $tab = '&#38;#160;&#38;#160;&#38;#160;&#38;#160;&#38;#160;&#38;#160;&#38;#160;&#38;#160;&#38;#160;&#38;#160;&#38;#160;&#38;#160;'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // sending query $result = mysql_query("SELECT * FROM {$table} ORDER BY blog_id DESC LIMIT 5"); if (!$result) { die("Query to show fields from table failed"); } $sql = mysql_query("SELECT * FROM {$table2} ORDER BY comment_id ASC LIMIT 5 "); $fields_num = mysql_num_fields($result); $fields_num2 = mysql_num_fields($sql); while($row2 = mysql_fetch_assoc($sql)) { $blog_comments = $row2['comment_content']; $date_commented = $row2['date_commented']; $time_commented = $row2['time_commented']; $blog_username2 = $row2['username']; $blogid = $row2['blogid']; $comment_id = $row2['comment_id']; } while($row = mysql_fetch_assoc($result)) { $blog_title = $row['title']; $blog_content = $row['content']; $blog_username = $row['username']; $blog_date = $row['date_posted']; $blog_time = $row['time_posted']; $blog_id = $row['blog_id']; echo "<hr>"; echo "<div class='post'>"; echo "<h2 class='title'><a href='#'>$blog_title</h2></a>"; echo "<p class='byline'>posted by <b>$blog_username</b> on <b>$blog_date</b> ($blog_time)</p>"; echo "<br>"; echo "<div class='entry'>$blog_content</div><br>"; if ($blogid == $blog_id) { echo "<b>User Posted Comments:</b><br><br>"; echo "$tab<b>$comment_id</b>. $blog_comments"; echo "<br><br>"; echo "Commented posted by <b>$blog_username2</b> on <b>$date_commented ($time_commented)</b>"; echo "<br><br><br>"; } if (!isset($_SESSION['logged']) || $_SESSION['logged'] !== true) { // not logged in, move to login page echo "<b><a href='login.php'>Login</a></b> to post your comments!"; } echo "<br><br><br>"; include('blognewcomment.php'); echo ""; echo "</div>"; } mysql_free_result($result); ?> I have created a system that uses an API to drop utility data into MSQL Server 2008. Once the data is in the db, a web app can query the data to create electric bills. Currently we are working with only one customer but are entertaining expansion and want to approach the growth from the best possible angle.
Considering that all data is the same type of data but comes from different customers and sources, would it be best to maintain 1 database with all of the utility meter data streaming to it or would it be best to have a new data base with each customer?
Also, assuming we keep it all in the same database, would it be best (assuming we are secure) to have all the individual customers data go to the same tables or have separate tables for separate customers.
I'm pretty certain I know the answer but I'm a novice so that means nothing.
Thank you for any help with this issue.
Edited by Butterbean, 18 November 2014 - 11:28 AM. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=349747.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=358619.0 Hey guys, I have been programming for a while and I want to know what sort of design patterns I should look into when making a game? For example what design pattern is best for: Database management User management Forum management Etc I can only think of singleton or factory (for user/forum) I am reasonably new to OOP, but would like to learn it properly, so I thought creating a simple program such as rock-paper-siccors would work to be able to expand it eventually, and hopefully it will teach me reusable code practice. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=333559.0 I have an audio mix submitting form on my website. The first part of the form takes the details from the user and inserts a new row in the first table 'mix', auto incrementing to generate a mix_id primary key. The second part then uses a series of check boxes to select which genres the mix contains and a foreach for the resulting array to insert, into the 2nd table 'genres_for_mix', a new row for each genre id (foreign key for the genres table) that is selected and the mix_id that it concerns. Now I'm starting to think this is a bad way to do this because: 1. I don't know how to echo this out when a user edit's the mix to make all the relevant checkboxes selected. 2. When a user deselects a choice, it would be quite long winded to delete the nessesary row. So instead I'm thinking that it would be much wiser to user the serialise functions to put the array into the database However, I still don't know how to make the right checkboxes selected when I echo out the edit form. Do I use something like inarray()? If so how? Also, it's really important that I can query the database for mixes that are associated with a specific genre. Without unserialising the array and therefore echo'ing out all the results, I don't know how to query this. Would I just use a 'WHERE genre_field LIKE 'genre_id'? Can anyone help me with this please? Hello, I am fairly new at php (have been using HTML/CSS for a while but recently learned the php basics). I am building a website to allow clients to schedule through multiple massage therapists and I am struggling with the basic beginings of a scheduler scripts. If someone can point me towards a tutorial or script that would be great, or answer any of the following questions: 1. What would be the best way to store each therapists weekly schedule (based on monday-sunday with start and end times) and propagate that info. to every day that a client might schedule on? 2. How do i get the day of the week based on the date? 3. How do i display a calendar that lets them choose the date? This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=317921.0 Hello everyone, I'm in the process of creating a PHP script (will be open-source), I just need to know how to make it easy for people to add plugins? Like I don't really know much about the concept of plugins (how they should work), all I know is that there should be a function to activate / deactivate the plugin, but how can I make it possible for people to run their "code" wherever they want? I've heard about "hooks" but I don't really understand how this should work, anyone can explain please? Thank you very much in advance So I started a blog project just to help me out with learning php. This is my post form <form action="insert.php" method="post"> Title: <input type="text" name="title"> <br> Post: <input type="text" name="post"> <br> Author: <input type="text" name="author"> <br> <input type="submit"> </form> Insert.php <?php $con = mysqli_connect("localhost","test","","test"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // escape variables for security $title = mysqli_real_escape_string($con, $_POST['title']); $content = mysqli_real_escape_string($con, $_POST['post']); $author = mysqli_real_escape_string($con, $_POST['author']); $sql="INSERT INTO article (title, content, author) VALUES ('$title', '$content', '$author')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "1 record added"; mysqli_close($con); ?> But when I try to display that information he <h1>Title: </h1> <?php echo $title; ?> <h2>Content: </h1> <?php echo $content; ?> <h3>Posted by: </h1> <?php echo $author; ?>It doesn't work and I get this: ( ! ) Notice: Undefined variable: title in C:\wamp\www\test\index.php on line 33 Call Stack # Time Memory Function Location 1 0.0000 239144 {main}( ) ..\index.php:0 Content: ( ! ) Notice: Undefined variable: content in C:\wamp\www\test\index.php on line 34 Call Stack # Time Memory Function Location 1 0.0000 239144 {main}( ) ..\index.php:0 Posted by: ( ! ) Notice: Undefined variable: author in C:\wamp\www\test\index.php on line 35 Call Stack # Time Memory Function Location 1 0.0000 239144 {main}( ) ..\index.php:0The form works because when I looked at the database, the information was there. The problem is getting that information and displaying it in the right place, how can i fix that? Just in case, this is my index: <?php include ('connect.php'); include ('header.php'); ?> <div id="container"> <div id="rightcol"> <form action="insert.php" method="post"> Title: <input type="text" name="title"> <br> Post: <input type="text" name="post"> <br> Author: <input type="text" name="author"> <br> <input type="submit"> </form> </div> <div id="content"> <h1>Title: </h1> <?php echo $title; ?> <h2>Content: </h1> <?php echo $content; ?> <h3>Posted by: </h1> <?php echo $author; ?> </div> </div> <?php include "footer.php"; ?> </div> Hey I have this blog http://www.nikita-andrews.com/ingrid/?page_id=34 ... Im trying to remove the prettyphoto enlargement on posts to this page ... and not sure how to go about it. The code for thumbnail.php is Code: [Select] <?php if (has_post_thumbnail()) { $data = get_post_meta( $post->ID, 'key', true ); if ($data[ 'project_link' ]) { ?> <a class="externalLink tooltip" title="View Live Site" target="_blank" href="<?php echo $data[ 'project_link' ]; ?>">∞</a> <?php } ?> <?php $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large'); if ($data[ 'video_link' ]) { ?> <a class="thumbLink video" rel="prettyPhoto" href="<?php echo $data[ 'video_link' ]; ?>"> <?php } else { echo '<a class="thumbLink" href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" >'; } the_post_thumbnail(); echo '</a>'; } ?> I want the thumbnails to still show but just not enlarge. Infact itd be even better if they just linked directly to the post itself. Any help would be much appreciated! I have looked around. And what I came across was not necessarily what I was looking for.
I was wondering if somebody can recommend a good tutorial for building a blog in PHP OOP?
Also, I was wondering if somebody perhaps knows a good blog app written in PHP OOP, where I could be learning from the script files?
Hi guys, Am having trouble with my OO php blog. i can add, delete and search for messages but cannot update them as i get the folowing eror message (see below) Quote Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM messages WHERE id = NULL' at line 1' Have checked that when i hover over the link i do get an id number and it is pointing to the correct cmd i.e. blogAmend. Any ideas as to where i am going wrong, files attatched for further info. |