toplay
-
Posts
973 -
Joined
-
Last visited
Never
Posts posted by toplay
-
-
Maybe you want something like this:
$query2 = "SELECT COUNT(*) AS TotalCount, `to_t1` - `from_t1` AS TotalNumber, SUM( `to_t1` - `from_t1`) AS Totalhours FROM `week1`";
-
Based on what I think you want, try something like this:
select
*
from Agents
join Properties
using (Agent_ID)
where AgentCounty = 'something'
-
...I've made sure the variable names correspond with the HTML form names...
That will only work if you have register_globals on. Keep it off and use $_GET or $_POST instead.
You're already using $_GET['id'], so why aren't you doing it for the other fields? Or are you already usign $_GET and assigning it to those variables and you're just not showing us that?
To help debug, display the $updatequery value before or after the mysql_query(). The SQL syntax shown in post looks correct.
Note: Look into using mysql_real_escape_string() - always use especially with string values.
-
Read up about using quotes in PHP (and MySQL).
$query="INSERT INTO films (Name, Genre, Year) VALUES ('$Name', '$Genre', '$Year')";
-
$sql = "SELECT Name FROM films WHERE Name LIKE '$letter%' ";
-
Changing this part:
LIKE '%" . $letter . "%'"
to this:
LIKE $letter . "%'"
will find everything starting with whatever $letter value is.
-
You should state the bottom line of what you're trying to do. For instance, you can use fsockopen() or perhaps cURL instead (if available) of trying to install sockets.so.
I doubt you can do what you want through godaddy (they're very limiting with their PHP). They're a great registrar, but I would never use them to host a web site.
FYI: I highly recommend to host with these guys (starting at $4.95 USD):
http://www.ixwebhosting.com/index.php/v2/pages.planBusinessPlus
-
Yes, that's the correct syntax ProjectFear.
DssTrainer, members have already helped you with PHP answers, and here's how to do it in MySQL if you want:
select
if(column_name = 1, 'true', 'false') as boolean_string_var
from
table_name
-
Try a query similar to this:
select
menu_name
, link_name
, link_href
, link_target
from scm_menus
join scm_menu_links
on link_parent = menu_id
order by link_order ASC
Just read each row from the result to build the array however you want it to be.
Note: The link_parent should be the same size as the menu_id. One should not be int(10) and the other int(11) (and whether negative allowed or not).
-
It would have been easier if you just listed your join query so we can help with the syntax issue.
I'm not sure what you mean exactly, but here is something to try:
select
pq.poll_id
, sum(if(pa.answer = pq.answer1, 1, 0)) as total_for_answer_1
, sum(if(pa.answer = pq.answer2, 1, 0)) as total_for_answer_2
, sum(if(pa.answer = pq.answer3, 1, 0)) as total_for_answer_3
, sum(if(pa.answer = pq.answer4, 1, 0)) as total_for_answer_4
, sum(if(pa.answer = pq.answer5, 1, 0)) as total_for_answer_5
from pollquestions pq
join pollanswers pa
using (poll_id)
-
You need to have a column name and not enclosed is single quotes where you have '$SearchCat'.
So, remove the single quotes or use backtick marks like so:
$query2 = "SELECT * FROM clients WHERE `$SearchCat` LIKE '$search2'";
You already have the percent signs in $search2 so you should be good to go.
FYI: Look into the use of mysql_real_escape_string():
http://us3.php.net/manual/en/function.mysql-real-escape-string.php
-
Change the last part from this:
AND sumHits>1 GROUP BY h.visitorID ORDER BY v.dateTime DESC LIMIT 0, 20
to this:
GROUP BY h.visitorID having sumHits >1 ORDER BY v.dateTime DESC LIMIT 0, 20
-
Try something like this:
select
u.user_id, u.first_name, cr.credit_amount
from `user` u
join `credit_remaining` cr
on cr.user_id = u.user_id
where u.user_id = 1234
-
Look closely after the table names. Each one is assigned an alias 'io', 'i', and 'c'.
FYI:
-
By default, when no column list is provided at the end of the LOAD DATA INFILE statement, input lines are expected to contain a field for each table column. If you want to load only some of a table's columns, specify a column list:
LOAD DATA INFILE 'persondata.txt' INTO TABLE persondata (col1,col2,...);
You must also specify a column list if the order of the fields in the input file differs from the order of the columns in the table. Otherwise, MySQL cannot tell how to match input fields with table columns.
-
Don't use a union and just join the tables. The way to do it depends on what data you want back. This is an example where it only displays info only on the customers that have ordered (it goes through the item_order table as the primary source).
select
c.cust_id, c.fname, c.lname, i.order_id, i.color, i.size, i.price, io.date
from item_order io
join item i using (order_id)
join customer c using (cust_id)
order by io.cust_id, io.order_id, i.item_id
;
-
-
To find server version do: select version();
To list dup titles:
select count(*) as number_of_dups, Title from Kvikmyndir.Movie group by Title having number_of_dups > 1;
-
Use a join:
SELECT
im.name
, ipc.field_11
FROM ibf_pfields_content ipc
JOIN ibf_members im
ON im.id = ipc.member_id
ORDER BY ipc.field_11 DESC
-
Specifying a date/time in the "WHERE" clause will be faster than MySQL executing a function (DATE_SUB) every time.
FYI - extra info: Even if a column like SignupDate had a key/index MySQL may or likely would not use the index if used in a function (i.e. DATE_SUB(SignupDate...)).
-
Don't forget the percent signs. Try something like this:
$sql="SELECT m.login, m.email, p.distributornr FROM `amember_members` m LEFT JOIN `profile` p USING (member_id) WHERE m.login LIKE '%$search%' OR p.distributornr LIKE '%$search%' OR m.email LIKE '%$search%'";
-
The best is not to use DATE_SUB() in the 'WHERE' clause at all but an actual date. Execute the query to retrieve your values and use PHP strtotime() to calculate the date, then use that in your 'WHERE' query instead of DATE_SUB(). That will be the fastest.
-
Write a function to do it based on the criteria/format you're looking for and then check the serial generated in your database to make sure it's not already used (if so, generated a different one and check again).
You can use the char(rand(65, 90)) to produce a random character between A to Z.
-
Change this:
$query="INSERT INTO messages(username,from,message) VALUES('$to',$username','$msg')";
To this:
$query="INSERT INTO messages(`username`,`from`,`message`) VALUES('$to','$username','$msg')";
[SOLVED] Update table query not working
in MySQL Help
Posted
Post the $updatequery value here.
How are you determining that it's not updating?
Do:
$result = mysql_query($updatequery);
echo ($result) ? 'Update successful. Rows affected (if any): ' . mysql_affected_rows() : 'Did not update. Error: ' . mysql_error();
Tell us the result.
Note: MySQL will not update the row if it determines the values are the same (it's intelligent enough to know there's nothing different and no point in updating). So, if the values you're trying to update is already in the table for that tutid, then it won't update.