PHP - Php & Mysql Books
Hey guys,
I really need a descent php & mySQL book, but i have just been looking on Amazon and the prices are gay, excuse thee expression : P. I was just wondering if anyone on this forum had any they have finished with that they could like to sell to me for a reasonable price. I probably sound like a bit of a scruff, but i am a student and soon to be a father (literally soon, she is due on the 20th of this month ) so money is tight. lol Similar TutorialsHello wasn't sure where to put this post so if a needs moving please move.
I recently took a break from design due to birth of my daughter, i am coming back to learn php and have
PHP solutions: Dynamic Web Design Made Easy – David Powers
was wondering if it is still a good book to use to learn from.
Thanks
I know some basic PHP from my college. I wanted to learn WordPress, but before jumping into wordpress I think I should expertise PHP functions and arrays because that what mostly used in WordPress.
Can you recommend me some books/resources where advanced level PHP functions and arrays are discussed. Main Focus is PHP Functions, advanced level.
I know some basic PHP from my college. I wanted to learn WordPress, but before jumping into wordpress I think I should expertise PHP functions and arrays because that what mostly used in WordPress.
Can you recommend me some books/resources where advanced level PHP functions and arrays are discussed. Main Focus is PHP Functions, advanced level.
So I have these session variables being stored on login. Each page stores these session variables in local PHP variables. For some reason, all pages display that variable in the URL except one page. I have done some 'echo' work just to ensure variables have values stored and that everything was being read appropriately, no issues there. The variables are apparent everywhere on the page besides the URL. Below you can find all the code I have to make this thing work....maybe someone can point me in the right direction because I am STUMPED!!! LOL So my first page calls a popup window in javascript defined below. The link involves the following PHP Code: [Select] $customer_id = $_SESSION['cid']; $customer_email = $_SESSION['cust_email']; $customer_fname = $_SESSION['cust_first_name']; $customer_contact_id = $_SESSION['customer_contact_id']; $customer_company_id = $_SESSION['customer_company_id']; $c_project_id = $_GET['pid']; $c_project_id = mysql_real_escape_string($c_project_id ); $c_project_id = eregi_replace("`", "", $c_project_id); Then comes in the Javascript... Code: [Select] <script type="text/javascript"> <!-- $(document).ready(function(){ $(".approval").click(function(){ v = $(this).attr("id"); url = 'deny_approval.php?cid=<?php echo "$customer_id"; ?>&company_id=<?php echo "$customer_company_id"; ?>&customer_contact_id=<?php echo "$customer_contact_id"; ?>&pid=<?php echo "$customer_project_id"; ?>§ion=' + v; window.open(url, "myWindow", "status = 1, toolbar = no, scrollbars = yes, location = no, resizable = no, height = 600, width = 600, resizable = 0" ); }); }); //--> </script> And finally, the HTML.... Code: [Select] <body> <a href="#" id="deny_quote_approval" class="approval">Deny Quote Approval</a><br /><br /> </body> Any ideas?? As always, any help would be greatly appreciated. Bl4ck Maj1k I am working on a website which sells various content, including books/guides in an online format. A lot of people - including here - have stated that they wouldn't make a purchase on my site if I didn't also offer a PDF version of books/guides. (I guess more people read offline than I do personally?!) Right now, I am working on the ecommerce portion so people can browse a catalog, choose a book/guide, add it to their cart, and check out. (Just your textbook ecommerce metaphors.) After making a purchase, when someone logs in, then they can navigate to a gallery which contains thumbnails representing all of the books they have purchased. And by clicking on a given thumbnail, they will be taken to that particular online book which is a series of linked web pages protected from outsiders behind a paywall. I am comfortable with all of this, however I'm stuck on what to do with the PDFs... First off, when someone is in the Product Catalog picking out books and guides, should I give them the chance to specify if they want a PDF version, or should I just give everyone that buys a book/guide both access to the online book/guide PLUS the PDF version as well? Next, for customers who get a PDF, how should I deliver it to them? Do I make the PDF available when they navigate to their online book? Do I build a second gallery which only shows PDFs that have been purchased? Do I leave links to the PDFs up indefinitely, or should I just offer a one-time download? And if so, how would I go about that? In summary, something that seems so simple actually is very confusing the more I think about it. This is probably because I have never bought online books or PDFs before and so I don;t have any examples in my mind to go off of. Could definitely use some advice here, and am hoping this won't be as difficult as it currently seems?! Thanks.
This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=307986.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=334128.0 create table mimi (mimiId int(11) not null, mimiBody varchar(255) ); <?php //connecting to database include_once ('conn.php'); $sql ="SELECT mimiId, mimiBody FROM mimi"; $result = mysqli_query($conn, $sql ); $mimi = mysqli_fetch_assoc($result); $mimiId ='<span>No: '.$mimi['mimiId'].'</span>'; $mimiBody ='<p class="leading text-justify">'.$mimi['mimiBody'].'</p>'; ?> //what is next? i want to download pdf or text document after clicking button or link how to do that Hello everyone, Sorry if this has been answered but if it has I can't find it anywhere. So, from the begining then. Lets say I had a member table and in it I wanted to store what their top 3 interests are. Their$ row has all the usual things to identify them userID and password etc.. and I had a further 3 columns which were labled top3_1 top3_2 & top3_3 to put each of their interests in from a post form. If instead I wanted to store this data as a PHP Array instead (using 1 column instead of 3) is there a way to store it as readable data when you open the PHPmyadmin? At the moment all it says is array and when I call it back to the browser (say on a page where they could review and update their interests) it displays 'a' as top3_01 'r' as top3_02 and 'r' as top3_03 (in each putting what would be 'array' as it appears in the table if there were 5 results. Does anyone know what I mean? For example - If we had a form which collected the top 3 interests to put in a table called users, Code: [Select] <form action="back_to_same_page_for_processing.php" method="post" enctype="multipart/form-data"> <input name="top3_01" type="text" value="enter interest number 1 here" /> <input name="top3_02" type="text" value="enter interest number 2 here" /> <input name="top3_03" type="text" value="enter interest number 3 here" /> <input type="submit" name="update_button" value=" Save and Update! " /> </form> // If my quick code example for this form is not correct dont worry its not the point im getting at :) And they put 'bowling' in top3_01, 'running' in top3_02 and 'diving' in top3_03 and we catch that on the same page with some PHP at the top --> Code: [Select] if (isset($_POST)['update_button']) { $top3_01 = $_POST['top3_01']; // i.e, 'bowling' changing POST vars to local vars $top3_02 = $_POST['top3_02']; // i.e, 'running' $top3_03 = $_POST['top3_03']; // i.e, 'diving' With me so far? If I had a table which had 3 columns (1 for each interest) I could put something like - Code: [Select] include('connect_msql.php'); mysql_query("Select * FROM users WHERE id='$id' AND blah blah blah"); mysql_query("UPDATE users SET top3_01='$top3_01', top3_02='$top3_02', top3_03='$top3_03' WHERE id='$id'"); And hopefully if ive got it right, it will put them each in their own little column. Easy enough huh? But heres the thing, I want to put all these into an array to be stored in the 1 column (say called 'top3') and whats more have them clearly readable in PHPmyadmin and editable from there yet still be able to be called back an rendered on page when requested. Continuing the example then, assuming ive changed the table for the 'top3' column instead of individual colums, I could put something like this - Code: [Select] if (isset($_POST)['update_button']) { $top3_01 = $_POST['top3_01']; // i.e, 'bowling' changing POST vars to local vars $top3_02 = $_POST['top3_02']; // i.e, 'running' $top3_03 = $_POST['top3_03']; // i.e, 'diving' $top3_array = array($top3_01,$top3_02,$top3_03); include('connect_msql.php'); mysql_query("UPDATE members SET top3='$top3_array' WHERE id='$id' AND blah blah blah"); But it will appear in the column as 'Array' and when its called for using a query it will render the literal string. a r r in each field instead. Now I know you can use the 'serialize()' & 'unserialize()' funtcions but it makes the entry in the database practically unreadable. Is there a way to make it readable and editable without having to create a content management system? If so please let me know and I'll be your friend forever, lol, ok maybe not but I'd really appreciate the help anyways. The other thing is, If you can do this or something like it, how am I to add entries to that array to go back into the data base? I hope ive explained myself enough here, but if not say so and I'll have another go. Thanks very much people, L-PLate (P.s if I sort this out on my own ill post it all here) I have following piece of code below, and I would like to be able to express it pure SQL, something that could go into a .sql file :
$request_string='SELECT topic_forum_id FROM topic_table WHERE topic_id= 2014'; $query=database->prepare($request_string); $query->execute(); $data=$query->fetch(); $query->closeCursor(); $forum=$data['topic_forum_id']; $request_string='INSERT INTO post_table (post_topic,post_forum) VALUES (2014,:forum)'; $query=database->prepare($request_string); $query->bindValue(':forum',$forum,PDO::PARAM_INT); $query->execute(); $data=$query->fetch(); $query->closeCursor();Is it possible ? So i have this php as shown below. It should make a list of comments with comment replies below their comment respectively. The problem is that it only goes through and shows 1 comment and all the comment replies for that one comment. It should be showing all comments i have in the db for that article. If i remove the second while then it shows all the comments correctly but no comment replies then... How do i get this script to loop through the db for every comment but also loop through every comment reply for that $row[id]? If anyone has a better / more efficient way of what I am trying to do, please explain or show example (i am open to anything)... Code: [Select] // what article are we showing? $article_to_show_id = $_GET['article_id']; $active_is_set_text = "1"; // Active Column text that makes it okay to show // Finding the article $search_for_article = mysql_query("SELECT * FROM articles WHERE id = '$article_to_show_id' AND active = '$active_is_set_text'"); while($row = mysql_fetch_array($search_for_article)) { // format the last updated date right $update_date_edit = $row[update_date]; $update_date_edit = date('F j, Y \a\t h:ia', $update_date_edit); $row[update_date] = $update_date_edit; // format the submit updat date right $submit_date_edit = $row[submit_date]; $submit_date_edit = date('F j, Y \a\t h:ia', $submit_date_edit); $row[submit_date] = $submit_date_edit; echo ' <div> ', $row[title] ,' </div> <div> by: ', $row[author] ,' on ', $row[submit_date] ,' </div> <div> ', $row[content] ,' </div> <div> Last Updated: ', $row[update_date] ,' </div> <form action="article_reply.php" method="post"> <input type="hidden" name="article_id" value="', $row[id] ,'" /> <button name="article_reply" type="submit" value="submit">Reply</button> </form> '; } $comment_count = 0; $comment_reply_count = 0; // Finding all of the comments $search_for_article = mysql_query("SELECT * FROM article_comments WHERE article_id = '$article_to_show_id' AND reply_id = '0'"); while($row_comment = mysql_fetch_array($search_for_article)) { // format the submit updat date right $comment_date_edit = $row_comment[comment_date]; $comment_date_edit = date('F j, Y \a\t h:ia', $comment_date_edit); $row_comment[comment_date] = $comment_date_edit; echo ' <br> <br> COMMENT:<br> <div> By: ', $row_comment[username] ,' on ', $row_comment[comment_date] ,' </div> <div> ', $row_comment[comment] ,' </div> '; $comment_count++; // Finding all of the comment replies if any $search_for_article = mysql_query("SELECT * FROM article_comments WHERE article_id = '$article_to_show_id' AND reply_id = '$row_comment[id]'"); while($row_two = mysql_fetch_array($search_for_article)) { // format the submit updat date right $comment_date_edit = $row_two[comment_date]; $comment_date_edit = date('F j, Y \a\t h:ia', $comment_date_edit); $row_two[comment_date] = $comment_date_edit; echo ' <br> <br> COMMENT REPLY:<br> <div> By: ', $row_two[username] ,' on ', $row_two[comment_date] ,' </div> <div> ', $row_two[comment] ,' </div> '; $comment_reply_count++; } } Need some help I have 2 tables in a database and I need to search the first table and use the results from that search, to search another table, can this be done? and if it can how would you recommend that I go about it? Thanks For Your Help Guys! Hi im trying to count the number of rows in my notifications My code So far list($total_server) = mysql_fetch_row(mysql_query("SELECT COUNT(id) FROM users WHERE notifications")); I have a Database with two tables "users" and "Logins" and I'm trying to figure out how to check the cookie ID and use a mysql query to check if ID from the cookie matches UID in the "Logins" table and get all the data with a matching ID and UID. How exactly would I go about doing this? -edit- Fixed spelling -edit- Hi all! I have racked my brain trying to figure this one out. I'm typically a smart cookie, but since I am kinda new to php and mysql, I'm stumped. I'm just trying to program a Joomla search plugin that queries my HDFLV player database, so videos are searchable, but I keep getting an invalid "foreach(" command. It's supposed to be there to interpret the database query, right? I'll post my code here, can someone give me some insight? Code: [Select] <?php /** * @version $Id: contacts.php 10381 2008-06-01 03:35:53Z pasamio $ * @package Joomla * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); $mainframe->registerEvent( 'onSearch', 'plgSearchhdflvplayer' ); $mainframe->registerEvent( 'onSearchAreas', 'plgSearchhdflvplayerAreas' ); JPlugin::loadLanguage( 'plg_search_hdflvplayer' ); /** * @return array An array of search areas */ function &plgSearchhdflvplayerAreas() { static $areas = array( 'hdflvplayer' => 'Videos' ); return $areas; } /** * Contacts Search method * * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category */ function plgSearchhdflvplayer( $text, $phrase='', $ordering='', $areas=null ) { $db =& JFactory::getDBO(); $user =& JFactory::getUser(); if (is_array( $areas )) { if (!array_intersect( $areas, array_keys( plgSearchhdflvplayerAreas() ) )) { return array(); } } // load plugin params info $plugin =& JPluginHelper::getPlugin('search', 'hdflvplayer'); $pluginParams = new JParameter( $plugin->params ); $limit = $pluginParams->def( 'search_limit', 50 ); $text = trim( $text ); if ($text == '') { return array(); } $section = JText::_( 'hdflvplayer' ); switch ( $ordering ) { case 'oldest': $order = 'a.id ASC'; break; case 'popular': $order = 'a.times_viewed DESC'; break; case 'alpha': $order = 'a.title ASC'; break; case 'category': $order = 'b.title ASC, a.title ASC'; break; case 'newest': default: $order = 'a.id DESC'; } $text = $db->Quote( '%'.$db->getEscaped( $text, true ).'%', false ); $query = 'SELECT a.title AS title, "" AS created,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(\':\', b.id, b.alias) ELSE b.id END AS catslug, ' . ' CONCAT_WS( ", ", a.title, a.description ) AS text,' . ' CONCAT_WS( " / ", '.$db->Quote($section).', b.title ) AS section,' . ' "2" AS browsernav' . ' FROM #__hdflvplayerupload AS a' . ' INNER JOIN #__hdflvplayername AS b ON b.id = a.catid' . ' WHERE ( a.title LIKE '.$text . ' OR a.description LIKE '.$text.' )' . ' AND a.published = 1' . ' AND b.published = 1' . ' AND a.access <= '.(int) $user->get( 'aid' ) . ' AND b.access <= '.(int) $user->get( 'aid' ) . ' GROUP BY a.id' . ' ORDER BY '. $order ; $db->setQuery( $query, 0, $limit ); $rows = $db->loadObjectList(); foreach($rows as $key => $row) { $rows[$key]->href = '?pid='.$row->slug; } return $rows; } ANY help is more than what I got from HDFLV Player support. Thank you so much in advance! Hi all, I have a question concerning building the Admin area. Let's say there are 3 pages. Page 1: "staff.php" (login/register page) Page 2: "staffproc.php" (process forms) Page 3: "adminManage.php" (Manage the content, edit, delete, add, etc.) I need to link the login page to the admin page so no one can access "adminManage.php" without providing the Login details. How??? Will I just include the login page into the admin? Any response will be appreciated!! Just want to ask how to create a login system using these wml and php? i have a background on connecting html php and the database.. but in these wml i am confused.. can someone help me? What i'ved got here is Wap Proof for wap emulator to test my codes.. You can download it here http://www.wap-proof.com/ i have tried this code but i gets me to error.. // login.php <?php # Header Info header('Content-Type: text/vnd.wap.wml', true); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); # Version Type print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; # Import config file include "/home/jamieb/private/conf.php"; # Connect to database mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname); ?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <!-- THIS IS THE LOGIN CARD --> <card id="login" title="Login"> <p> <do type="accept" label="Login"> <go href="process.php" method="post"> <postfield name="userName" value="$userName" /> <postfield name="password" value="$password" /> </go> </do> </p> <p> User Name: <input title="userName" name="userName" /> <br /> Password : <input title="password" name="password" type="password" /> <br /> </p> </card> </wml> // process.php <?php # Header Info header('Content-Type: text/vnd.wap.wml', true); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); # Version Type print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; # Import config file include "/home/jamieb/private/conf.php"; # Connect to database mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname); # Verify the user $sql = mysql_query("SELECT userName,nickName FROM table WHERE userName = '".strtolower($_POST['userName'])."' AND password = '".md5($_POST['password'])."'"); $row = mysql_num_rows($sql); $login = mysql_fetch_array($sql); $user = md5($login['userName']); $nick = $login['nickName']; if ($row == 0): ?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id="failed" title="Login Failed"> <p> Sorry, username or password incorrect! </p> <p> <anchor>Home <go href="index.php#menu" /> </anchor> <do type="prev" label="Back"><prev/></do></p> </card> </wml> <?php exit; else: ?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id="success" title="Login Success"> <p> <do type="accept" label="Admin"> <go href="admin.php" method="post"> <postfield name="session" value="<?php echo "$user"; ?>" /> </go> </do> </p> <p>Welcome <?php echo "$nick"; ?>, please enter the admin area.</p> </card> </wml> <?php endif; ?> My problem here is it doesn't open anything on the wap proof.. or if i ever open it i can't see the submit button.. can someone give some login scripts using php wml? thanks the code below isn't populating the mysql fields... i believe it's not running correctly at the while and for loop areas. also, would like to know of a way to have the 1000 to have the ability to look at the end of the row and then look at the next row of data, because there are sometimes +/-1000 characters in a row. can someone please assist? many thanks. <?php //connect to the database include "opendb.php"; #if the first row of csv file contains column headings: $columnheadings = 1; if (($handle = fopen("/my/file/destination/name.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); # echo "<p> $num fields in line $columnheadings: <br /></p>\n"; $columnheadings++; for ($i=0; $i<$num; $i++) { $line = trim($data[$i],'",'); $arr = explode(',',$line); //mysql insert of values $sqlData = ("INSERT INTO thisTable(name1, name2, name3, name4, name5) VALUES('".$arr[0]."', '".$arr[1]."', '".$arr[2]."', '".$arr[3]."', '".$arr[4]."')"); } } fclose($handle); } else { mysql_query($sqlData) or die(mysql_error("The specified file does not exist. Thanks.")); } mysql_close($con); ?> |