genzedu777 Posted October 10, 2010 Share Posted October 10, 2010 Hi, Currently the line which I have highlighted in red, was actually a jquery command, which prompt user if there is no selection, it was originally meant to be in a html code, but I have added into a php coding, and after I have run it, when there is no selection, the system will not prompt the user anymore, it seems like by putting it into the PHP coding, it overwrites the jquery command. Any advice to this? Thanks <?php $dbc = mysqli_connect('localhost', '***', '***', '***') or die(mysql_error()); $query = ("SELECT * FROM tutor_preferred_district ORDER BY district_id ASC"); $sql = mysqli_query($dbc, $query) or die(mysql_error()); while($data = mysqli_fetch_array($sql)) { echo '<input name="district" type="checkbox" id="'.$data['district_id'].'" value="'.$data['district_id'].' class="required" title="Please check at least 1 location."> <label for="'.$data['district_id'].'">'.$data['district_name'].'</label>'; } ?> <html> <input name="district" type="checkbox" id="1" value="1" class="required" title="Please check at least 1 location."> <label for="1">Yishun</label> </html> Link to comment https://forums.phpfreaks.com/topic/215553-jquery-command-overwritten-after-adding-php-codes/ Share on other sites More sharing options...
BlueSkyIS Posted October 10, 2010 Share Posted October 10, 2010 Missing a double-quote in the HTML tag, plus a single quote at the end of the echo echo '<input name="district" type="checkbox" id="'.$data['district_id'].'" value="'.$data['district_id'].'" class="required" title="Please check at least 1 location.">'; Link to comment https://forums.phpfreaks.com/topic/215553-jquery-command-overwritten-after-adding-php-codes/#findComment-1120819 Share on other sites More sharing options...
monkeytooth Posted October 10, 2010 Share Posted October 10, 2010 php and JavaScript (jQuery being your choice of JavaScript framework in this case) do no interact. They are completely independent of one another, you can not call a function from a JavaScript element with PHP and vise versa. PHP renders server side and displayes to the client the finished product of that rendition. JavaScript can take that finished rendition and remaster it, anything from the alerts, to altering the physical appearance. Also the bit in red is technically more in tune with CSS than it is jQuery.. but thats the part of JavaScript/jQuery that manipulates the front end after its been rendered. I don't recall ever seeing an input checkbox with a "Title" either. Link to comment https://forums.phpfreaks.com/topic/215553-jquery-command-overwritten-after-adding-php-codes/#findComment-1120821 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.