Jump to content

custom Navbar settings


papillonstudios

Recommended Posts

i have been working at this for a while now i want create a form that will display 2 fields for each row in the database.

 

Its for the navbar in my cms. there is a max of 7 links, so thats no more than 14 fields. but the problem im having is getting the MySQL Query to update the correct link. Currently the mysql query only sees the last link which is contact us.

 

how do i make it submit all the fields at once, while keeping the form dynamic.

 

*remember i want to update rows not columns

 

heres the code i currently have

 

<?php
//Checks to see if theyre allowed to edit their profile
if ($uCan['admin']) {
    //Double security incase the admin hasn't set a guest membergroup
    if ($uId) {

        //If the form hasn't been submitted, show it.
        if (!$_POST['update']) {
?>
<form method="post">
    <table width="75%">
        <?php
        //Selecting the News From trhe Table news
        $query = "SELECT * FROM `nav`";
        $result = mysql_query($query) or die(mysql_error());

        while($row = mysql_fetch_assoc($result)) {
            echo '<tr><td><input type="text" size="25" maxlength="200" name="linkname"' . $row['id'] . '" value="' . $row ['linkname'] .'"></td><td> <input type="text" size="25" maxlength="200" name="url"' . $row['id'] . '"" value="' . $row ['url'] .'"> </td><td><input type="submit" name="update" value="Change Link "></td></tr>';
        }  
        ?>
    </table>
</form>


<?php

        }
        //Or else it has been submitted...
        else {
            //Get information from the forms secure it all.
            
            $linkname = secure($_POST['linkname']);
		$url = secure($_POST['url']);

		//$update = mysql_query("UPDATE nav SET linkname = '$linkname' , url = '$url' WHERE id = " . $_GET['id'] . ";");
		echo '<p>' . $linkname. '</p>';
				  echo '<p>' . $url . '</p>';


            if ($update)
                echo 'Link ' . $row['id'] . ' had been updated, click <a href="index.php?action=upnav">here</a> ';

            else
               echo "Error message = ".mysql_error(); 

            //A query to update everything


	}
}
}


?>

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/167866-custom-navbar-settings/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.