Entering Data Into A Second Table:
Using a script, I able to insert the data into the first table of my mysql db, but when I try to insert the same into second table(duplicate, so same vars, etc.. no prob at that level), it doesn't go through. It doesn't even make an empty row(which would mean wrong vars) Someone told me to check in the logs of both PHP and mySQL. How do I do this?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Entering Data From One Table To Another
does anyone know how to write a statement where you are able to transfer data from one table to another? I have got one table with user details. and I have another table for creating bulletins. is there a statement which will put the ID of the user from user details to bulletins everytime they create a bulletin?
Page Reloads Keep Entering Data In Db
The problem is I have a small form that allows a user to input data into a database. Everything works fine, after a successful submission, the user get a message saying that their info was accepted. The problem is that if that page is reloaded, it enters the info again. There is only going to be one person doing the submitting so I could explicitly say...DO NOT RELOAD the page, but that seems kinda half as**d.
Ok Problems Entering Data Into Database
i am having problems if you look at the script below you will see that it the query has 4 values to insert but the actual values only contain title entry and now() for the date. well i have made the database and the blog_id is a primary auto interger what ever table bascly look below the the insert code block to find the code block that makes the table in the database, // Define the query. $query = "INSERT INTO blog_entries (blog_id, title, entry, date_entered) VALUES ('{$_POST['title']}', '{$_POST['entry']}', NOW())"; // Execute the query. if (@mysql_query ($query)) { print '<p>The blog entry has been added.</p>' } else { print "<p>Could add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } --------------------------------------------------------------------------------------------------------------------------------------------------- // Define the query. $query = 'CREATE TABLE blog_entries ( blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR(100) NOT NULL, entry TEXT NOT NULL, date_entered DATETIME NOT NULL )' // Run the query. if (@mysql_query ($query)) { print '<p>The table has been created.</p>' } else { die ('<p>Could not create the table because: <b>' . mysql_error() . '</b>.</p><p>The query being run was: ' . $query . '</p>'); } Quote:
Entering Data From A Form To A Mysql Database
I'm trying to enter data from a form with the fields name and email into a mysql database called newsletter, as you guess it's a newsletter sign up. this what I have at the moment: Code:
Using PHP To Sort Data In MySQL Table 1 By Values In Table 2
I have a MySQL database with 2 tables in it. products and prices.. Products has a field in it called 'prodno'. Prices has a field in it called 'prodid'. There is one of each item in products and each product has it's own unique 'prodno' There are multiple instances of each product's pricing in prices.. One for each price.. So if a product had multiple prices depending on quantity it would have an entry for each price.. Example: id = 1 prodid = 7001 qty = 300 price = 12.5 id = 2 prodid = 7001 qty = 400 price = 15.5 I was wondering if I could query the database getting info from the products table but sort it according to the prices in the prices table. Kinda like doing a "SELECT * FROM products" ordering it by the lowest price value from each item.. This is all very confusing to me, and I'm the one writing it. Let's try one last time.. Query the database selecting * from products (I plan on using all the info in products) and ordering them by the lowest price for each item in the prices table. I've tried sorting the results of just a basic SELECT * FROM products using Javascript and PHP but with pagination in the results it makes it a bit hard.
Update Table While Insert Data To Another Table
it seem like mine coding din work. [php]<? include("checkin.html"); $conn=mysql_connect('localhost','root','') or die ('Could not connect to server'); $today = date("Y.m.d"); mysql_select_db('hms', $conn); $ok = mysql_query("INSERT INTO check_in(ID,room_no,datein)values ('$ID','$room','$today')", $conn); if( $ok ){ $up = mysql_query("UPDATE studtable SET checked = 'checkin' where [ID] = '%ID'); if(mysql_affected_rows( $up ) == 1) { echo'Checked IN!' }else { echo'No such student to check in' }} else { echo'Check In FAILED, please check again'}?>[php]
Table Data
I have a table on a php page with the cells containing database data from a mysqldatabase. what would be the easiest way to allow a user to change how the data is listed by clicking on the top of each data column? I have seen this feature on most applications but cant figure out how to doit??
Table Data Row
I have a script that pulls information from a table. This table contains foreign id keys for other tables. This code works just fine, but pulls id numbers. I would like to make a change to this file to convert the id numbers into their matching names. I have tried to use this type of code:
Data Into Table
I'm trying to get a neat and clean readout of all of the parasites that are in the MySQL table. Right now everything works except all of the info is all over the table and I can't seem to get the table to be clean and presentable for when I open my site to the public. Code:
Help Listing Data In Php From My Table.
I have a result set that came from the query "SELECT * FROM characters" and I want it to list on my php page the results like: Name gender race Name gender race Name gender race How could I do that?
Inserting Data Into A Table
I would like to know if there is anything strange about the script below(I have only just started to learn php so there may well be!) Although it seems to work, occasionally it doesn't just insert a single row into the data base, instead 2 or 3 duplicate rows end up in the table. Could the explanation be that I tried this morning to create a table and forgot I already had one with this table name in the database. Would that have damaged the table in some way making it misbehave! I have commented out the bit about creating tables as I only want to insert data with this script at the moment. One other thought occurs to me, is the problem due to my host freedom to surf as its only a free host and I expect you get what you pay for(or don't pay for in this case). I have subscribed to a pay host http://www.phpwebhosting.com but I am unable to use the database that they have provided because they have informed me that I must use a telnet shell to log into my database and I have absolutly no idea what this is(is it in my Win98?) or do I need to go and get one. I am still waiting for this host to email me back with some help. If there is anyone out there who could tackle all or some of my problems I would be very grateful indeed! One last thought - I think there is something very strange going on as sometimes when I visit my database, there is less entries in this table than last time, some have been chucked away and my id entries are all out of order now, something like 1,2,3,11,5,7,12 - the last insert had id = 12 next to it and somehow another duplicate has sprung up id = 11???????? Whats going on please! <html> <head> <title> Connecting to Mysql server at ISP host</title> </head> <body> <?php $Host = "db.davegraham.f2s.com:3306";// Set the variables for the database access: $User = "p0c79"; $Password = "********"; $DBName = "p0c79"; $TableName = "Jokes2"; $link = @mysql_connect("$Host", "$User", "$Password"); if (!$link) { print("<P>Unable to connect to the " . "database server at this time.</P> "); //note how 2 strings have been concatonated exit(); } else { print("Your now connected to the Mysql server at the host ISP.<P> "); } if (! @mysql_select_db("$DBName") ) { print("<P>Unable to locate the $DBName database at this time.</P> "); exit(); } else { print("The database $DBName has been located.</P> "); } /* $sql = "CREATE TABLE $TableName (ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, JokeText TEXT, JokeDate DATE NOT NULL )"; if ( mysql_query($sql) ) { print("<P>$TableName table successfully created!</P> "); } else { echo("<P>Error creating $TableName table: " . mysql_error() . "</P>"); } */ $Query="INSERT into $TableName VALUES(Ɔ', 'hello hello hello!', ��-08-08')"; if (mysql_query ($Query)) { print ("The query was successfully executed!<br> "); } else { print ("The query could not be executed!<br> "); } mysql_close($link); ?> </body> </html>
Column Data From One Table To Another
im trying to get the vend_name column data from one table(manuf) into another table (products2) that has the same vend_name column which is empty but has a vend_code column as a key identifier. im wondering if theres a way to put the data from the vend_code column and vend_name column from the first into an array so that i can populate the vend_name column of the 2nd table this is what ive come up with below, it seems to be just puting the last record into those two array variables PHP Code:
Copy Table Data To Another
I've been searching in the PHP forums for this answer, and I've found something similar, and have used to this to the problem I have. Anyway, when I do run this script I get an error line 5 which is the 'while' statement. $query_newsfeed = "SELECT itemid,heading,news_date,content FROM newsfeed"; $query1_exec = mysql_query ( $query_newsfeed ); // Error here! while ( $query_row = mysql_fetch_assoc ( $query1_exec ) ) { $query2 = "INSERT INTO newsfeed_map ( itemid,heading,news_date,content ) VALUES ( $query_row[$itemid],'$query_row[$heading]','$query_row[$news_date]','$query_row[$content]' )" $query2_exec = mysql_query ( $query2 ); Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Any ideas where I could be going wrong?
How To Replace ID With Data From Another Table.
I'm working on a project where I have a MySQL table that contains profile data. This data has 2 grouping fields one for group and one for criteria. The client wants the flexibility to edit and rename these grouping fields without having to go back and make changes to each profile. With this said, I created 2 more tables one for group and one for criteria. Tables would look like this:
Inserting Data Into A Table.
I keep getting a parse error with this code. What am I doing wrong? The SQL statement works in MySQL. Is there something wrong w/the way I'm decaring my PHP variables? Code:
Dynamic Data In Table
Trying to display dynamic data in a table. The code spits out the table just fine, but won't display the $name variable at all, I just get table cells w/ broken links. I must be missing something but can't get it, thanks. my code:
Format Data Into A Table
Managed to get this script to out put data and put it into table format. But the idea is to be able to limit the number of data into 3 columns. I put a border = 1 into the table to see whats happening. It seems that the first entry gets into the table and the rest gets listed one after the other with no table around it. Check out the code ! PHP Code:
Insert Data To A Table
I just can't figure out why it isn't sending the data to the table, I've check the names over and over, all the info is parsed correctly, but it falls flat at: $result = mysql_query($sql);
Converting Table Data From HTML To PHP
I have a problem converting data from a html file, to a 3 way split. (header.php index.php and footer.php, Reason being PHP won't parse the following line, <table width="37%" border="0" cellspacing="0" cellpadding="0" height="163"> I think it all revolves around the % sign, does anyone have any ideas about how to fix it without limiting the width to X amount of pixels?
Grabbing Data From A Table And Displaying It
I'm grabbing data from a table and displaying it but I want to to spand out into multiple pages...I got it all setup but when I click on the next link nothing happens... I got it setup at "3" right now just for testing..I have 5 entries in the database.. anyways could someone help me out? here is the code: <?php // Get connection info include "../connect.php"; // End connection info if(!$rowstart) $rowstart=0; // Start database select $result = mysql_query( "SELECT * FROM links WHERE notactive='$notactive' order by date desc limit $rowstart,3"); //Select Database $result2 = mysql_query("select * from links"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } // Display the text of each host while ( $row = mysql_fetch_array($result) ) { if ($notactive = 1) { echo ("<table width=500 height=57 border=0 cellpadding=0 cellspacing=0>"); echo ("<tr>"); echo ("<td align=left valign=top><strong>" . $row["name"] . "</strong></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=left valign=top>" . $row["desc"] . "</td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=left valign=top><a href=" . $row["url"] . ">". $row["url"] ."</a></td>"); } echo ("</tr>"); echo ("<br><br>"); echo ("</table>"); } if ($rowstart>$numrows) { echo "<A HREF=$php_self?rowstart=rowstart-3>"; echo "< Previous Page</A>"; } echo "|"; $numrows=mysql_num_rows($result2); if($rowstart+3<$numrows) { echo "<A HREF='$php_self?$rowstart=rowstart+3'>Next Page></A>"; } ?>
Grabbing Data From A Table And Displaying It
I'm grabbing data from a table and displaying it but I want to to spand out into multiple pages...I got it all setup but when I click on the next link nothing happens... I got it setup at "3" right now just for testing..I have 5 entries in the database.. anyways could someone help me out? here is the code: <?php // Get connection info include "../connect.php"; // End connection info if(!$rowstart) $rowstart=0; // Start database select $result = mysql_query( "SELECT * FROM links WHERE notactive='$notactive' order by date desc limit $rowstart,3"); //Select Database $result2 = mysql_query("select * from links"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } // Display the text of each host while ( $row = mysql_fetch_array($result) ) { if ($notactive = 1) { echo ("<table width=500 height=57 border=0 cellpadding=0 cellspacing=0>"); echo ("<tr>"); echo ("<td align=left valign=top><strong>" . $row["name"] . "</strong></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=left valign=top>" . $row["desc"] . "</td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=left valign=top><a href=" . $row["url"] . ">". $row["url"] ."</a></td>"); } echo ("</tr>"); echo ("<br><br>"); echo ("</table>"); } if ($rowstart>$numrows) { echo "<A HREF=$php_self?rowstart=rowstart-3>"; echo "< Previous Page</A>"; } echo "|"; $numrows=mysql_num_rows($result2); if($rowstart+3<$numrows) { echo "<A HREF='$php_self?$rowstart=rowstart+3'>Next Page></A>"; } ?>
Grabbing Data From A Table And Displaying It
I'm grabbing data from a table and displaying it but I want to to spand out into multiple pages...I got it all setup but when I click on the next link nothing happens... I got it setup at "3" right now just for testing..I have 5 entries in the database.. anyways could someone help me out? here is the code: <?php // Get connection info include "../connect.php"; // End connection info if(!$rowstart) $rowstart=0; // Start database select $result = mysql_query( "SELECT * FROM links WHERE notactive='$notactive' order by date desc limit $rowstart,3"); //Select Database $result2 = mysql_query("select * from links"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } // Display the text of each host while ( $row = mysql_fetch_array($result) ) { if ($notactive = 1) { echo ("<table width=500 height=57 border=0 cellpadding=0 cellspacing=0>"); echo ("<tr>"); echo ("<td align=left valign=top><strong>" . $row["name"] . "</strong></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=left valign=top>" . $row["desc"] . "</td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=left valign=top><a href=" . $row["url"] . ">". $row["url"] ."</a></td>"); } echo ("</tr>"); echo ("<br><br>"); echo ("</table>"); } if ($rowstart>$numrows) { echo "<A HREF=$php_self?rowstart=rowstart-3>"; echo "< Previous Page</A>"; } echo "|"; $numrows=mysql_num_rows($result2); if($rowstart+3<$numrows) { echo "<A HREF='$php_self?$rowstart=rowstart+3'>Next Page></A>"; } ?>
Grabbing Data From A Table And Displaying It
I'm grabbing data from a table and displaying it but I want to to spand out into multiple pages...I got it all setup but when I click on the next link nothing happens... I got it setup at "3" right now just for testing..I have 5 entries in the database.. anyways could someone help me out? here is the code: <?php // Get connection info include "../connect.php"; // End connection info if(!$rowstart) $rowstart=0; // Start database select $result = mysql_query( "SELECT * FROM links WHERE notactive='$notactive' order by date desc limit $rowstart,3"); //Select Database $result2 = mysql_query("select * from links"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } // Display the text of each host while ( $row = mysql_fetch_array($result) ) { if ($notactive = 1) { echo ("<table width=500 height=57 border=0 cellpadding=0 cellspacing=0>"); echo ("<tr>"); echo ("<td align=left valign=top><strong>" . $row["name"] . "</strong></td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=left valign=top>" . $row["desc"] . "</td>"); echo ("</tr>"); echo ("<tr>"); echo ("<td align=left valign=top><a href=" . $row["url"] . ">". $row["url"] ."</a></td>"); } echo ("</tr>"); echo ("<br><br>"); echo ("</table>"); } if ($rowstart>$numrows) { echo "<A HREF=$php_self?rowstart=rowstart-3>"; echo "< Previous Page</A>"; } echo "|"; $numrows=mysql_num_rows($result2); if($rowstart+3<$numrows) { echo "<A HREF='$php_self?$rowstart=rowstart+3'>Next Page></A>"; } ?>
Q. Data Not Posting Mysql Table
I am trying to post from a form to table using the code below from file2.php and having two problems: 1. The data is not being posted to the table 2. After submit is pressed the following message comes up: "The page cannot be displayed" - The browser can't find the file, because it is looking for http://file2.php instead of http://teachercards.org//file2.php
HTML Table With Data From Two Recordsets
I have two MySQL tables, say one is author and one is books. Author contains a unique PK say author_id Books contains an author_id also which links across to the author table. Usual stuff. My problem is getting at the info. If I wanted to display the info, in it's mnost basic format, I would set up a HTML table with the columns and repeat the row. PHP Code:
Extract Data From Table Html
I would like to extract data from the table attached. Could someone help me to create the regular expression to grab that informations?
Echoing 3 Types Of Data From 1 Table Row
I have this script where one of the rows in a mysql table is named "type" tinyint(3). now when a person joins the site they have a basic membership and their data is 0 in the type row when they become silver members it is 1 and gold is 2 all 3 numbers are entered into that one row for each member depending on what kind of membership they have. what I want to do is echo each type of membership on a page by the total number of each type so say there is 100 basic memberships then it would add up all the 0's within the row in the mysql database and then echo that total. I have already gotten it to display total number of users by adding. Code: $query = "select id from user"; $result = MYSQL_QUERY($query); $totalusers=mysql_num_rows($result); @mysql_free_result($result); if(($s=="")or($s>=$totalusers)or($s<0)){ $s=0;} and then having <?print $totalusers;?> where ever I want it to echo. How can I do the same with the memberships? I have a feeling that it would have something to do with $totalusers=mysql_num_rows($result); i need to change mysql_num_rows to something else?
Simple Adding Of Data To A Table
I'm basically creating a system which add records to a pre made SQL database built in SQLyog. So far i'va had no problems actually connecting to the database and displaying resulst but I just cannot make it add records. I know its connected to the database as a I made a mistake with connection details on purpose to see if it recognised it. I just add data into a text field, click submit and the page goes to a new, blank page with no changes to the table when I check in SQLyog. Here is the code I have tried (simple add before I code the proper system): HTML page <form action="script.php" method="post"> Test: <input type="text" name="test2"><br> <input type="Submit"> </form> and the PHP script to add data: <? $host="localhost" $username="root"; $database="test"; $test2=$_POST['test2']; mysql_pconnect($host,$username); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO test2 VALUES ('','$test2')"; mysql_query($query); mysql_close(); ?>
Transfer Data From An Xls Spreadsheet Into A Table
Is there any way I can transfer data from an excel spreadsheet to my table?? Example: I have an .xls spreadsheet called hello.xls and it has 5 columns with hundreds of rows of data in it. I want to copy all this data to my table instead of copying line by line which will take me eternity. I have a table called hello which has the same 5 columns.
Using An Array To Insert Data Into A Table.
This works: $col1 = 2; $col2 = 2; $col3 = 2; $col4 = 2; $query = "INSERT INTO test (a,b,c,d) VALUES ($col1,$col2,$col3,$col4)"; and this does not $col = array(2,2,2,2); $query = "INSERT INTO test (a,b,c,d) VALUES ($col)";
Variable Data In Dynamic Table.
What I'm trying to do is list the values of an array into different table rows while alternating the color of the table rows. Simple enough right? It makes the table fine. Creates the proper ammount of rows. It even alternates color (yay!). The only thing that it doesn't do is list the values in the array. PHP Code:
Paginating Data W/ Inner Table Joins
I'm having some trouble paginating data using an inner table join. I know that the query for a standard pagination would look something like this... PHP Code:
Displaying Data In Html Table.
I wondered if anyone could offer some guidance, I trying to write a php script to connect to a database, and display the records in a table. I found the code here in a php4 text, and when I run this directly through the php intrupeter, the line Successfully connected is display and 4 as the number of rows. The database table we connect to, has three field username, firstname, surname. When I tried a while loop, to display the data in a table. No values were displayed. Could anyone possibly demonstrate how to display the username, firstname, surname values in a basic table? <?php function db_connect(){ global $MYSQL_ERRNO, $MYSQL_ERROR; $link_id = mysql_connect("localhost","user04", "password04"); if(!$link_id){ $MYSQL_ERROR = "Connection failed"; return 0; } else if(empty($dbname) && !mysql_select_db("database04")){ $MYSQL_ERROR = mysql_error(); return 0; } else return $link_id; } !$link_id = db_connect(); if(!$link_id) die(error_message('Error connecting')); $result = mysql_query("SELECT * FROM users"); if(!$result) error_message('Error in selection'); else echo "Successfully connected. "; $query_data = mysql_fetch_row($result); $total_records = $query_data[0]; if(!$total_records) error_message('No records'); else echo "$total_records."; ?>
Adding Data To Mysql Table
I have the following script which is supposed to process a complete order for a serial number from a POST. It has so far been working okay. It processes the order successfully, then sends an email to me and to the user, but it is failing at the point where it has to do the insert of the data into the CustomersTable. PHP Code:
Table And PHP Scripts For Existing Data
I've been using MySQL for several months and enjoyed great success when installing other people's scripts to databses I make using phpMyAdmin. My challenge is developing from scratch the scripts, for which I've got good resources, manuals, and much time into practice and test. My question is three-fold, as I have 14,000 records of Security Dealers that I want to install in MySQL at www.securitydealers.com 1) what should my table SQL statement look like for data (sample) as follows; "John Doe","Managing Partner","BM SECURITIES LTD.","P.O. Box 201","Grand Cayman","Cayman Islands,"","","345--555-5999", 2) once the table is created inside my database on MySQL, how do I load the data in? 3) what is the best choice of variables, operators and arrays for my PHP script, to display only records from a certain city, country, company name or Dealer name?
How To Display Random Data Table Row
I would like to be able to display a random database row in an ad system I am thinking about developing. Here is MySQL code that I create: <?php mysql_connect("localhost","username","password"); mysql_select_db("databaseName"); mysql_query("SELECT * FROM dateTableName ORDER BY RAND() LIMIT 1");?> Is this correct and what would be my next step to make a single random row display. I am sure I would use echo or print the database variables in some fashion. I the past I have been using the mysql_fetch_array method, but I am not quit sure how to do this now.
Fetching Data From Table Except The First Record
What query needs to be written to fetch the data except the first record, the id is auto increment but if the users delete the first lowest id then second id must not be shown. $tbl=new Model; $sSqlQuery="select * from ".ACHIEVEMENTS_TABLE." WHERE achievements_lang='EN' AND 1=1";
Getting Data From A Table Based On The Results From Another?
This is the second part of my problems with a top ten list: I'm making a site for guitar effects. I'm trying to make a list of the top ten effects pedals, based on how many effects settings (patches) people have submitted for each pedal. There are two tables, pedals and patches: I want it to select patches and find out which "pedal_id" is most common, then select that pedal ID from pedals, echo some tuff, then do the query again, except search for the SECOND most popular value, echo it, then the third, echo it, etc etc etc
Pulling Data From The Last Field Of A Table
What is the command to view the last result in a table using a DB query? Table Example TABLE PEOPLE >ID >NAME >POINTS one thing, it cant be ORDER BY id DESC If at all possible it has to be SELECT * FROM people WHERE name=jon && id=**last id** **last id** = Last id where the name jon was found.
Data From Table Based On Variable
Im making a website where users sign up to a club each user has a user_id and each club has a club_id. On the first page after logging in I want to be able to include a standard welcome message which will say something like "Welcome to $clubname". Then once the admin signs in he then has the ability to edit the post and write some information on the club and save it. However within the website there are lots of different clubs so I need the message that applies to a particular club to only be visible if the user is linked to the club. My database has 3 tables, 1 for users, 1 for clubs and 1 for welcome.
Adding Totals To Table Of Data
I have a table of data that is generated with a query php/mysql. I'd like to show a total for one of the columns that include dollar amounts. How would i go about doing that?
Entering Each Array Value Into DB
I need to enter an array of values into a database, having each value be inserted as it's own row. I've searched for how to do it and the best I found was the foreach() function. So, would: foreach ($array as value) { $result = mysql_query("INSERT INTO some_table (value1, value2) VALUES ('$value', '$someOtherValue')"); } work, or is there a better way to do it?
Checking For Existing Data In Mysql Table..
I'm having a bit of a problem on a project I'm working on.. Here's the deal: I want to log search terms. Easy enough, right? Well, to make things interesting, I want to *NOT* log terms less than 3 chars long, *AND* if the term's already in the database, I don't want to add the term again, I just want to update the 'count' field to reflect that there was a 'hit' to the word. Here's how I coded it note: it doesn't work because I suck and I have no real idea how to do what I'm trying to do): This is the actual "recording" code I came up with: if(strlen($term)>3){ $record_term = sql_query("insert into $terms(ID, Term, count) values ('', '$term','')"); Now, this is the code I've come up for for the adding to the count part.. (and I know it's wrong, if someone can fix that too, I'd appreciate it): $query = mysql_query("SELECT term, count FROM Term WHERE term like $term;"); $entry = @mysql_fetch_array($query); $new_count = $entry["count"]+1; $query = mysql_query("UPDATE links SET count = $new_count, WHERE Term like $term;"); mysql_close($db); ----------------------------------------- So how do I combine these two actions to do what I want it to do? and what's wrong with the second query?
Replace A Cell In A Table With New Data In MySQL?
how to replace a cell in a table with new data in MySQL? -OR- A good site that will explain it step by step and not just list functions? For example, I have a change username page, Need it to change the username field in the users function as a result.
|