db entry based on primary key

Posted on 16th Feb 2014 01:33 pm by admin

My "topics" table contains 10 entires
topicid topic
01 Bye
02 Hi
03 Hello
10 Morning

<?php //topics.php
ttopics[]= //I have 10 strings here which have changed by now.

foreach ($ttopics as $ttkey)

//I am trying to update my "topics" table whenever these strings change, based on the topicid (primary key).

//Please correct my code.

$id = mysql_real_escape_string('topicid');
$topic = mysql_real_escape_string('topic');
$result = mysql_query("SELECT topicid, topic FROM table WHERE topicid='{$id}' and topic='{$topic}' ");
$num = mysql_num_rows( $result );
if ($num == 0)
$querypost = mysql_query ("INSERT INTO trendingtopics (topic) VALUES ('$ttkey')");


I am getting an error. Lets say the position of Morning is first and Bye is last. It should update the database accordingly. If there is a new entry, say "phpfreaks" in first position. It should update according.

No comments posted yet

Your Answer:

Login to answer
76 Like 17 Dislike
Previous forums Next forums
Other forums

tag inside php...

Code: <?php
echo "<td width="$columnWidth%" align=&

Why is my row count 0?
Here's the MySQL query i'm running. It basically pulls data from 2 tables based on some data passed.

Day -Date II
[b][url=http://watchlove.michaelkorswallet.cn/fi/]Rolex Yacht - Master II[/url][/b] [b][url=http://w

Moncler Asraon Online - Lascaine Moncler Jackets For Sale
moncler díol
siopa asraon moncler
[b]Lascaine Moncler ar díol[/b][b][url=http://www.da

Parse error: syntax error, unexpected T_ELSEIF in /home/......html/item.php on l
I do not know what is wrong with this. Hope some one can help. I do nto want to post the entire site

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Google+ Indyaspeak @ Pinterest RSS