Jump to content

Second query really sorry - putting a checkbox in returned data


Gilly79

Recommended Posts

Hello

 

Sorry peeps another question! Ive been plaing around with this inserting commands to no availe!

 

What I am trying to do is insert a checkbox in a table of returned data from back end php..

 

The table is below with its retruned values - however i want to put a check box in the delete and reply table entries...

 

I have the php to delete and reply so thats not an issue - i wrote it myself (a miracle!!0 but no idea how to get a checkbox in the table s i just press submit and it deletes  the highlighted messages..

 

// see if any rows were returned

if (mysqli_num_rows($result)>0) {

    echo "<table border=1>\n<tr>" .

              "<th>MessageNo</th>" .

              "<th>MessageFrom</th>" .

"<th>MessageTo</th>" .

  "<th>Subject</th>" .

  "<th>Message</th>". 

"<th>Reply</th>".

"<th>Delete</th>";

 

    while ($row = @ mysqli_fetch_array($result)) {

    //while($row = mysql_fetch_row($result)) {

      echo "<tr>";

        echo "<td class=BorderMeRed>".$row["MessageNo"]."</td>";

        echo "<td class=BorderMeRed>".$row["MessageFrom"]."</td>";

echo "<td class=BorderMeRed>".$row["MessageTo"]."</td>";

echo "<td class=BorderMeRed>".$row["Subject"]."</td>";

        echo "<td class=BorderMeRed>".$row["Message"]."</td>";

echo "<td class=BorderMeRed></td>";

        echo "<td class=BorderMeRed></td>";

echo "</tr>

 

Again thank you so much for your help..

 

[attachment deleted by admin]

no its not the html code for a checkbox, its how i put a check box within the same string of returned data from the php query...

 

Can you see how ive got the echo row? well at the returned row id like to put a checkbox at the end so I can mark for delete... however Im just not sure how this is done?

 

Then when I have the checkbox for delete I have a submit button at the bottom of the code which will activate deleting ther relevant row...

 

Is that making sence? sorry explaining is never my forte - which sucks when im asking for help!

echo "<input type=\"checkbox\" name=\"delete[]\" value=\"$row['MessageNo']\" />";

echo "<td class=BorderMeRed>".$row["MessageNo"]."</td>";

 

_$POST['delete'] will be an array of all the MessageNO that were checked

 

 

HTH

Teamatomic

Hiya - thanks for the reply - I came up with something simlar (not quite like that) but it does not compute in my code...

 

the MessageNo come up highlighted as there is an error - Im really sorRy but im strugging with this - Ive just copied the code accross... and put it at the end of the the echo table entry and its saying there is an error...

 

Its the parms and the coding structure i cant seem to grasp...

 

Ive attachted the full file - any help appreciated

 

Sorry teamatomic im being a tard today!

 

 

 

 

[attachment deleted by admin]

got it working.... its like so if anyone is intrested...

 

 

// see if any rows were returned

if (mysqli_num_rows($result)>0) {

    echo "<table border=1>\n<tr>" .

              "<th>MessageNo</th>" .

              "<th>MessageFrom</th>" .

"<th>MessageTo</th>" .

  "<th>Subject</th>" .

  "<th>Message</th>". 

"<th>Reply</th>".

"<th>Delete</th>";

 

    while ($row = @ mysqli_fetch_array($result)) {

    //while($row = mysql_fetch_row($result)) {

      echo "<tr>";

        echo "<td >".$row["MessageNo"]."</td>";

        echo "<td>".$row["MessageFrom"]."</td>";

echo "<td>".$row["MessageTo"]."</td>";

echo "<td>".$row["Subject"]."</td>";

        echo "<td>".$row["Message"]."</td>";

echo "<td><input type=\"checkbox\" name=\"delete[]\" value=".$row["MessageNo"]." /></td>";

echo "</tr>";

 

thanks for all your help

HIYA

 

Ive got my checkboxes working in full effect - however I dont seem to be getting the var passed from the ttable to my php page....

 

My php page looks right as it works elsewhere - but the delete checkbox doesn't seem to pass the var on the submit command??

 

is this

 

echo "<td><input type=\"checkbox\" name=\"reply[]\" value=".$row["MessageNo"]." /></td>";

 

And i have the $delete = $POST['delete'];  IN my php page - any idea why it wont work??

 

confused.com! ha

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.