Retrieve Php Content From Mysql
I am relatively new to php however I am working on a site and appear to be
getting on quite well. Most of my pages are coded in php and work fine
however what I would like to do is be able to retrieve my content from a
mysql database. The set up is as follows:
Database contains several fields, but for this example I will only require
the Page Name and the Content fields. In page name I have the page name
i.e. whatson.php and I then have the entire contents of the page that I
worked on in my editor pasted in to the Content field.
I then create a basic php page that makes a connection to the database and
just searches for the page I want i.e. whatson.php and stores the result in
a variable called result.
I then echo out result but for some reason it just displays the php code and
does not appear to have interpreted it, can anyone help?. Sample code is
below:
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Create A Multi Table Database In MySQL And Write To And Retrieve Information Using MySQL.
I am trying to create a multi table database in MySQL and write to and retrieve information using MySQL. I am able to insert and call data easily enough going into one table, but I am having problems with connecting tables and using the idea of normalization. I am starting simple with an online registration for alumni of an association. My first table in a database is called alumni and it stores there e-mail address, first and last name and year of graduation. Code:
View Replies !
View Related
Retrieve Data From Mysql
i have this code: <?php // Connects to your Database mysql_connect("localhost") or die(mysql_error()); mysql_select_db("eurialz") or die(mysql_error()); //This code runs if the form has been submitted if (isset($_POST['submit'])) { //This makes sure they did not leave any fields blank if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] | ! $_POST['name'] | !$_POST['gender'] ) { header("location: register.php?error=yes"); exit;} // checks if the username is in use if (!get_magic_quotes_gpc()) { $_POST['username'] = addslashes($_POST['username']);} $usercheck = $_POST['username']; $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { header("location: register.php?error2=yes"); exit; } // this makes sure both passwords entered match if ($_POST['pass'] != $_POST['pass2']) { header("location: register.php?error3=yes"); exit; } // here we encrypt the password and add slashes if needed $_POST['pass'] = md5($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['username'] = addslashes($_POST['username']); } // now we insert it into the database $insert = "INSERT INTO users (username, password, name, gender, dobmonth, dobday, dobyear) VALUES ('".$_POST['username']."', '".$_POST['pass']."', '". $_POST['name']."', '".$_POST['gender']."', '".$_POST['dobmonth']."', '".$_POST['dobday']."', '".$_POST['dobyear']."')"; $add_member = mysql_query($insert); header("Location: newmember.php"); ?>
View Replies !
View Related
MySQL Retrieve Previous And Next Row
I have a table which store details of uploaded images. The primary key is pic_id. If I upload five images, there will be 5 rows, with sequential pic_id's. If I delete the row where pic_id = 3, how can I implement navigation between pic_id = 2 and pic_id = 4? Initially I have been using: $pic_id = $_GET['pic_id']; $next_pic = $pic_id+1; $previous_pic = $pic_id-1; But obviously this will only work if all of the pic_id's are sequential.
View Replies !
View Related
Retrieve Names From MYSQL
1. Im tryin to retrieve the following names from the database 'kagiso', 'steve', 'dwele', 'raheem', 'raekwon', 'common' 2. i need to retrieve only 3 names @ a time then echo a 'next >>' link that will retrieve the last three
View Replies !
View Related
Retrieve Multidimensional Array From Mysql?
I am developing a site to sell dvds. Each dvd can have multiple actors, I have created a select query that returns the film information and if there is more than 1 actor associated, more than 1 row is returned. I have tried to use the mysqli_fetch_array function to retrieve all the rows but this only seems to retrieve the first row. I assumed it would create a multidimensional array but I cannot find a second row. I have tried such things as $row[0][actor_name], $row[1][actor_name] but this does not work.
View Replies !
View Related
Retrieve TREE Structure From Mysql Db
I already know how to print a tree structure using a recursive function but what i want is to save the results in a multidimensiona array so i will be able to format them in a table with graphic etc. the funciont that i am using to simple print the structure is: function display_children($parent, $level) { // retrieve all children of $parent $result = mysql_query('SELECT titolobreve,id FROM categorie '. 'WHERE parent="'.$parent.'";'); // display each child while ($row = mysql_fetch_array($result)) { // indent and display the title of this child echo str_repeat('- ',$level).$row['titolobreve']." <br>"; display_children($row[id], $level+1); } }
View Replies !
View Related
Search, Retrieve And Update MYSQL Db
I've successfully managed to write php code for a db where data is strictly written to the mysql db. That was easy. Now, I need to create a search page and have the search term search a specific field and retrieve all records corresponding to the search term. Subsequently, on a second page, I'd like to display the records (with corresponding fields) and edit each one by having drop down menus for each record (multiple edits). The records are then updated in the db using one submit button.
View Replies !
View Related
MySQL Regexp - Retrieve The First 4 Consecutive Digits
This is my first stab at regular expressions. Can anyone tell me what I'm doing wrong. I'm trying to retrieve the first 4 consecutive digits after the word 'admitted'. There is a varying number of letters and digits after the word 'admitted', so I used [:alnum:]* but I'm only interested in the first 4 consecutive digits I find. Code:
View Replies !
View Related
Trying To Store And Retrieve Formatted Text From MYSQL
I am trying to store formatted text (windows format) into a MySQL database and then retrieve it. The field in the database is a varchar. I cut and paste the test into a form field formatted, then call the PHP program to add the record using POST. When I get the text out, it has lost it's formatting. Formatting in the text is achieved by multiple spaces not tabs, but even multiple spaces are converted to a single space and the carrage return/line feeds are lost. Below is the basic code I am calling when I click POST in the form. Code:
View Replies !
View Related
Retrieve Data From Mysql Table And Put A Hyperlink For Download
I have created a database and a table and have stored the information in mysql table. Now my question is how do I retrieve that data from the my sql table and have a php page that when someone goes to say:download.php, he/she will be able to download the data from my mysql table? Also what if I have multiple tables in mysql that I want to be able to download from the php file?
View Replies !
View Related
Retrieve MySQL Row's Auto-increment In Query
I've only been working with PHP and MySQL for about the last month and half and have done fairly well but have run into a problem that I hope has an answer. I'm working on a simple, small animation showcase site where people I know (animators) can post their animations/movies. Visitors can then "tag" their movies with descriptive words. If I submit a form to insert the mysql row that has an auto-incrementing ID # on it into a table, is there a way to retrieve that ID immediately and use it in that same query to insert the ID # into another table (which I use to cross-reference the table that contains all of my movies's info and the table that contains the information I want to be able to relate to that user)? SO, more plainly I want to: - Retrieve from a form/page the movieID and tag - Insert "tag" into "tags" table of my database, which automatically assigns each tag row an ID - Pull the tagID for the tag row that was just created from the tags table <- Where I need the help - Insert the tagID and movieID into a crossref table
View Replies !
View Related
Retrieve Data From Mysql And Send Email To User
does anyone know how i could make php or sql retrieve data from mysql database and then send an email to the respective user the info that is in the database? like a user request for forget password, i want the user to be able to receive a mail from me. i have the mail stuff done and all the stuff are on my laptop (localhost) using php and apache.
View Replies !
View Related
Content Manager Without MySql
I would like to setup a website for someone where they can change some content themselves (list of concerts). The obvious choice is to use PHP and MySql, but is there a way to do it without MySql. It will save me about US$15.00 per months, is it worth the hassle?
View Replies !
View Related
Mysql Content Management
I have created a site for my community in which people can come in and places ads about their pets and so forth. the site works but what i want to do is once they place their ad it gets inserted in to the database and it is inmidiately available in the results page. so my first issue is , I would like to find a way to put that ad on "hold" until i review the ad, and then once i see is ok, then i will publish it. but i don't know how to go about this. Code:
View Replies !
View Related
Rankings Of Mysql Table Content
I have a large Mysql database table full of ratings of items. For example, say I had: "apple" with a rating of 3 "banana" with a rating of 7 "grape" with a rating of 4 "orange" with a rating of 6 What I need to do is rank the ratings. For example, banana would be rank 1, and apple would be rank 4. I suppose this you could compare this to any item on Amazon.co.uk (i.e: Amazon.co.uk Sales Rank: 10). I need to show the rank on a page viewed by a visitor. I have thought a few ways of doing this myself (I have been developing with PHP and Mysql for a while), but the problem is, the database table has over 10,000 rows! I have tried making a simple script, to select all rows, ordered by rating (descending), and then to add a rank number to the row (in a new column) before moving onto the next row. However, after 15 minutes, this script has still not completed! Has anyone got any suggestions on the best way that I could produce a ranking for each item?
View Replies !
View Related
Display Content From A MySQL Table
I have copied a script out of a book and then modified it to fit my needs. But I keep getting a parse error and don't know how to fix it. I am trying to take content from a MySQL table and order it by the name. Here is the script I have: Code:
View Replies !
View Related
Formatting Mysql Output As Content
i'm working on a web project that involves entire text articles that are stored in a mysql database to be presented as content on a website. certain parts of the text are going to be formatted differently than others (titles, links, email addresses) and i was wondering how other developers organize a project like this. do you attempt to sort your data into meaningful columns in mysql such as title, author, etc and apply certain formatting options depending on the column it came from, or do you simply lump the entire article into a big blob and sort out the formatting with PHP? i will be working with multiple articles that will all require the same formatting applied.
View Replies !
View Related
Leech (?) Content Of MySQL Tables
I was wondering something about mySQL, but i don't have a clue if it's possible (but it would be great!). Imagine i have two tables. One is called species, and one is called animals. One of the species is 'birds' (others are fishes etc.) In my table animals one of the birds is a hawk, another an eagle. Anyway, can i get a field in 'animals', that automatically has the same content as a defined field in 'species'. So if i would change 'birds' to 'flying animals' in the 'species' table, it would also change in the 'animals' table.
View Replies !
View Related
MySQL Delete Only Deleting Content
I am working on a content editor for a client who wants tha ability to add new page. But he also has to be able to delete page. The pages are refered by their PID column which is set to auto increment. However, when I delete a row, for some reason, it deletes the content in the row, but not the row itself. So, I have an empy row left which gets assigned a PID when I drop the PID column and reconstruct it with the new auto_increment numbers. What could be causing this? Or is there a way to renumber the auto_increments after a page has been deleted? My coding is a little rusty right now as I am out of practice. had to have a reference manual by my site at all times. PHP Code: $sql     = "DELETE FROM $db_table WHERE PID = $id LIMIT 1"; $result = @mysql_query($sql, $db_connect) or die(mysql_error()); $drop     = "ALTER TABLE $db_table DROP COLUMN PID"; $result = @mysql_query($drop, $db_connect) or die(mysql_error()); $add    = "ALTER TABLE $db_table ADD PID INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"; $result = @mysql_query($add, $db_connect) or die(mysql_error());
View Replies !
View Related
Email Content Written To Mysql
wondering if someone may direct me to a little more info/advice on what i need to do. Currently some of our workers cannot place daily reports through our online system because they have been blocked from using a browser by the workplace, so I am thinking that there may be a way to populate a mysql table from an email. If i set up a seperate email address for them to send their text reports in, is there a way that when that email lands in the email box it can automatically update a table with the contents of that email?
View Replies !
View Related
Copying Content Of A Mysql Table
I want to copy the content of a table with lots of duplicate e-mailaddresses into another, new table (which should have only unique e-mail addresses). How can I do this most efficient? The old table and the new table have different columns. There are also some other columns (like Ip address) I want to copy to the new table).
View Replies !
View Related
Populating Page Content From Mysql Db.
First off my db table is orginized in this way: ImgKey (auto increments) ImgType (pertaining to the buttons in the gallery) ImgName (name of image) When you click a button from the initial gallery page, my plan is to pass a query string to the next page with the appropriate ImgType. On the next page I need to grab all the records in the table with that ImgType. (you can see the next page by clicking the first button) Code:
View Replies !
View Related
Looking For PHP Solution To Adding Content To MySQL Database
I have recently used aedpro to quickly make pages for my client to be able to /add/edit/delete/view all/ content in their MySQL database. Though these pages work, they are limited to an all-or-nothing type view within their returned record pages. You can't sort the edit or delete pages to find your information quickly/easily, you have to scroll through all the records to find your record of interest. The database contains over 2000 horses, so scrolling to find a particular horse takes too long. Or, when trying to edit a horse's record, or group of records, you have to scroll to find the record(s) instead of being able to type in the record's horseID number and then go just to that record or group of records to edit. Do any of you gurus out there know of a PHP based MySQL database management system that you have used that is both flexible in its use and easy to install? I have Googled, but nothing is coming up but CMS type systems, which we don't need. Perhaps I am calling this something it is not, thus I can't find it. Any help or direction appreciated.
View Replies !
View Related
Managing Content On A PHP/mysql Enabled Website
I have a .htm website with about 150 pages of content. I want to convert these pages to php to, among other things, increase the ease of maintenance of the website. I'm intending to use a template for the site, such as using a .inc header and footer. Before looking in depth at php and mysql I was under the impression that for each page I would have variables such as $title $description $author $articledate and $article which would pull data from the corresponding info stored in the mysql database. Is this the best way to approach such a website? I'm just questioning it because I can't find specific information on the processes needed to set up an article based dynamic website.
View Replies !
View Related
MySQL And PHP - Modify The Html Code In The Content
I'm using mySQL and PHP on a webhost, and WordPress. ... Wordpress is what I'm using to make it easy for my pops to post articles. My index.php uses some code to pull from the mySQL db (created by wordpress) and puts the post content into a div, then p class. However, I'm noticing that when the content contains html coding, it seems to fall out of the class and lose it's padding. Is there some command I need to use to modify the html code in the content when it's posted to my page? Below is what I think is the relevant code: You can check the results at www.meetwithkbh.com (yes, it's got a goal). If there's no html like <ul>'s and <li>'s included in the post, it formats fine with the padding, but - if there is, it'll drop out of the padding that i'm trying to keep. <?php $db = mysql_connect("localhost", "mywordpressdb", "*******"); /*no, these aren't the real user/pass ;) */ mysql_select_db("dbwordpress",$db); $result = mysql_query("SELECT id, post_title, post_content, post_date_gmt FROM wp_posts ORDER BY post_date_gmt DESC Limit 0, 5",$db); while ($myrow = mysql_fetch_row($result)) { echo "<div class="post"> <p class="posttitle">"; printf("%10.60s", $myrow[1]); echo "</p>"; echo " <p class="postcontent">"; printf("%10.400s",$myrow[2]); echo "...<a href="More.php">Read More</a></p> </div><br /> "; } mysql_close($db); ?> Here is the css, contained in the index.php too, which is in the proper place in the index.php: ..posttitle { font-size: 120%; font-weight: bold; color: white; background: #806C59; padding: 3px 3px 3px 1em; margin-top:0em; } ..postcontent { padding-left:2em; padding-right: 2em; text-align: justify; } ..post { border: 1px solid #cccccc; line-height:1em; }
View Replies !
View Related
Use A Content Type Application/zip, And A Content Disposition With The File Name (test.zip)
I was able to use Ethor's suggestion to fix a problem I'm having. My original problem was that I was missing the quotes around the filename in the CD header. I've read the ensuing dialog between Ethor and JD and have a question/comment driven by the fact that things don't seem to work for me the way they're "supposed to" and I wonder why. I use a content type application/zip, and a content disposition with the file name (test.zip) just like JD suggests. But it only works if the HTTP request ends with ".zip". My request is http://a.b.c.net/cc/production.php?file=123&zip=.zip I get a valid zip file downloaded, but the filename isn't the filename in the CD header - its cc.zip. Furthermore, if I make the request http://a.b.c.net/cc/production.php?file=123&zip= (no .zip on the end, which is what I wanted it to be), it doesn't work at all. The dialog box that pops up is making the filename ?file=123&zip= (Note: I'm using IE as the browser. My server is remote from where I am, and I go through all kinds of route point and a VPN to get to the server. Also note that this works when I browse to my local machine.) I've tried various combinations of application/zip, octet-stream, lower/upper case, quotes/no quotes, order, etc. All have the same result described above. The only two headers I specify in PHP are the CT and the CD. I making a SWAG that some device between my browser and the remote server is monkeying around with the request and/or response headers. Otherwise why would the response headers that my PHP application has correctly applied? Is there something in the Apache or PHP configuration I need to look at? http://eye.cc php newsgroups
View Replies !
View Related
Using The 'Content-type', 'Content-Disposition' And 'readfile'
I've been facing a problem I couldn't solve, I don't know how to serch for it in the list's old messages, so I'll tell you what it is and see if you can help me. I have this lines: if (isset($_GET['download']) && ($_GET['download'] >= 1)) { if ($_GET['download'] == 1) header('Content-type: application/doc'); else if ($_GET['download'] == 2) header('Content-type: application/rtf'); else if ($_GET['download'] == 3) header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="' . $_GET['file'] . '"'); readfile($_GET['file']); } It should show to the user an dialog to the user, so he can choose to save the file or to open it directly. The dialog shows and the user chooses, and here comes the problem, by using the 'Content-type', 'Content-Disposition' and 'readfile' the content of the page I'm in is "attached" to the end of the file I'm downloading. When it's an DOC or RTF file, the content of the page doesn't affect the funcioning, but if it's an PDF the string taht goes "attached" in the end of the file happens to make the file useless. All I want to do is to use some routine to let the user choose to save the file or to read it directly, nothing more, nothing less. I have been trying to solve this problem for at least some weeks, and I couldn't find some information that could really help me. BTW, at php.net I found the following example: <?php // We'll be outputting a PDF header('Content-type: application/pdf'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // The PDF source is in original.pdf readfile('original.pdf'); ?> I used (as can be seem) this example with some modifications, but not too much, and it happens that it's useless for my needs, if someone knows how to fiz it or some other way to do what I want please let me know, I'll be very grateful.
View Replies !
View Related
XML Content Syndication And Content Management System
I have several folders of news stories in XML format on my server running PHP, MySQL, apache. What's the best way to dynamically grab the xml files and display them? Is there an existing news content management system that would allow me to specify which XML stories I want displayed? Allowing me to QC news stories and approve/ban them via an admin screen?
View Replies !
View Related
How Do I Retrieve $Variable From URL?
How Do I Retrieve $Variable From URL? I am designing a user registration section for a web site. "Page One" below contains excerpts from the user input form and "Page Two" below contains excerpts from the script that 1).inputs the data into the database and 2).sends an e-mail with the $UserName variable appended to the URL. Pages One and Two work just fine. Page Three is where I'm having the difficulty. My question is this: How do I get the $UserName variable that is appended to the URL on page two (that is subsequently sent in an e-mail) to insert into the "UPDATE $TableName..." query shown below on Page Three? PHP Code:
View Replies !
View Related
How I Can Get Php To Retrieve The Directory
Can anyone tell me how i can get php to retrieve the directory i am working from (Home Directory)the reason i ask is i am getting a directory listing of my images folder and i dont want to have to enter the complete path to that directory (C:lahdahimages) i want to be able to just enter the images folder as my folder to retrieve.
View Replies !
View Related
Retrieve Body Tag
If I have a body tag that looks something like this <body id="home page"> where each page on my website has a unique "id", is it possible to retrieve the body tag in PHP and pass the id along as a variable?
View Replies !
View Related
Cannot Retrieve Data In Utf-8 From Php
I have a IIS server with php3 installed. I have SQL server database and data stored in unicode format (nvarchar fields). In header of my php I have the meta: <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">. I have the following problem: - I trie to do a query using ODBC (version 3.525.1022.0) and SQL Server odbc driver (version 200.85.1022.00). The query doesn't retrieve information in utf format and accents and extra characters aren't showed correctly. - I trie to di the query usin native OLE DB. I use mssql funtions and the problem is the same. If I install php4 and I use "new COM("ADODB.Connection",NULL,CP_UTF8);", then it works correctly. Anybody knows if its posible to retrieve data from sql-server in utf-8 format using php3? I see in other postings that odbc driver only accept utf-8 in version 3.7 or higher? Is it true? If is true, where I can download odbc driver 3.7?
View Replies !
View Related
Retrieve All Pics From Url
I want to get all pics (.jpg) from a url and I use this code but sometimes with some urls it doesnt work :( Anyone can check it out? $text = implode("", file($url)); $text = eregi_replace("<!--([^-]|-[^-]|--[^>])*-->","", $text); while (eregi("[:space:]*(img)[:space:]*=[:space:]*([^ >]+)", $text, $regs)) { $regs[2] = ereg_replace(""", "", $regs[2]); $regs[2] = ereg_replace("'", "", $regs[2]); $regs[2] = preg_replace("/(s.+)/" , "" , $regs[2]); if(eregi(".jpg|.jpeg|.jpe",$regs[2])){ echo $regs[2]."<br>"; } $text = substr($text, strpos($text, $regs[1]) + strlen($regs[1])); }
View Replies !
View Related
|