Jump to content

Need some help with this code


irkevin

Recommended Posts

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

Link to comment
Share on other sites

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? ;D

Link to comment
Share on other sites

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?  :-[

Link to comment
Share on other sites

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

Link to comment
Share on other sites

fisrt !!!! indent your code properly thats very important trust me  ;D

 

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

}

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.