Jump to content

PHP - Help...


iamyespee

Recommended Posts

Hi everybody,

 

Am writing one small script to upload and share the file to specific users..

While writing this script, I need to display the user name as a value for html checkbox value attribute...

Below is the code (inbox.php)

 

<?php

mysql_connect("localhost", "root", "") or die(mysql_error());

mysql_select_db("universys") or die(mysql_error());

$check = mysql_query("SELECT * FROM users") or die(mysql_error());

 

 

echo "Welcome ". $_COOKIE['ID_my_site'] ."!!";

echo "<HTML>

      <head>

      <link rel='stylesheet' type='text/css' href='style.css'>

      </head>

      <body>

      <table width = '75%' border = '0' cellspacing = '2' cellpadding = '2' align = 'center' style = 'border-style:solid;border-width:1px;border-color:#4c4c4c;'>

 

  <tr bgcolor = '#EEEEEB'  align = 'center' valign = 'middle'>

  <td colspan = '2'>

  <h2> Universys FTP </h2>

  </td>

  </tr>

 

  <tr>

  <td><a class = 'toplink' href = './upload.php'>Upload Files</a> | <a class = 'toplink' href = './download.php'>Download Files</a> | <a class = 'toplink' href = './logout.php'>Log Out</a></td>

  </tr>

 

  <tr><td height = '25'></td></tr>

 

 

  <tr><td>

  <table width = '50%' border = '0' cellspacing = '0' cellpadding = '0' align = 'center' style = 'border-style:solid;border-width:1px;border-color:#4c4c4c;padding:15px;'>

  <tr align = 'left'><td><h3> Upload Files </h3></td></tr>

        <tr><td height = '10'></td></tr>

        <tr align = 'center'> <td> <input type = 'file' name = 'fileupload'> </td> </tr>

      <tr> <td height = '20'> </td> </tr>

      <tr align = 'center'> <td> <input class = 'button' type = 'button' name = 'upload' value = 'Upload'> </td> </tr>

</table>

  <h3 style = 'padding-left:185px;'>Share to :</h3>

  </td></tr>

  </table>

  </body>

  </html>

" ;

?>

 

<html>

<table width = '100%' border = '0'>

<tr>

<td>

<?php

while($row = mysql_fetch_array($check))

{

$name = $row['username'];

echo "<input type = 'checkbox' name ='users' value = $name>";

}

?>

 

</td>

</tr>

</table>

</html>

 

But the value is not displaying.. Only empty checkbox is displaying...

I think, I needs to correct the while loop...  Please help me to fix this issue...

 

Thanks...

Link to comment
https://forums.phpfreaks.com/topic/100608-php-help/
Share on other sites

<?php
         while($row = mysql_fetch_array($check))
         {
         $name = $row['username'];
         echo "<input type = 'checkbox' name='users' value='". $name ."'>". $name ."<br />";
         }
?>

that should do the trick!

also, the value of a input checkbox is hidden, to display what the checkbox is selecting you put your text on which ever side of the checkbox you feel necessary, simple HTML right there.

 

-Zack

Link to comment
https://forums.phpfreaks.com/topic/100608-php-help/#findComment-514556
Share on other sites

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.