Return to iWEBTOOL

Go Back   iWEBTOOL Talk > The Web and your Website > Programming > PHP
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
Welcome to iWEBTOOL Talk, where you talk about webmaster-related stuff.
 
Discuss topics which interest you.
With over thousands of threads (topics), we're sure you'll find something that'll interest you.
Ask for help whenever you need it.
We have thousands of members who are available to help you if you need it.
It's absolutely FREE!

 1  Register           2  Browse the board           3  Discuss whatever may interest you!
 


Reply
 
Thread Tools Search this Thread Display Modes
Old 03-10-2008, 11:19 PM   #1
jperezmt
Junior Member
 
jperezmt's Avatar
 
Join Date: Apr 2007
Posts: 92
jperezmt is on a distinguished road
Default Update SQL with PHP Form

I need help!!!

I'm trying to create a blog app and I want to add categories for my blog post. The only thing is when I set up the code, it is not updating the category id.

Here is my code

PHP Code:
<?php

            
/* add the query in order for this to work i.e. qry = SELECT table FROM ....*/

            
$query "SELECT blogid, title, date, blogentry, blog.catid, category.categoryid, category.category FROM blog INNER JOIN category ON blog.catid = category.categoryid ORDER BY blogid DESC LIMIT 1";

            
$result mysql_query($query) or die(mysql_error());

                
$row=mysql_fetch_array($resultMYSQL_ASSOC); 

                
$blogid $row['blogid'];

                
$categoryid $row['categoryid'];
                
                
$catid $row['catid'];

                
$category $row['category'];

                
$text $row['blogentry'];

                
$title $row['title'];

                
$date $row['date'];

                echo 
"<b>" $date "</b><br />\n ";
                
                if (!
$catid == 1) {
                echo 
"Posted in " $category "<br />";
                } else {
                    if (isset(
$submit))  {
                        
$qp1 "UPDATE blog SET catid = '$categoryid' WHERE blogid = '$blogid'";
                        
$resultqp1 mysql_query($qp1) or die("shit it don't work");
                    }
                    
                    
$query "SELECT categoryid, category FROM category WHERE categoryid > 0"
                    
$result mysql_query($query) or die(mysql_error());
                        
$row mysql_fetch_array($resultMYSQL_ASSOC);
                        
$categoryid $row['categoryid'];
                        
$category $row['category'];
                        echo 
"<form action=" $_SERVER['PHP_SELF'] . " method=\"post\">\n";
                        echo 
"<select name=\"category\">\n";
                        echo 
"<option>Change Category</option>";
                        while(
$row mysql_fetch_array($resultMYSQL_ASSOC))
                                                   {
                                                       
$category $row['category'];
                                                       echo 
"<option>" $category "</option>\n";
                                                   }
                        echo 
"</select>\n";
                        echo 
"<input type=\"hidden\" name=\"categoryid\" value=\"$categoryid\" />\n";
                        echo 
"<input type=\"submit\" name=\"submit\" value=\"submit\" />\n";
                        echo 
"</form>\n";
                    
                }

                echo 
"<h3><a href=\"blog.php?id=$blogid\">$title</a></h3><br />\n";

                
// assuming the words are separated by spaces 

                
$text_array explode(' '$text); 

                

                for(
$x 0$x 300$x++){ 

                echo 
$text_array[$x] . ' '

                } 

                echo 
"... <a href=\"blog.php?id=$blogid\">read more</a>";

            
?>

Anybody know what I could be doing wrong?? Any suggestions??
__________________
Build Your Web Presence
jperezmt is offline   Reply With Quote
 
This is an Ad Revenue Sharing forum Place your advert here
SEO Checklist
Get yourself better ranking with
our "Do-it-Yourself" SEO Checklist.
Click Here
Old 04-21-2008, 01:01 PM   #2
littleBird
Smurf
 
littleBird's Avatar
 
Join Date: Apr 2008
Posts: 9
littleBird is on a distinguished road
Send a message via Skype™ to littleBird
Default Re: Update SQL with PHP Form

At a glance the problem would appear to be that you are UPDATEing your blog with the hidden form value $categoryid, which is statically set everytime the FORM is generated. Rather this update should be read from the user selected variable $_POST['category'].

I hope this is of some help...
__________________
http://www.cssdiscussion.com - CSS forum for Newbies & Experts
littleBird is offline   Reply With Quote
 
This is an Ad Revenue Sharing forum Place your advert here
Webmaster Tools Webmaster Tools Click Here
Reply



Quick Reply
Message:

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with PHP Filesystem AssistantX PHP 1 Yesterday 07:15 AM
Help with sql search commands eautocad MySQL 4 05-03-2008 07:31 AM
Looking for PHP+SQL programmer Rickzkm PHP 6 04-29-2007 05:23 AM
Working with PHP offline Seeker81 PHP 7 09-20-2006 07:42 AM


All times are GMT. The time now is 08:14 AM.


Powered by vBulletin v3.6.7 © 2008, Jelsoft Enterprises Ltd. SEO by vBSEO © 2006, Crawlability, Inc.