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
https://forums.phpfreaks.com/topic/98505-not-displaying-first-row/
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.