Current location: Hot Scripts Forums » General Web Coding » JavaScript » Problem wiring my buttons dynamic like


Problem wiring my buttons dynamic like

Reply
  #1 (permalink)  
Old 08-26-10, 07:56 PM
Golith Golith is offline
Newbie Coder
 
Join Date: Jun 2010
Posts: 87
Thanks: 6
Thanked 1 Time in 1 Post
Problem wiring my buttons dynamic like

Hi all,

not strong with JS so i hope there is someone out there who can help

here is the code

PHP Code:

function DumpSQL( $result ){

     if($result == 0) 
    { 
        echo "<b>Error ".mysql_errno().": ".mysql_error()."</b>"; 
    } 
    elseif (@mysql_num_rows($result) == 0) 
    { 
        echo("<b>Query completed. No results returned.</b><br>"); 
    } 
    else 
    { 
        echo "<table border='1'> 
            <thead> 
            <tr><th>[Item]</th>"; 
        for($i = 0;$i < mysql_num_fields($result);$i++) 
        { 
            echo "<th>" . mysql_field_name($result, $i) . "</th>"; 
        }
        echo"<th> Active </th>";
        echo "<th> Update </th>";
        echo "<th> Delete </th>"; 
        echo "  </tr> 
            </thead> 
            <tbody>"; 
        for ($i = 0; $i < mysql_num_rows($result); $i++) 
        { 
            echo "<tr><td>[$i]</td>"; 
            $row = mysql_fetch_row($result); 
            for($j = 0;$j < mysql_num_fields($result);$j++)  
            {
            if (stristr($row[$j],"http")){
                 echo("<td> <a href=" . $row[$j] . "> " . $row[$j] . "</a></td>");
                }
                else{
                    echo("<td>" . $row[$j] . "</td>"); 
                }
            } 
            // check if active or not then place right icon
            echo "<td align=center>" ?> <img src="images/green_tick.png" width="30" height="30"><img src="images/red_cross.jpg" width="30" height="30"> <?php "</td>";            
            echo 
"<td>" ?> <form><input type = "submit" name = "update" value = "update"></form> <?php "</td>";
            echo 
"<td>" ?> <form><input type = "submit" name = "del_file" value = "del_file" ></form> <?php "</td>";
                        echo 
"<td>" ?> <form><input type = "submit" name = "del_row" value = "del_row" ></form> <?php "</td>";
            echo 
"</tr>"
        } 
        echo 
"</tbody> 
        </table>"

    }  
//end else
I am trying to make the last 3 buttons with name update and del_* do stuff.
Update needs to update a file pulling xml of the web.
Del_file need to delere a file from my server.
Del_row needs to delete the entry from the database .

I can do these things manually but want to wire the buttons to do the job

PHP Code:

function copyxml($file1,$file2){ 

          
$contentx =@file_get_contents($file1); 
          
$openedfile fopen($file2"w"); 
          
fwrite($openedfile$contentx); 
          
fclose($openedfile); 
              if (
$contentx === FALSE) { 
                
$status=false
            }
            else 
$status=true
                    
           if (!
copyxml($file1$file2)){
    echo 
"failed to copy $file1...\n";
}
else{
echo 
" copied $file1 successfully!!!...\n";

for example this function copies stuff from the web
Anyone got a suggestion ??
__________________
Its My script and I'll if I want to
www.cictradinggroup.com.au
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-13-10, 04:15 PM
jsNewbie jsNewbie is offline
New Member
 
Join Date: Sep 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Golith,

Do you need to accomplish this without a page reload? If not, why not just use php to execute like below?

I have edited only the form part of your code below:
// check if active or not then place right icon
echo " <form name=form method=post action=[filename].php>\n";
echo "<td align=center>" ?> <img src="http://www.hotscripts.com/forums/images/green_tick.png" width="30" height="30"><img src="http://www.hotscripts.com/forums/images/red_cross.jpg" width="30" height="30"> <?php "</td>";
echo "<td><input type = submit name = update value = update></td>";
echo "<td> <form><input type = submit name = del_file value = del_file ></td>";
echo "<td><input type = submit name = del_row value = del_row ></td>";
echo "</tr>";
echo "</form>\n";

Then, above the opening html tag:

if(!empty($_POST[update])) {
//perform relevant update
}

if(!empty($_POST[del_file])) {
//delete file from server
}

if(!empty($_POST[del_row])) {
//delete the row from the database
}

Good luck!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-14-10, 08:57 PM
Golith Golith is offline
Newbie Coder
 
Join Date: Jun 2010
Posts: 87
Thanks: 6
Thanked 1 Time in 1 Post
thanx will give it a go ..
__________________
Its My script and I'll if I want to
www.cictradinggroup.com.au
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Many buttons problem sunanurag PHP 3 09-05-09 06:08 AM
Problem retrieving data from dynamic input field li_ping Everything Java 8 01-02-07 10:34 AM
Caching Problem w/ Dynamic Pages Monarch JavaScript 0 08-09-05 09:32 AM
problem with dynamic table noviceforever HTML/XHTML/XML 1 07-31-04 10:09 PM
problem with dynamic table noviceforever JavaScript 3 07-10-04 11:16 AM


All times are GMT -5. The time now is 01:28 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.