irkevin Posted October 25, 2007 Share Posted October 25, 2007 Hi all, i have this bunch of codes <?php $page = $_GET['page']; if (isset($page)) { switch ($page) { case 'add': $conn = mysql_connect($server,$dbusername,$dbpassword); mysql_select_db($db_name); if(isset($_POST['submit'])) { // sql to insert an anime title into the database }else { echo "Enter an anime and press the Add button. The anime you entered will display on the Add/Edit Section.<br>"; echo ""; // the code for the form goes there } break; case 'edit': echo "Select an anime to edit<br><br>"; $conn = mysql_connect($server,$dbusername,$dbpassword); mysql_select_db($db_name); $sql = "SELECT * FROM multimedia ORDER BY mult_name"; $result = mysql_query($sql,$conn); while($row = mysql_fetch_array($result)){ $id = $row['mult_id']; $anime = $row['mult_name']; $aid = $_GET['aid']; if(!isset($aid)){ echo "<a href=indexa.php?page=edit&aid={$id}>{$anime}</a>"; echo "<br>"; } } if(isset($aid)){ $conn = mysql_connect($server,$dbusername,$dbpassword); mysql_select_db($db_name); $sql = "SELECT * FROM multi_file WHERE mult_id = $aid"; $result = mysql_query($sql,$conn); $num = mysql_num_rows($result); while($myarray = mysql_fetch_array($result)){ $fid = $myarray['file_id']; $fname = $myarray['file_name']; echo "<a href=indexa.php?page=edit&aid={$aid}&fid={$fid}>$fname</a>"; echo "<br>"; } if(isset($_POST['submit'])){ // the sql query to insert an anime $sql = "INSERT into multi_file VALUES (NULL,'$aid', '" . $_POST['synopsis'] . "', '" . $_POST['file_picture'] . "', '" . $_POST['file_name'] . "', '" . $_POST['file_description'] . "', '" . $_POST['file_link'] . "')"; $result = mysql_query($sql); if($result){ echo "Your Data was inserted sucessfully<br>"; print ("<input type=button value=Back onclick=history.back(-5)>"); } //end of the insert sql }else { echo "";// the form goes there and should not appear in the $filid page } } $filid = $_GET['fid']; if(isset($filid)){ echo "Testing the filid page!!!!! "; // should get only this message and not a form } break; default: echo "This is the home page where you'll have info"; break; } }else { echo "This is the home page where you'll have info<br><br>"; echo "Available animes are :<br><br> "; $conn = mysql_connect($server,$dbusername,$dbpassword); mysql_select_db($db_name); $sql = "SELECT * FROM multimedia ORDER BY mult_name"; $result = mysql_query($sql,$conn); while($row = mysql_fetch_array($result)){ $anime = $row['mult_name']; echo "<ul><li>$anime</li></ul>"; } } ?> And where it insert the anime <if(isset($_POST['submit']))>, it make the sql statement correctly or else it shows the form like it should, but on the next part, <$filid = $_GET['fid']; if(isset($filid)){ echo "Testing the filid page!!!!! "; // should get only this message and not a form }> instead of showing only the message, it showing the form also, how to prevent it from showing the form once again? Would be great if someone can help me with this Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/ Share on other sites More sharing options...
teng84 Posted October 25, 2007 Share Posted October 25, 2007 whats the question ? Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378246 Share on other sites More sharing options...
irkevin Posted October 25, 2007 Author Share Posted October 25, 2007 sorry teng, hihi ! my finger hit the enter button accidentally .. haha!! so can you figure this out ? Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378250 Share on other sites More sharing options...
teng84 Posted October 25, 2007 Share Posted October 25, 2007 men your code is so messy ! and where is the form there? for now i guess you can try exit(); after echo "Testing the filid page!!!!! "; exit(); Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378253 Share on other sites More sharing options...
irkevin Posted October 25, 2007 Author Share Posted October 25, 2007 Nope it's not working.. if i make this if(isset($filid)){ echo "Testing the filid page!!!!! "; // should get only this message and not a form } shouldn't it echo only the message., i don't get it.. Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378258 Share on other sites More sharing options...
darkfreaks Posted October 25, 2007 Share Posted October 25, 2007 die should do the same thing Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378264 Share on other sites More sharing options...
irkevin Posted October 25, 2007 Author Share Posted October 25, 2007 well but it keeps showing the form i use for the insert statement instead of the simple message ! Thats weird ! Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378265 Share on other sites More sharing options...
teng84 Posted October 25, 2007 Share Posted October 25, 2007 where is the form? Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378267 Share on other sites More sharing options...
irkevin Posted October 25, 2007 Author Share Posted October 25, 2007 you mean the code, or you want the link to see it?? Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378269 Share on other sites More sharing options...
teng84 Posted October 25, 2007 Share Posted October 25, 2007 you said you only want to echo the message and not the form but we dont see how you call that form we need to see how you include that form? heres your code this absolutely right if(isset($filid)){ echo "Testing the filid page!!!!! "; // should get only this message and not a form } how do you get that form? is it included or what? Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378271 Share on other sites More sharing options...
irkevin Posted October 25, 2007 Author Share Posted October 25, 2007 if(isset($_POST['submit'])) { // sql to insert an anime title into the database }else { echo "<form method=\"post\"> <table border=\"0\" width=\"350\" cellspacing=\"3\" cellpadding=\"3\" align=\"center\"> <tr> <td>Synopsis</td> <td><textarea name=\"synopsis\" rows=\"5\" cols=\"50\ style=\"width:381px\"></textarea></td> </tr> <tr> <td>File Picture</td> <td><input type=\"text\ name=\"file_picture\" /></td> </tr> <tr> <td>Anime Title</td> <td><input type=\"text\" name=\"file_name\" /></td> </tr> <tr> <td>Anime Description</td> <td><input type=\"text\" name=\"file_description\" /></td> </tr> <tr> <td>File Link</td> <td><input type=\"text\" name=\"file_link\" /></td> </tr> <tr> <td align=\"center\" colspan=\"2\"><input type=\"submit\" value=\"add\" name=\"submit\" /></td> </tr> </table> </form>"; // the code for the form goes there } Do you see whats wrong wiz it? Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378274 Share on other sites More sharing options...
teng84 Posted October 25, 2007 Share Posted October 25, 2007 i see what you want but when do you want to have this form? Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378275 Share on other sites More sharing options...
irkevin Posted October 25, 2007 Author Share Posted October 25, 2007 well i have a list of anime like this bleach death note Devil May Cry Dragon Ball Dragon Ball GT Dragon Ball Z F M Alchemist If i click on suppose, "bleach", i get the episodes listed along with a form on the bottom to insert another episode.. When I click on the episode, i should not get the form again, but only the test message i want to echo "Testing the filid page!!!!! " Right now, i don't know why it is not working... Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378276 Share on other sites More sharing options...
teng84 Posted October 25, 2007 Share Posted October 25, 2007 fisrt !!!! indent your code properly thats very important trust me ok maybe you can do this When I click on the episode, add a query string that will determine that you have click that part then replace your else with something like if (isset($_GET['episode'])){ //show the form } Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378278 Share on other sites More sharing options...
irkevin Posted October 25, 2007 Author Share Posted October 25, 2007 what you mean by adding a query string.. sorry but im quite new to this can you give me a brief example? Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378279 Share on other sites More sharing options...
teng84 Posted October 25, 2007 Share Posted October 25, 2007 if your page is index.php then in your link href = index.php?episode = teng once that link is click your url will look like this www.teng.com/index.php?episode = teng then if (isset($_GET['episode'])){ //show the form } Quote Link to comment https://forums.phpfreaks.com/topic/74808-need-some-help-with-this-code/#findComment-378283 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.