PHP - Blog Post And Database
Hello,
I made myself a simple blog system, but in my case "simple" becomes difficult when it comes to writing an article. Have you ever seen that movie about how facebook was created (I think it's called "Social network" or something like that)? As a newbie web developer I noticed how "Mark" was writting his blog post. I think it was an textarea, and when he was writing article, he wrote it with html tags, like <p>. So, I have now the same problem: when I'm writing article, I have to write it with all div's and p's and a's and img's and so on. I want to avoid that. Few ideas did pop to my head: use preg_replace for some elements, and set up some javascript WYSIWYG editor (but i really don't want it, and can't explain why, I just don't like it). I have a couple of css classes for images, both of them resizes images, one resizes it a lot, other not so much, both make them smaller. One class is for image to be on the left, so the text would wap that image from the right. After paragraph I must clear floats with css class. Other image class just takes full width available and if image is bigger that that available width - it resizes image. So no need to clear floats. How can I make my life easier when I'm writing article to my blog? Similar Tutorialshey, 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); ?> Hi, I am trying to get a facebook like button displayed under each of my blog post, but so far I am just getting three like buttons displayed above the blog post instead of below each one. Below is the function code to display my blog post and also where I cam currently placing the FB like button code. <?php include 'blogpost.php'; $connection = mysql_connect('localhost', 'username', 'pw') or die ("<p class='error'>Sorry, we were unable to connect to the database server.</p>"); $database = "DBName"; mysql_select_db($database, $connection) or die ("<p class='error'>Sorry, we were unable to connect to the database.</p>"); function GetBlogPosts($inId=null, $inTagId =null) { if (!empty($inId)) { $query = mysql_query("SELECT * FROM blog_posts WHERE id = " . $inId . " ORDER BY id DESC LIMIT 2"); } else if (!empty($inTagId)) { $query = mysql_query("SELECT blog_posts.* FROM blog_post_tags LEFT JOIN (blog_posts) ON (blog_post_tags.postID = blog_posts.id) WHERE blog_post_tags.tagID =" . $tagID . " ORDER BY blog_posts.id DESC"); } else { $query = mysql_query("SELECT * FROM blog_posts ORDER BY id DESC"); } $postArray = array(); while ($row = mysql_fetch_assoc($query)) { $myPost = new BlogPost($row["id"], $row['title'], $row['post'], $row['postfull'], $row["author_id"], $row['date_posted']); array_push($postArray, $myPost); echo '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like show_faces="true" width="450"></fb:like>';//this is where I am currently implementing the FB Like button } return $postArray; } ?> Hello! I am a 17 year old beginner Php student and I am currently creating a page for which I would like to create a blog management admin interface. I went very well, I can already add the categories to the database, through the admin interface or I can list them on the website. However, there would be a problem with creating a Blog post. Because I use the same create () function as for adding a category, but unfortunately the Blog Post does not add to the database. I don't get any php error code just when I try to list the post id after the create function. Instead of a value of 1, I get a 0. I enclose the code of the blog post and its control, as well as the data of my database!
Blog Posting form admin html and php code (ujblogposzt.php) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?php require_once('templates/head.php') ?> <!-- includes database and user controll -->
<?php include('app/controllers/posztok.php');?> <!-- Add new blog post controll file -->
<!-- Main content -->
<div class="card-footer">
</div>
<!-- bs-custom-file-input --> <?php require_once('templates/footer.php') ?>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Blogpost controll code (posztok.php)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?php
if (isset($_POST['add-post'])) {
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- I see everything okay in these codes, because I add the category to the database in the same way when adding a category my function called dd is at the end of the line of code, it's just for checking, it shows results. my create() function seen like this:
function create($table, $data)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The strange thing is that if I add 1-2 items to the database statically without php code, it is detected and displayed in the blog editing menu, but I can't add a post to the database via the admin interface itself, that's why I wrote here ! :) From testing, I also print the end result of the create function at the end of the control code, which should return an id, but instead of id 1 I get a value of 0 and the post doesn't added to the database after pressing the post button['add-post'] and unfortunately I can't figure out why it is ?! I also attach the pictures of the problem!
The pictures of my problem can be viewed he https://drive.google.com/drive/folders/1WTVNv4LlbJiosWvBZoIRzjiUDkvhMgYk?usp=sharing
Thanks to anyone in advance !!!
Hello everyone. I'm new here and to php mvc. Been trying to hone my skills with mvc, mysql, classes and functions. But I am stuck. Can display all blog posts from DB but not a single post. The Readmore link only leads to post 1 (or the next published post from the db). Please I need your help. My code is below. Thanx in advance. BlogsModel.php (PDO db): public static function getBlog($blogsID) { try { $db = static::getDB(); $stmt = $db->query('SELECT * FROM blogs WHERE blogsStatus=1 AND blogsID=blogsID '); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result; } catch (PDOException $e) { echo $e->getMessage(); } } Blogs.php (Controller): public function blogAction() { $blog = BlogsModel::getBlog($blogsID = 'blogsID'); $user = BlogsModel::getBlog($blogsUserID = 'blogsUserID'); $data = [ 'blog' => $blog, 'user' => $user ]; View::renderTemplate("Services/Blogs/blog.php", $data); } index.php (front controller): $router->add('blogs/{id:[\w-]+}', ['controller' => 'Services\Blogs', 'action' => 'show']); ReadMore link: <a id="readMore" href="/blogs/{{ blog.blogsAlias }}" >ReadMore</a>
I have a problem about Blog Post Categorization Script. Can anyone review it ? Instead of showing how much posts that category have it just repeats. Code: [Select] <? $sqlCategories = "SELECT * FROM blog_entry, categories where blog_entry.CategoryID=categories.CategoryID and blog_entry.UserID=".$_REQUEST['UserID']." order by Category asc"; $resultCategories = mysql_query($sqlCategories, $conn); if (@mysql_num_rows($resultCategories)!=0){ $strcategory=""; while($row_categories = @mysql_fetch_array($resultCategories)) { $categoryduplicate=0; $arrcat = explode(",",$strcategory); for($i=0;$i<strlen($arrcat);$i++) { if($arrcat[$i]==$row_categories['CategoryID']) { $categoryduplicate=1; } } if($categoryduplicate==0) { if($strcategory=="") { $strcategory=$row_categories['CategoryID']; } else { $strcategory=$strcategory.",".$row_categories['CategoryID']; } $sqlCategories2 = "SELECT * FROM blog_entry where CategoryID=".$row_categories['CategoryID']." and UserID=".$_REQUEST['UserID']; $resultCategories2 = mysql_query($sqlCategories2, $conn); if($row_categories['CategoryID'] == $_REQUEST['CategoryID']) { echo " <Tr> <td class='content'><a href='postss.php?CategoryID=".$row_categories['CategoryID']."&UserID=".$_REQUEST['UserID']."&Category=".$row_categories['Category']."' class='in_sel'>".$row_categories['Category']."</a> [".@mysql_num_rows($resultCategories2)."]</td> </Tr> "; } else { echo " <Tr> <td class='content'><a href='posts.php?CategoryID=".$row_categories['CategoryID']."&UserID=".$_REQUEST['UserID']."&Category=".$row_categories['Category']."' class='in_sel'>".$row_categories['Category']."</a> [".@mysql_num_rows($resultCategories2)."]</td> </Tr> "; } } } } ?> Hi, I have a blog page I am working on and I am trying to make some enhancements that I need some help with. In MySQL I have a table with id, title and post. In my page display I want to enable the user to click on the title and display a post on it's own so the URL would look like www.mysite.com/blog/?id=1 or something like that. Here is the PHP function to display the post from MySQL. all on one page. function GetBlogPosts($inId=null, $inTagId =null) { if (!empty($inId)) { $query = mysql_query("SELECT * FROM blog_posts WHERE id = " . $inId . " ORDER BY id DESC LIMIT 2"); } else if (!empty($inTagId)) { $query = mysql_query("SELECT blog_posts.* FROM blog_post_tags LEFT JOIN (blog_posts) ON (blog_post_tags.postID = blog_posts.id) WHERE blog_post_tags.tagID =" . $tagID . " ORDER BY blog_posts.id DESC"); } else { $query = mysql_query("SELECT * FROM blog_posts ORDER BY id DESC"); } $postArray = array(); while ($row = mysql_fetch_assoc($query)) { $myPost = new BlogPost($row["id"], $row['title'], $row['post'], $row['postfull'], $row["author_id"], $row['date_posted']); array_push($postArray, $myPost); } return $postArray; } I had a wordpress site setup for my maintenance company. I am not trying to setup a blog on the site. I have the blogroll showing up on this page: http://handymore.com/blog/ but when you click the individual articles the single post page shows a Error 404 message. Could anyone point me in the right direction as to how to fix this so that the individual post pages are found? Any guidance would be appreciated. Hi all - I'm setting up a custom PHP blog. It pulls the data from a MySQL database which includes HTML tags (<p><div><span> etc...). I would like to display only up to 50 words per post on the blog page, which users can then read and click a link to then see the entire post. I've developed some code which does this, however, it seems to be stripping my HTML tags... Very sad! Would be very very grateful if one (or more) of you kind lot would have a look at my code and let me know if there is a easier (I'm all for easy) and proper way of implementing this so that it works without stripping my HTML tags. Cheers!!! Code: [Select] // Counts number of blog words in the content $blog_content_words = str_word_count($blog["content"], 1); // Sets the blog_words variable to 0 $blog_words = 0; // Prints title on page as a permalink to a post echo '<h1><a href="blog.php?id='.$blog["id"].'">'.$blog["title"].'</a></h1><p>'; // Loops while blog_word is under 50 while($blog_words < 50) { // Prints a word from blog_content_words array of blog post and adds a space afterwards echo $blog_content_words["$blog_words"]." "; // Adds 1 to the blog_words counter ++$blog_words; } // Adds a read more link to the post which links to full blog post echo '... <a href="blog.php?id='.$blog["id"].'">[read more]</a></p>'; Hello. I'm new to pHp and I would like to know how to get my $date_posted to read as March 12, 2012, instead of 2012-12-03. Here is the code: Code: [Select] <?php $sql = " SELECT id, title, date_posted, summary FROM blog_posts ORDER BY date_posted ASC LIMIT 10 "; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $id = $row['id']; $title = $row['title']; $date_posted = $row['date_posted']; $summary = $row['summary']; echo "<h3>$title</h3>\n"; echo "<p>$date_posted</p>\n"; echo "<p>$summary</p>\n"; echo "<p><a href=\"post.php?id=$id\" title=\"Read More\">Read More...</a></p>\n"; } ?> I have tried the date() function but it always updates with the current time & date so I'm a little confused on how I get this to work. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=323879.0 I know this should be easy... I have several text input boxes where I enter data to be sent to one column of my database. Code: [Select] [while($row = mysql_fetch_array( $result )) { $i=1; if ($row['game_id']='$i') { echo "<tr>"; echo "<td>"; echo $row['date']; echo "</td><td>"; echo $row['team_name']; echo "</td><td>"; echo $row['owner']; echo "</td><td>"; echo "<input type='text' size='4' name='result[]'>"; echo "</td></tr>"; Not every box has a value so my array will end up with several numbers and several "blanks". I echoed the array using Code: [Select] $result = ("$_POST[result]"); and all the values are returned as expected. Now I need to UPDATE the "pt_spread" column in the database inserting all the values (even the blank values). I tried the following but can't get it to actually post anything into the database. Code: [Select] <?php header("Location: admin_main_entry.php"); include("opendatabase.php"); $result = ("$_POST[result]"); foreach ($result as $spread) { $sql = " UPDATE schedule SET pt_spread = '$spread' WHERE week_id = '$weekID'" ; mysql_query($sql); } mysql_close($con) ?>Can anyone show me the correct way to do this? Thanks. Hi guys, Was wondering if you could help. Apart from using a form are the other ways to POST to a mysql database? e.g. using clicking a link or so. Code: [Select] <?php $con = mysql_connect("localhost", "root", ""); $name = $_GET['jente_navn']; $name = mysql_real_escape_string($name); $ip = $_SERVER['REMOTE_ADDR']; mysql_select_db("name", $con); if ( preg_match("/^[^a-z]|[^A-Z]+/i", $name) ) { die ("Feil: Kan bare bruke gyldige tegn"); }else{ $sql = 'SELECT * FROM banned WHERE name= \'' . $name . '\' OR ip= \'' . $ip . '\''; $result = mysql_query($sql); if( mysql_num_rows($result) ){ print "That Name, or your ip adress is. BANNED!"; } } $sql = "INSERT INTO girl ('girl','accepted','ip') VALUES ('$name', '0', '$ip');"; if ( mysql_query($sql, $con) ){ mysql_close($con); header('http://localhost/takk.php'); }else{ mysql_close($con); header('http://localhost/error.php'); } ?> I don't get any errors, but it still doesn't post the name in the database, even though the name doesn't exist or ain't banned. :s Ok .I tried to look for the problem for about 1 hour but I can't see what's wrong whit the following code: In firebug the post values appear correctly like so:id=116&usern=asdawe&com=qweqw&page=116&submit=submit and the inserc() function works correctly because i tried it whit a array of data created by my; Code: [Select] <?php if(isset($_POST['submit'])) { $comment = new comment; $comment->storeform($_POST); $comment->insertc(); } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="hidden" name="id" value="<?php echo $result['article']->id ?>"/> <ul> <li> <input type="text" name="usern" id="usern" /> </li> <li> <textarea name="com" id="com" COLS=40 ROWS=6></textarea> </li> <input type="hidden" name="page" value="<?php echo $result['article']->id ?>" /> <input type="submit" name="submit" value="submit" /> </ul> </form> Code: [Select] <?php class comment{ public $id = null; public $usern = null; public $com = null; public $page = null; public function __construct($data=array() ) { if( isset($data['id']) ) $this->id= (int)$data['id']; if( isset($data['usern']) ) $this->usern= preg_replace ( "/[^\.\,\-\_\'\"\@\?\!\:\$ a-zA-Z0-9()]/", "", $data['usern'] ); if( isset($data['com']) ) $this->com= preg_replace ( "/[^\.\,\-\_\'\"\@\?\!\:\$ a-zA-Z0-9()]/", "", $data['com'] ); if( isset($data['page']) ) $this->page= (int)$data['page']; } public function storeform ( $params ) { // Store all the parameters $this->__construct( $params ); } public function insertc() { $con = new PDO(DBN,DB_USER,DB_PASS); $sql = "INSERT INTO comments (usern,com,page) VALUES (:usern,:com,:page)"; $st =$con->prepare($sql); $st->bindValue( ":usern", $this->usern, PDO::PARAM_STR ); $st->bindValue( ":com", $this->com, PDO::PARAM_STR ); $st->bindValue( ":page", $this->page, PDO::PARAM_INT ); $st->execute(); $this->id = $con->lastInsertId(); $con = null; } } ?> Hello, I wrote a script where i can enter a stock symbol and it get saved in my database. This works, but when i enter the stock symbol i would like to also get the current stock price get saved into the database. The link for the stock price (i.e. AAPL): http://quote.yahoo.com/d/quotes.csv?s=AAPL&f=l1&e=.csv How do i programm this in the script below? Besides above, notice that "AAPL" in the link above has to be a varaible, which changes where i for example type in "GS". Form: Quote <html> <body> <form action="portfolio/insert_buy.php" method="post"> Symbol: <input type="text" name="symbol"><br /> <input type="submit" value=" Submit"> </form> </body> </html> PHP-script Quote <?php $conn = mysql_connect("xxx","xxx","xxx"); $db = mysql_select_db("xxx",$conn); $sql="INSERT INTO portfolio (symbol) VALUES ('$_POST[symbol]')"; if (!mysql_query($sql,$conn)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($conn); ?> I hope someone can help me out, thanks! Iv tried asking a lot of people and have had no luck resolving this issue, so I will try here. I have created a Form which gathers its information from a Database. The first form is a Dropdown Option, which when submitted takes you to another page. The new page is Supposed to use the value from the Dropdown to search the database and return the proper rows to populate a few text areas to edit the values. This is where I am stuck. Compared to what most of you create this is probably sloppy and not too well structured, but I am new to this. Anyways, I will provide more information below now. The following is the initial page with the first form. This is where you would select what page you wish to edit. (I believe this may be where the issue resides) - (I included the 'num' value before the 'name' value so that I could see it is getting the value from the database, which it is) <form method="post" action="pageedit.php"><br /> <?php include "config.php"; echo "<select name=\"page\">\n"; $conn = mysql_connect("localhost", "$username", "$password"); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("$database")) { echo "Unable to select $database: " . mysql_error(); exit; } $sql = "SELECT * FROM sitePages"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } while ($row = mysql_fetch_assoc($result)) { echo "<option value='"; echo $row['num']; echo "'>"; echo $row['num']; echo " - "; echo $row['name']; echo "</option>"; } echo "</select>"; ?> <br /> <input type="submit" /> </form> And then the following is the page that the form is sent to when submitted: (I have attempted to Echo the 'num' value sent so that I could verify that it is indeed sent, but it is not. I will post the message I receive after the PHP snippet <form method="post" action="pageeditinsert.php"><br /> <?php include "config.php"; echo $_POST['num']; $num=$_POST['num']; $conn = mysql_connect("localhost", "$username", "$password"); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("$database")) { echo "Unable to select $database: " . mysql_error(); exit; } $sql = "SELECT * FROM sitepages WHERE num = '$num'"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } while ($row = mysql_fetch_assoc($result)) { echo "<input name'num' type='hidden' class='form1' value='"; echo $num; echo "' maxlength='10' id='cat' /><br /><br /><br />"; echo "<input name='name' type='text' class='form1' value='"; echo $row['name']; echo "' maxlength='20' id='name' /><br /><br />"; echo "<input name='desc' type='text' class='form1' value='"; echo $row['desc']; echo "' maxlength='100' id='desc' /><br /><br /><br />"; echo "<input name='title' type='text' class='form1' value='"; echo $row['title']; echo "' maxlength='100' id='title' /><br /><br /><br />"; echo "<input name'cat' type='hidden' class='form1' value='cat' maxlength='3' id='cat' /><br /><br /><br />"; } ?> <br /><br /><br /> <center><input type="submit" /><input type="reset" /></center> </form> Below is the message I receive when attempting to echo the POSTed 'num' value: Quote Notice: Undefined index: num in C:\wamp\www\gondieCOM\editor\edit\pageedit.php on line 16 Call Stack # Time Memory Function Location 1 0.0025 687600 {main}( ) ..\pageedit.php:0 (I am running the latest WAMP release on my personal PC for testing purposes until I have finished this and upload it to my hosting server) Anyways thanks for your time. Hopefully someone has an idea for me. Hi, i'm currently building essentially an API for my URL shortener site so other sites can implement it. But i've hit a stumbling block on the last script of the lot(the others merely collate the data and store it) In this last script, i need to find all this data, stored in cookies and inout it into the database, as the main site does(i'm confident this bit works, as it's the code from the main site just copied across, and i can see the data in the database). Importantly, i then need o look in another table for the callback URL to send the data back to $urltoshorten = $_COOKIE["URLtoShorten"]; $alias = $_COOKIE["urlalias"]; $key = $_COOKIE["key"]; //connection details go in here $alias =mysql_real_escape_string($alias); $urltoshorten = mysql_real_escape_string($urltoshorten); $base = "http://s-url.co.uk/i/?id="; $url = $base . $alias ; //this is the main bit, where the URL shortening occurs mysql_query("INSERT INTO table (id, name) VALUES('$alias', '$urltoshorten')")or die( mysql_error()); //this is where the callback url is looked for $result= mysql_query("SELECT apiaddress FROM apistuff WHERE apinumber='$key'")or die( mysql_error()); $row = mysql_fetch_array($result); $new = $row[apiaddress]; //I then start a CURL session to POST data to the page in question, as found above $Curl_Session = curl_init($new); curl_setopt ($Curl_Session, CURLOPT_POST, 1); curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "shortenedurl=$url"); curl_exec ($Curl_Session); curl_close ($Curl_Session); annoyingly, no errors get thrown, as far as i can see, i just end at a blank page without being returned to the callback page. I'm rather stumped on this one, where am i likely to be going wrong/how do i go about correcting it. Cheers Joe Hi,
Webapp noob here.
I have an application that is going to be data-heavy, so I would like to avoid saving things to the database whenever possible. The application in a nutshell is an android application wired up to a php web app(with MySQL) where you can send requests to the phone and the phone will respond with text or image data with POST.
The normal way to do this would be for the phone to post the data to the database, then have the webapp display it. However, what im wondering is if it is possible for a user on the webapp to request information from the phone, and then when the phone replies using a POST to display the information temporarily in maybe a popup window instead of having to save it to the database.
Thanks!
Hi all, Thanks for reading. I'm hella frustrated at this script I wrote: for some reason, it will not work correctly. Basically, it works. The first 4 names in the table on the database show up when searched. But, anything past these four names in the database will not show up as a result when searched! I'm pulling my hair out here! It's really simple - take a gander: Code: [Select] if (isset($_POST['submit'])) { $search = $_POST['search']; $searchQuery = mysql_query("SELECT * FROM Accounts WHERE FullName='$search'"); if (mysql_num_rows($searchQuery) == 0) { $result = "Your search returned no results. Please try again."; } else { $results = 1; while ($getSearchResults = mysql_fetch_array($searchQuery)) { $fullName = $getSearchResults['FullName']; $result = "Name: ".$fullName.""; } } } ?> ...and the HTML form... Code: [Select] <form action="search.php" method="post"> <p>Search: <input type="text" name="search" size="35" maxlength="100" /></p> <p><input type="submit" value="Search" name="submit" /></p> <?php echo $result; ?> </form> Does anyone have any ideas? |