Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

[SOLVED] Reset MySQL pointer

Codes here !

Moderators: macek, egami, gesf

[SOLVED] Reset MySQL pointer

Postby aymanoz1 » Wed Jun 25, 2014 9:58 pm

I wont to use 2 select with same table , I try to use mysql_data_seek($result,0); function but its not working :-x
the first select its OK but the second on is not OK
Please if some one can help me .....


Code: Select all
<?php // Make a MySQL Connection
$condb=mysqli_connect("localhost","user","pass","database");
$result = mysqli_query($condb,"SELECT * FROM man WHERE Last name LIKE 'johnson'");?>
<select >
   <?php // This select working fine
      while($row = mysqli_fetch_array($result)) {
         echo "<option value='".$row['ManID']."'>".$row['name']."</option> ";} ?>
</select>
<select >
   <?php // This select is not working
      mysql_data_seek($result,0);
      while($row = mysqli_fetch_array($result)) {
         echo "<option value='".$row['ManID']."'>".$row['name']."</option> ";} ?>
</select>
Last edited by aymanoz1 on Fri Jun 27, 2014 3:43 pm, edited 1 time in total.
aymanoz1
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jun 25, 2014 8:25 am

Re: Reset MySQL pointer

Postby aymanoz1 » Fri Jun 27, 2014 3:42 pm

I SOLVED :D

I keep try to do any thing and just I try to make SQL again

Code: Select all
<?php // Make a MySQL Connection
$condb=mysqli_connect("localhost","user","pass","database");
$result = mysqli_query($condb,"SELECT * FROM man WHERE Last name LIKE 'johnson'");?>
<select >
   <?php // This select working fine
      while($row = mysqli_fetch_array($result)) {
         echo "<option value='".$row['ManID']."'>".$row['name']."</option> ";} ?>
</select>
<select >
   <?php // This select is not working
      mysql_data_seek($result,0);
$result2 = mysqli_query($condb,"SELECT * FROM man WHERE Last name LIKE 'johnson'");
      while($row2 = mysqli_fetch_array($result2)) {
         echo "<option value='".$row2['ManID']."'>".$row2['name']."</option> ";} ?>
</select>

aymanoz1
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jun 25, 2014 8:25 am


Return to mySQL & php coding

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.