Jump to content

Not displaying first row


rofl90

Recommended Posts

It should display all the navigation links, but it only displays the ones after the first, I use $navnum = 1; on each while I, +1.

 

sitenavigation.php:

<?php
$sql = 'SELECT * FROM sitenav';
$resulta = mysql_query($sql);
$my_array = mysql_fetch_array($resulta);
if(isset($_GET['action']) && $_GET['action'] == "addnav") {
if(isset($_POST['submitnav'])) {
$linkname = $_POST['linkname'];
mysql_query("INSERT INTO sitenav(title) VALUES('$linkname')") or die(mysql_error());
echo "Link Added! <a href='sitenavigation.php'>Click here</a> to go back.";
}
else {
?>
	<form id="nav" name="nav" method="post" action="?action=addnav">
	<fieldset><legend>Add Nav Object</legend>
        <input type="text" name="linkname" id="title" />        		
	</fieldset>
        </fieldset><fieldset><legend>Finished?</legend>
        <input type="submit" name="submitnav" id="add" value="Update" />
	</fieldset>
	</form>
<?php
}
} 
else {
echo "<input type=\"button\" name=\"new\" value=\"Add Nav\" onclick=\"parent.location='sitenavigation.php?action=addnav'\"  />";
	$navnum = '0';
	while($naviga = mysql_fetch_array($resulta)) {
	$navnum = $navnum + 1;
	if($_POST[''.$navnum.'']) {
	$name = $_POST[''.$navnum.'a'];
	$sqlupdate = "UPDATE sitenav SET title='$name' WHERE id='$navnum'";
	mysql_query($sqlupdate);
	echo "Updated Navigation!";
	} else {
	?>
	<form id="nav" name="nav" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
	<fieldset><legend>Link <?php echo $navnum; ?></legend>
        <input type="text" name="<?php echo $navnum."a"; ?>" value="<?php echo $naviga['title']; ?>" id="title" />        		
	</fieldset>
        </fieldset><fieldset><legend>Finished?</legend>
        <input type="submit" name="<?php echo $navnum; ?>" id="add" value="Update" />
	</fieldset>
	</form><?php } } } ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.