PHP - Reading Normalized Mysql Database (key/value)
I have a normalized database in the form of
Code: [Select] ID user_id key value 1 3 first_name Brian 2 3 last_name Tardy 3 4 first_name John 4 4 last_name Wilson What is the fastest way to capture these values within php? I want to perform a SELECT to catch the values for every user as Code: [Select] $result=mysql_query("SELECT * FROM users_data WHERE user_id = '$id'"); while($row=mysql_fetch_array($result)) { here we process all data for a given user and write it to text file as a single line } Since it is a long list (100K users with about 10M of rows in user_data), I am looking for the fastest and most reliable way to scan all the database. ?> Similar TutorialsHey, I'm trying to work out how I can have a simple script that will work like this: Page 1 - Heading, Paragraph, Image read from database. Page 2 - Has text boxes allowing you to change heading, paragraph and image (url) with each edit using a different text box. (Admin panel) The database connection would be in a separate file. So far I've got the database connection sorted. Code: [Select] <?php //Database Information $dbtype = "mysql"; $db_host = "localhost"; $db_user = ""; $db_pass = ""; $db_name = ""; $db_port = ""; $db_table_prefix = "userCake_"; ?> At the top of each of the other pages this is what I've got. Code: [Select] <?php require_once("models/config.php"); ?> Let's say I give each bit stored in the database a page ID and an object ID. If the page selected is index.php how can we give it a page ID of 1 and give then include all the separate 'objects' throughout the page? Hopefully this makes sense? Cheers, Jack Where is the best to store the list of categories and menu? Obviously it is better to reduce mysql queries. From a plain list in file, we can create desirable list (menu) from an array. This is quite faster (though SELECT from an indexed table is fast too; but I do know if it is as fast as reading from a php file). Any idea how to code this to create the menu faster ? As per the client requirement he wants to read words from a file and want to insert them in database one by one . ie a confirmation is required whether he wants to insert is or not. I have developed the thing but the problem is when i am retrieving the words it asks for all the words. i will show u wat the problem is. My main query is i want to pause the exectution until user's input. Code: [Select] <script type="text/javascript" src="jquery.js"></script> <script type"text/javascript"> function show() { document.getElementById('form#submit').fadeIn(); alert("Abhinav"); } $(document).ready(function(){ $("form#submit").submit(function() { // we want to store the values from the form input box, then send via ajax below var word = $('#word').attr('value'); var synonym = $('#synonym').attr('value'); $.ajax({ type: "POST", url: "ajax.php", data: "word="+ word + "&synonym=" + synonym, success: function(){ $('form#submit').hide(); //$('form#submit :input').val(""); $('div.success').fadeIn(); } }); return false; }); }); </script> <?php $file=fopen("welcome.txt","r") or exit("Unable to open file!"); @$word=""; @$c=""; while (!feof($file)) { $c=fgetc($file); if(strcmp($c," ")==0) { echo "". "<form id='submit' method='post' name='submit' action='' >". "<fieldset> ". "<legend>Enter Information</legend> ". " <label for='word'>Word:</label> ". "<input id='word' class='text' name='word' size='20' type='text' value='$word' > ". " <label for='Synonym'>Synonym:</label> ". "<input id='synonym' class='text' name='synonym' size='20' type='text'> ". " <button class='button positive' type='submit'> Add Client </button> ". " </fieldset> ". " </form> ". "<div class='success' style='display:none;'>Client has been added.</div> ". "</div>"; $word=""; } else $word=$word.$c; } fclose($file); ?> Now what i want is after user clicks add client then only next insertion box must be shown. please check the attached image to see the output. Guys pls help me over this. Thnx in advance I'm trying to learn how to code the proper way. There's a few things im worried about,but overall im worried about clogging up the server. so what should i keep in mind while coding, to avoid this? I'm thinking, keep insert and update to a minimum? as in, when possible, use session to keep track of data until i absolutly have to add that data to a database? is that a correct thought? what about once the data is in the database, how much trouble is it to ask for the selected data inside a database? should i be worried about overdoing request of data from databases? on the other hand, should i be worried about having too many sessions travelling around with a user. why? Im just asking to get a better feel for how to do things the proper way, i would hate to have a website built, only to find out that what i built is only a bat, that would bash the hell out of a server i wanted to put it on. I am reading in a table and ordering it by a column labeled "sub" and generating an HTML table. The "sub" column entries are in numerical order (i.e. 1 2 3 4 5 6 7 8 10 11 12 etc. etc.). There are over 100 entries in this table as well. The problem I'm facing is probably obvious to some of you as the display is
1 Obviously I'd like the display to be in numerical order.
What can I do?
I have news articles which I distribute to various sites. Each article contains various hyperlinks, which must resolve to a location on the site which pulled the article, i.e. Article: (hyperlink) Widgets are wonderful. Don Doe, president of (Widgets Incorporated) say they are cool. ------ Site A: To resolve to example.com/widget-companies/Widget-news/Widgets-Incorporated. Site B: To resolve to otherexample.com/Widgets-Incorporates/widget-news I'm paralyzed. The only thing I can think of is to bring the whole article in, and do a string replace. Some of the articles are 2k+ words. Even then, I have to come up with a way of pointing out the link text. I came up with $COMPANY:WIDGETS-INCORPORATED:Widget-Incorporated (UC WIDGETS to associate it with that company, and the mixed case Widget-Incorporated would be the hyperlink text. Explode it and use it. I am not even sure it will work, or if it works whether it is too inefficient. Should I try that, or something else? Hello
Is it possible to save data from saved htm table from other website in our mysql database system
as I have problem that there is one htm page where i can get data but i want to save it in mysql table. as data is large on htm page
it was hard to copy so i want access it direct from php and save it in mysql table
please guide
awaiting your valuable reply.
Thank in advance
Hi All, Is there a way we can write a PHP script to automatically read receive emails, extract csv file attachment from there and insert into MySQL database then run this in Cron Jobs to automate the process? Hi All, Is there a way we can write a PHP script to automatically read receive emails, extract csv file attachment from there and insert into MySQL database then run this in Cron Jobs to automate the process? Hi my website has been working all day now everypage is getting this error also get the same error when i try to login into phpmyadmin Lost connection to MySQL server at 'reading initial communication packet', system error: 111 is this most likely a problem with the server? This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=353212.0 At the moment I am creating a search function for my website. The approach I have in mind is a pseudo-PHP database. To give an example: A HTML form will submit the results to a PHP file. HTML FORM - Colour: Black PHP RESULT PAGE - if ($_POST['color'] == 'Black') {readfile("./products/black/*.html");} HTML FORM - Price: <$50 PHP RESULT PAGE - if ($_POST['Price'] == '<$50') {readfile("./products/less50/*.html");} The problem here is if there is an item that is black and costs less than $50, then its going to be listed twice. There is probably some code I can write to ommit the listing of duplicate entries, but it is probably going to be messy, so I am wondering if its better to use a centralized MySQL database, rather than a pseudo-PHP database? I've never used MySQL and don't know much about it and this is my first real attempt at using PHP. Hello, Five images will be displayed inside a division. There will be a previous and next button/link. If someone click the next button the next image will be added in that div and the first image will be gone from that div. The previous button/link will do the same thing. Is it possible with php? I am confused if it's a javascript or ajax question. Thanks. Alright, wasn't quite sure how to summarize this in the title, but I want to: Check if a user status is "active" or not based on the UserName input. I have a table witch holds: Code: [Select] VarChar Username Var CharPassWord int Active Ted TedsPW 1 something like the above(assuming it formatted correctly. In my php script I will want to input a variable for Username to check for: inputUN in this example would be "Ted". $UserNameToCheck = $_GET['inputUN']; Then I want to check for that UserName in the database, if it exists, I want pull the value for the "Active" field for just that UserName and echo it. Thanks for any help. How would I go about doing the following: I have a csv like this Quote "Division","Section","Group","Product Code","Description","Description + Secondary Description" "Division 1","Section 1","Group 1","BMSLPL25","Test Name","Test Description" "Division 1","Section 1","Group 2","BMSLPL26","Test Name 2","Test Description 2" "Division 2","Section 2","Group 2","BMSLPL27","Test Name 3","Test Description 3" I have a database structured like this Quote Divisions --- id name parent_id Groups --- id name division_id Products --- id code description secondary_description Section is a sub division. What is the best way to get the information from CSV into this database? Should I have another table and store the CSV data as is and then query that to make the other tables. Any help much appreciated. Okay, I have been following this tutorial: http://www.freewebmasterhelp.com/tutorials/phpmysql/1 to achieve exactly what I wanted to get done. I also followed the way to have it formatted in tables and added extra columns that I needed, included an "Options" column which houses three links, including "edit" and "delete" Now, I have everything working fine but I am stumped on how to get the "edit" and "delete" links to work for each individual entry that is listed. I have to have these features so the entries can be edited and deleted without having to physically go into the MySQL database to do it. The tutorial explains how to do it in Step 6, but I am confused. I'm not quite sure where to place the code for the links, which are generated automatically every time a new entry is inputted into the database. Anybody available to help me out? Thanks! Hi, I wonder if you could help me try to find what i'm looking for, i have a problem with bogus users on my site. I created a register page where the details are sent to the database, this is fine but someone is registering with the username: 1 and password: 1 multiple times. I have about 50 of these now and i would like to know what to actually search for (how to word it) to find out how to stop this? What would be the name of the script? i've looked for fake username script, multiple username/password prevention script, i'm just not getting it, sorry. If any of you have any ideas i'd like to hear from you, many thanks in advance for that. If you need anymore to go on please ask, once again thank you. |