rofl90 Posted March 29, 2008 Share Posted March 29, 2008 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 More sharing options...
sasa Posted March 29, 2008 Share Posted March 29, 2008 remove line 4 $my_array = mysql_fetch_array($resulta); Link to comment https://forums.phpfreaks.com/topic/98505-not-displaying-first-row/#findComment-504115 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.