GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 25-Nov-2006, 06:46
Richardknox Richardknox is offline
Junior Member
 
Join Date: Nov 2006
Location: Michigan
Posts: 83
Richardknox is on a distinguished road

Trouble transfer data between tables


I am attempting to transfer data between two tables. The first table has links, descriptions, who added it, the date added, and so forth. I am sorting this table in a descending order by the added date. I want this so that I can have a seperate table for the 10 newest addition to my site. I am attempting to place the sorted information into a second table.
I have placed a few echo within this script, just to allow me to see that the data is being retrived in a sorted order.

PHP Code:

<?
include "db_connection.php";   //Includes mysql connection information
?>
<?php
//Connect To Database

$dbname="wcdatabase";

// setting up the database link
$dblink = mysql_connect($dbhostname,$dbusername, $dbpassword) OR DIE ("Unable to connect to database! Please try again later.");

mysql_select_db($dbname, $dblink);

$id = 1;

// setting up the database query 
$query1 = "SELECT * FROM wcdatabase ORDER by addeddate DESC LIMIT 10";

// querying the database
$result1 = mysql_query($query,$dblink);


    
     echo "<table>";
     echo "<tr><td><b>Name: </b><td><b>ID#</b><td><b>Added Date:</b></tr>";
     
        while($row = mysql_fetch_array($result1))
    {
    
       echo "<tr><td>";
       echo $row["camname"];
       echo "<td>";
       echo $row["id"];
       echo "<td>";
       echo $row["addeddate"];
       echo "<td>";
       
    $ttcamid = $row["id"];
    $ttcamname = $row["camname"];
    $ttaddeddate = $row["addeddate"];
    
$query2 = "UPDATE wctopten SET ttcamname = "$ttcamname", ttaddeddate = "$ttaddeddate", ttcamid = "ttcamid" where ttid = $id";
$result2 = mysql_query($query2,$dblink);

        echo "<td>";
        echo $ttcamname;
        echo "<td>";
        echo $ttaddeddate;
        echo "<td>";
        echo $ttcamid;
        echo "<td><td>";
        echo $id;
        echo "<td>";

// increment the database
 $id++;

    }
    echo "</table>";

?>


Thanks,
Richard
  #2  
Old 26-Nov-2006, 06:59
Richardknox Richardknox is offline
Junior Member
 
Join Date: Nov 2006
Location: Michigan
Posts: 83
Richardknox is on a distinguished road

Re: Trouble transfer data between tables


I have found the errors in my script. Thanks
 
 

Recent GIDBlog2nd Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 13:12
Selling Server darkneal128 Managed / Dedicated Servers 4 28-Mar-2006 17:01
Strange C++ code memory leakage problem gaoanyu CPP / C++ Forum 7 04-Nov-2005 08:09
Pulldown menu with data from 2 tables or 1 with an ENUM choice? mytwocents MySQL / PHP Forum 1 10-Aug-2004 16:30
[CONTEST?]Data Structure Test dsmith C Programming Language 2 06-Jun-2004 15:13

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:33.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.