i want to replace this array in this javascript code to data from the database Book_Image_Sources=new Array( "images/1199696066.jpg","", "images/1199710328.jpg","", "images/1199772425.jpg","", "images/1199772431.jpg","", "images/1199772448.jpg","", "images/1199772904.jpg","", "images/1199772920.jpg","", "images/1199773091.jpg","", "images/1199797162.jpg","", "images/1199797196.jpg","", "images/1199797235.jpg","", "images/1199797258.jpg","", "images/3.jpg","" // NOTE No comma after last line ); PHP: to replace it to $query=mysqli_query($conn,"select client_images_fotos from client_images"); $records=mysqli_fetch_array($query); PHP: i tried to do it like that but it didnt work <?php do { ?> Book_Image_Sources= <?php echo $row_Recordset1['client_images_fotos']; ?> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> PHP:
You need to do it like, $query=mysqli_query($conn,"select client_images_fotos from client_images"); $total=mysqli_num_rows($query); $i=0; while($i<$total) { echo "Book_Image_Sources= ".mysql_result($query, $i, 'client_images_fotos'); $i++; } PHP: Havent tested should work
noooo it didnt work <?php $conn=mysql_connect("localhost","epicalex","10203040"); mysql_select_db("mystiq"); $query=mysql_query("select client_images_fotos from client_images"); if(!$query){echo mysql_error();}else{echo "yes";} $total=mysql_num_rows($query); echo $total; $i=0; ?> <!--CMBookFlipHS--> <script type="text/javascript"> /*********************************************** * Book Flip slideshow script- © Ger Versluis 2003 * Permission granted to DynamicDrive.com to feature script * This notice must stay intact for use * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ // 7 variables to control behavior var Book_Image_Width=300; var Book_Image_Height=300; var Book_Border=true; var Book_Border_Color="black"; var Book_Speed=15; var Book_NextPage_Delay=2*1000; //1 second=1000 var Book_Vertical_Turn=0; // array to specify images and optional links. At least 4 // If Link is not needed keep it "" <?php while($i<$total) { echo "Book_Image_Sources= ".mysql_result($query, $i, 'client_images_fotos'); $i++; } ?> PHP:
it ecgo the results when i put it in the top under the select query and gave me but when i put it inside the javascript it didnt echo anything
i'm not sure if i understood what you exactly want to do but this might help: <?php $conn=mysql_connect("localhost","epicalex","10203040"); mysql_select_db("mystiq"); $query=mysql_query("select client_images_fotos from client_images"); if(!$query){echo mysql_error();}else{echo "yes";} $total=mysql_num_rows($query); echo $total; $i=0; ?> <!--CMBookFlipHS--> <script type="text/javascript"> /*********************************************** * Book Flip slideshow script- © Ger Versluis 2003 * Permission granted to DynamicDrive.com to feature script * This notice must stay intact for use * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ // 7 variables to control behavior var Book_Image_Width=300; var Book_Image_Height=300; var Book_Border=true; var Book_Border_Color="black"; var Book_Speed=15; var Book_NextPage_Delay=2*1000; //1 second=1000 var Book_Vertical_Turn=0; // array to specify images and optional links. At least 4 // If Link is not needed keep it "" Book_Image_Sources=new Array( <?php while($i<$total) { echo '"'.mysql_result($query, $i, 'client_images_fotos').'",""'; if($i!=$total){ echo ','; } $i++; } ?> ); PHP:
thnxxxx but it gave me the same results nothing appeared even the image place am making a book flip from dreamwaver but it generates it static and i want it dynamically from the db
thnxxx i found the answer if ($result = $mysqli->query($query)) { $tmp = array(); while ($row=$result->fetch_assoc()) { $tmp[] = $row['client_images_fotos']; } } ?> <!--CMBookFlipHS--> <script type="text/javascript"> /*********************************************** * Book Flip slideshow script- © Ger Versluis 2003 * Permission granted to DynamicDrive.com to feature script * This notice must stay intact for use * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ // 7 variables to control behavior var Book_Image_Width=300; var Book_Image_Height=300; var Book_Border=true; var Book_Border_Color="black"; var Book_Speed=15; var Book_NextPage_Delay=2*1000; //1 second=1000 var Book_Vertical_Turn=0; // array to specify images and optional links. At least 4 // If Link is not needed keep it "" <?php $js = sprintf("Book_Image_Sources=new Array('%s','');",implode("','','",$tmp)); echo $js; ?> PHP:
but one thing please the first image appears empty cause the loop begins from 0 to the array length how can i make it begin with the first value