SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: code problem

  1. #1
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    code problem

    i have problem wz zs ,, i want to make employer be able to post jobs and no. of its posts be incremented within his account. post no. has DB table called pc and number of postings called pn. pc table has 3 fields id, user, pn.
    $kk=$session['user'];
    $result2 = mysql_query("SELECT * FROM pc");
    while($row = mysql_fetch_array($result2))
    {
    if($row['user']==$kk)
    {
    $pn=$row['pn'];
    $pn = $pn++;
    $sql2="UPDATE pc SET pn='$_POST[pn]'WHERE user='$kk'";
    $sql="INSERT INTO pc VALUES ('$pn');
    mysql_query($sql2);


    }
    }

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $kk=$session['user'];
    $result2 mysql_query("SELECT * FROM pc");
    while(
    $row mysql_fetch_array($result2))
    {
    if(
    $row['user']==$kk)
    {
    $pn=$row['pn'];
    $pn += 1;
    $sql2="UPDATE pc SET pn=$pn WHERE user='$kk'";
    mysql_query($sql2);


    }

    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  3. #3
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok but how to insert this incremented pn in table pc of database

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code php:
    $user=mysql_real_escape_string($session['user']);
    $sql="UPDATE pc SET pn=pn+1 WHERE user='$user'";
    mysql_query($sql);
    Saul

  5. #5
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Run that update query. sql2 ?
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •