funbinod Posted April 16, 2014 Share Posted April 16, 2014 got difficulty on converting mysql to mysqli to these line <?php// select table$query = "SELECT * FROM vender";$result = mysql_query($query);if (!$result) die("Unable to select database: " . mysqli_error());// fetch data$rows = mysql_num_rows($result);for ($n = 0 ; $n < $rows ; ++$n){ echo "<option>" . mysql_result($result,$n,'vname') . "</option>" ;}?> please guide.... Link to comment Share on other sites More sharing options...
thescientist Posted April 16, 2014 Share Posted April 16, 2014 what's the problem? have you tried looking up how to use mysqli? most of the function names are the same, but maybe the parameters are different http://www.php.net/manual/en/book.mysqli.php http://www.w3schools.com/php/php_ref_mysqli.asp however, until you use just one, you are going to have issues either way as you can't mix them like that. Link to comment Share on other sites More sharing options...
funbinod Posted April 17, 2014 Author Share Posted April 17, 2014 i read the topics & documents on w3schools and php.net. but i got difficulty on understanding mysqli_result or i dunno i did this <?php// select table$query = "SELECT * FROM vender";$result = mysqli_query($connect, $query);if (!$result) die("Unable to select database: " . mysqli_error());// fetch data$rows = mysqli_num_rows($result);for ($n = 0 ; $n < $rows ; ++$n){ echo "<option>" . mysqli_result($result, $n, 'vname') . "</option>" ;}?> but malfunctioned. Link to comment Share on other sites More sharing options...
thescientist Posted April 17, 2014 Share Posted April 17, 2014 how so? what does malfunction mean in this case? what's the value of $rows? Does the loop work and iterate through? is your column name correct? you echo <option> tags but no <select> tag? Link to comment Share on other sites More sharing options...
funbinod Posted April 18, 2014 Author Share Posted April 18, 2014 it works fine with "mysql". it didnt work converting to "mysqli". nothing else are changed. opening and closing tags of SELECT are before and after this PHP. like -- <select name="vname" id="vname"><option></option><?php// code goes here?></select> value of $rows is list of names from 'vname' column and yes the column name is correct.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now