hi,
i am using php/mysql.
i have a product table .
in which most product have starting name with number.
i want to listout all products start with any number.
any one have idea about it....
I'm new to PHP and MySQL I want a user to be able to store multiple names and there meanings in a MySQL database tables named names using PHP I will dynamically create form fields with JQuery every time a user clicks on a link so a user can enter 1 to 1,000,000 different names and there meanings which will be stored in a table called names.
Since I asked my last question I figured out how to store my values from my form using the for loop but every time I loop my values when I add one or more dynamic fields the second form field named meaning will not save the value entered also my dynamic form fields keep looping doubling, tripling and so on the entered values into the database it all depends on how many form fields are added dynamically. I was wondering how can I fix these problems?
On a side note I replaced the query with echo's to see the values that are being entered.
Here is the PHP code.
<?php
if(isset($_POST['submit'])) {
$mysqli = mysqli_connect("localhost", "root", "", "site");
$dbc = mysqli_query($mysqli,"SELECT * FROM names WHERE userID='$userID'");
$name = $_POST['name'];
$meaning = $_POST['meaning'];
if(isset($name['0']) && mysqli_num_rows($dbc) == 0 && trim($name['0'])!=='' && trim($meaning['0'])!=='') {
for($n = 0; $n < count($name); $n++) {
for($m = 0; $m < count($meaning); $m++) {
echo $name[$n] . '<br />';
echo $meaning[$m] . '<br /><br />';
break;
}
}
}
}
?>
And here is the HTML code.
<form method="post" action="index.php">
<ul>
<li><label for="name">Name: </label><input type="text" name="name[]" id="name" /></li>
<li><label for="meaning">Meaning: </label><input type="text" name="meaning[]" id="meaning" /></li>
<li><input type="submit" name="submit" value="Save" /></li>
</ul>
</form>
If needed I will place the JQuery code.
Hello guys I've got a mass mail function that sends e-mail to all emails in my mysql table. but theyr all goes spam. I want to use smtp validate for this function. How can I use smtp validation with "mail($email, $subject, $message, $headers);" ?
thank u
My client have created a script in php+mysql that saves images directly in the database and every images has url like this: www.example.com/image.php?id=421
In your opinion this is a very wrong solution ? Should I rebuild all the site ?
There are about 1000 visits per day and about 600 images in the database.
This is the site: http://tinyurl.com/3xkxdsw
I have a question about the snippet below. I'm wondering, if the first query doesn't bring any results, would I still get the results for the second query?
select *
from
(
-- first query
) as query1
left join
(
-- second query
) as query2
on query1.id=query2.id
left join
(
-- third query
) as query3
on query1.id=query3.id;
Update:
what I need is a full join, however, MySQL does not support it, what would be a good way to emulate this?
I'm currently using statement-based replication. After upgrading to MySql 5.1, I'm considering using row-based replication.
After reading the docs it seems that you can change the format of the master on the fly.
Will the slave automatically adapt to whatever type of binary log it is sent?
Do I have to make any changes to the slave or master to get ready for switching or can I simply modify the binlog_format variable on the master?
Hi,
I'm running a mySQL query that joins various tables of 500,000+ rows. Sometimes it takes a second, other times around 15 seconds! This is on my local machine. I have experienced similarly varied times before on other intensive queries, does anyone know why this is?
Thanks
Hi Guys,
I'm looking to construct a script that would go through an XML file. Would find specific tags in it, put them in a table and fill the table with specific tags within them. I'm using MySQL 5.1 so loadXML isn't an option and I think that ExtractData() method wont be much use either.. but I don't really know. What would be the best way to go about this?
With the tool "mysql administrator" i get a complete connection to my database, I can change userthings and so on.
But not PHPMyAdmin nor Joomly Installation will get a connection, they timed out.
Any Ideas?
I'm trying to use a simple mysql database but tweak it so that every field is backed up up to an indefinite number of versions. The best way I can illustrate this is by replacing each and every field of every table with a stack of all the values this field has ever had (each of these values should be timestamped). I guess it's kind of like having customized version control for all my data..
Any ideas on how to do this?
I recently encountered a problem in my production database due to MySQL bug. The bug is in the TimeStamp column. To avoid any inconvenience, I want to migrate the database to either Sql Server.
Is there any FREE tool to easily and reliably migrate data and table structures?
I really haven't found normal example of php file where mysql transactions are being used. Can you show me simple example of that?
And one more question. I've already created a lot of programming and didn't use transaction, maybe I can put any php function or smth to header.php that if one mysql_query fails, then others too?
Thank you.
Is there a way to only show the items that are older than a certain date in a php mysql array? I'm using this query method and sorting by lastpost_cl:
$query="SELECT * FROM properties ORDER BY lastpost_cl";
$result=mysql_query($query);
$num = mysql_num_rows ($result);
mysql_close();
and I was thinking the way of checking the time would be:
if (time() <= strtotime($lastpost_cl)) {
}
How can I combine the two and only show lastpost_cl that are older that the current time?
When I do mysqladmin extended from the command line, my Com_* counters differ completely from doing a show status when consoled into MySQL. Why is this?
Hi
I would like to know whether this MySql statement will be executed correctly,
"SELECT sum(price) FROM products WHERE productid IN (SELECT productid FROM shoppingcart WHERE sessionid=".$this->$sessionid.")"
And if not please give me pointers as to where I am wrong.
Thanks
I'm changing my dataset in my program. And when my job was finished, I'm connecting to mysql database. I don't want to do this job again, how can I send changings to database like this
mydatadapter.Update(dataset, " table");
I found this code, but I can't run it :S
Is it possible to merge these two mysql queries into one? I want to get NOW() returned to a php variable.
mysql_query('INSERT INTO translate (IDRef, RefType, Lang, Text, LastChangeTS) VALUES ('.$id.', \''.$reftype.'\', \''.$lang.'\', \''.$text.'\', NOW()) ON DUPLICATE KEY UPDATE text = \''.$text.'\', LastChangeTS = NOW()');
mysql_query('SELECT LastChangeTS FROM translate WHERE IDRef = '.$id.' AND RefType = \''.$reftype.'\' AND Lang = \''.$lang.'\'');
Iam quite new to functions in SQL and I would like to create a function to compare values in a MySQL table against previous and I am not sure how to do this.
For example (iId is the input value)
DECLARE pVal INT(20);
DECLARE val INT(20);
SELECT price INTO pVal FROM products WHERE Id=iId;
SELECT price FROM products;
IF price == pVal THEN
SET val = price;
END IF;
Thanks
I have a class variable called attributes which lists the instance variables I want to update in a database:
attributes = ['id', 'first_name', 'last_name', 'name', 'name_url',
'email', 'password', 'password_salt', 'picture_id']
Each of the class attributes are updated upon instantiation.
I would like to loop through each of the attributes and build a MySQL update query in the form of:
UPDATE members SET id = self._id, first_name = self._first name ...
Thanks.
in the following link
http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_flush_method
it says:Different values of this variable can have a marked effect on InnoDB performance. For example, on some systems where InnoDB data and log files are located on a SAN, it has been found that setting innodb_flush_method to O_DIRECT can degrade performance of simple SELECT statements by a factor of three.
Why O_DIRECT could slow down the select statement?
Why Nibernate HQL can not handle the following query:
from Deal D where (D.ApprovalDate + INTERVAL 1 Year) < current_timestamp() < (D.RenewalDate + INTERVAL -1 Year)
knowing that INTERVAL and YEAR are keywords in MySQL, so this is kind of mixing Sql within Hql (unless Hql can handle date functions like so and I don't know) . The dialect is MySQLDialect
Its perfectly valid to execute this query
SELECT '2005-01-01' + INTERVAL 1 Year;
I have a classified_id variable which matches one document in a MySql table.
I am currently fetching the information about that one record like this:
SELECT * FROM table WHERE table.classified_id = $classified_id
I wonder if there is a faster approach, for example like this:
SELECT 1 FROM table WHERE table.classified_id = $classified_id
Wont the last one only select 1 record, which is exactly what I need, so that it doesn't have to scan the entire table but instead stops searching for records after 1 is found?
Or am I dreaming this?
Thanks
I was trying to run the following query
UPDATE blog_post SET `thumbnail_present`=0, `thumbnail_size`=0, `thumbnail_data`=''
WHERE `blog_post` NOT IN (
SELECT `blog_post`
FROM blog_post
ORDER BY `blog_post` DESC
LIMIT 10)
But Mysql doesn't allow 'LIMIT' in an 'IN' subquery.
I think I can make a select to count the table rows and then make an ordered update limited by 'COUNT - 10', but I was wondering if there is a better way.
Thanks in advance.