iamyespee Posted April 11, 2008 Share Posted April 11, 2008 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 More sharing options...
zenag Posted April 11, 2008 Share Posted April 11, 2008 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 https://forums.phpfreaks.com/topic/100608-php-help/#findComment-514543 Share on other sites More sharing options...
conker87 Posted April 11, 2008 Share Posted April 11, 2008 You probably should enclose the value in ' ' Link to comment https://forums.phpfreaks.com/topic/100608-php-help/#findComment-514551 Share on other sites More sharing options...
quickstopman Posted April 11, 2008 Share Posted April 11, 2008 <?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 More sharing options...
iamyespee Posted April 11, 2008 Author Share Posted April 11, 2008 Thank you for your replies... But I need to get the value of the checkboxes in the other part of the program.. So I need to assign the users to value of the checkboxes... Link to comment https://forums.phpfreaks.com/topic/100608-php-help/#findComment-514564 Share on other sites More sharing options...
quickstopman Posted April 11, 2008 Share Posted April 11, 2008 yes so have you tried my code? that should do the job you need it too do! -Zack Link to comment https://forums.phpfreaks.com/topic/100608-php-help/#findComment-514567 Share on other sites More sharing options...
conker87 Posted April 11, 2008 Share Posted April 11, 2008 You don't need to break the echo if you're using " quotes Link to comment https://forums.phpfreaks.com/topic/100608-php-help/#findComment-514573 Share on other sites More sharing options...
quickstopman Posted April 11, 2008 Share Posted April 11, 2008 the thing about saying that is that you DON'T have too.. but i did anyway lol Link to comment https://forums.phpfreaks.com/topic/100608-php-help/#findComment-514574 Share on other sites More sharing options...
conker87 Posted April 11, 2008 Share Posted April 11, 2008 the thing about saying that is that you DON'T have too.. but i did anyway lol Which is exactly what I said, just worded differently. 'lol' Link to comment https://forums.phpfreaks.com/topic/100608-php-help/#findComment-514587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.