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
Share on other sites

just echo $name near checkbox


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

Link to comment
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
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.