Ivan007 Posted January 14, 2023 Share Posted January 14, 2023 I want to display data in my table tbljobcategory but for example , if the return data is Infomation and Technology it is only returning Infomation... <?php $stmt = $pdo->prepare("select * from tbljobcategory where category_id=:catid"); $stmt -> execute(array(":catid"=>$_GET["catid"])); $rows = $stmt ->fetch(PDO::FETCH_ASSOC); $CategoryName = htmlspecialchars($rows["Category"]); ?> <div class="card text-center form-add" style="width:35%;"> <div class="card-header"> Edit Job Category </div> <div class="card-body"> <form method="post" action=""> <div class="mb-3"> <label for="exampleFormControlInput1" class="form-label">Current Job Category</label> <input class="form-control" type="text" value=<?php echo "$CategoryName " ;?> disabled readonly> </div> <div class="mb-3"> <label for="exampleFormControlTextarea1" class="form-label">New Job Category</label> <input class="form-control" type="text" name="NCategory" placeholder="New Job Category" aria-label="default input example"> </div> <button type="submit" name="btn-update" class="btn btn-primary">Save Changes</button> <button type="submit" name="btn-cancel" class="btn btn-secondary">Cancel</button> </div> </form> Quote Link to comment https://forums.phpfreaks.com/topic/315799-mysql-select-statement-is-not-taking-space-in-consideration/ Share on other sites More sharing options...
Solution kicken Posted January 14, 2023 Solution Share Posted January 14, 2023 4 hours ago, Ivan007 said: <input class="form-control" type="text" value=<?php echo "$CategoryName " ;?> disabled readonly> Think about how that will get rendered after the PHP code is processed. You'll have: <input class="form-control" type="text" value=Information and Technology disabled readonly> You've set the value to just Information. The words and and Technology become unknown attributes. You need to put quotes around the value attribute content if you want to be able to use spaces. Quote Link to comment https://forums.phpfreaks.com/topic/315799-mysql-select-statement-is-not-taking-space-in-consideration/#findComment-1604656 Share on other sites More sharing options...
Ivan007 Posted January 14, 2023 Author Share Posted January 14, 2023 (edited) Edited January 14, 2023 by Ivan007 Quote Link to comment https://forums.phpfreaks.com/topic/315799-mysql-select-statement-is-not-taking-space-in-consideration/#findComment-1604658 Share on other sites More sharing options...
Barand Posted January 14, 2023 Share Posted January 14, 2023 If you look at the html source you will see that it is the same as before... <input class="form-control" type="text" value=Information and Technology disabled readonly> It needs to be <input class="form-control" type="text" value="Information and Technology" disabled readonly> ^ ^ The php needs to be <?php echo '<input class="form-control" type="text" value="'.$CategoryName.'" disabled readonly>'; ?> or, using a double-quoted string <?php echo "<input class='form-control' type='text' value=\"$CategoryName\" disabled readonly>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/315799-mysql-select-statement-is-not-taking-space-in-consideration/#findComment-1604659 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.