Jump to content

Displaying values of database


javiqq

Recommended Posts

I'm newbie to PHP and trying my best to learn on my own and take some courses online but currently I'm working on a website that stores information about students and their status. I need to create a link that goes to a PHP page with a script that generate the list of students with the ability to delete them if necessary.

 

I've been trying to achieve this all morning by trying to first get the list generated but with no positive results.

 

??? ??? ???can anyone help??

 

This is the code I currently have (I don't even know if it's really doing what I'm aiming for):

<?php

$query = "SELECT re_first_name, re_last_name FROM rebels WHERE re_status_id_fk =3";

$result = mysql_query($query);

 

if($_POST['list=1']){

while($re_first_name, $re_last_name) = $row = mysql_fetch_assoc($result) {

echo "Name: ".$re_first_name, $re_last_name;

}

}else{

echo "The script isn't working properly";

}

?>

 

The link to the page with the code above looks like this:

a href="delete_graduate_students.php?list=1"

 

Can anyone help please???  ??? ??? ???

 

Link to comment
Share on other sites

You should use something like:

<?php
$query = "SELECT re_first_name, re_last_name FROM rebels WHERE re_status_id_fk =3";
$result = mysql_query($query);

if($_POST['list=1'])
{
   while($row = mysql_fetch_assoc($result) 
  {
      echo "Name: ".$row[re_first_name]." ". $row[re_last_name]." ";
  }
}
else{
      echo "The script isn't working properly";
}
?>

Link to comment
Share on other sites

I think that something like the following should work(NOT TESTED):

<?php
$query = "SELECT re_first_name, re_last_name FROM rebels WHERE re_status_id_fk =3";
$result = mysql_query($query);

if($_POST['list=1'])
{
   echo "Names: ";
     echo"<textarea name='names' cols='' rows=''>";
   while($row = mysql_fetch_assoc($result) 
  {
      
    echo " ".$row[re_first_name]." ". $row[re_last_name]." ";
  }
echo"</textarea>";
}
else{
      echo "The script isn't working properly";
}
?>

 

Sorry for the delay ;)

Link to comment
Share on other sites

Solon don't worry about the delay. I appreciate the time you're taking to help me. Thank you very much.

 

Unfortunately the code you posted didn't work.

 

I tried the following but it didn't work either: :-\

<?php

$query = "SELECT re_first_name, re_last_name FROM rebels WHERE re_status_id_fk =3";

$result = mysql_query($query);

 

if($list=1){

while($row = mysql_fetch_assoc($result))

echo " ".$row[re_first_name]." ". $row[re_last_name]." ";

}

}else{

      echo "The script isn't working properly";

}

?>

 

<form action="delete_selected_user.php" method="post" enctype="multipart/form-data">

<textarea cols="80" rows="7" name="list_rebels" wrap="virtual"><?php print $row[re_first_name]; print $row[re_last_name];?></textarea>

<input type="submit" value="Delete selected users">

</form>

 

 

Link to comment
Share on other sites

Someone in the school will be incharge of deleting some, if not all, students that graduated highschool. The sql query and php script is bringing up the list of those graduates fine, however the list is way to long. To be efficient I'm trying to make that list populate inside a textarea field instead.

 

Also the person incharge should have the ability to select from the list inside the textarea the student(s) they want to delete.

Link to comment
Share on other sites

Ok then try this one it works on my computer.

 

<?php
$query = "SELECT re_first_name, re_last_name FROM rebels WHERE re_status_id_fk =3";
$result = mysql_query($query);

if($list=1){
   
   echo "Names: ";
    echo"<form action='' method='post'><select name='select'size='15' multiple";
   while($row = mysql_fetch_assoc($result))
   {  
    echo" ";  
    echo "<option value='{$row['re_last_name']}'>".{$row['re_last_name']}." " .{$row['re_first_name']}."</option></form>";
  }

echo "</select>";
}
else{
      echo "The script isn't working properly";
}
?>

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.