alexa-tracking

[Ask Help] Tampil image horizontal dengan script Php

Main Content

1024
1024
KASKUS
51
244
https://www.kaskus.co.id/thread/54cc87a6582b2e25248b456f/ask-help-tampil-image-horizontal-dengan-script-php
[Ask Help] Tampil image horizontal dengan script Php
Sebelumnya mohon maap kalau salah tempat,

Hallo kk/cc yang budiman, bisa mohon tolong yang da mahir Php.
dengan script di bawah ini
==============================================================
<?php
// fetch all records
$sql = "SELECT * FROM tbl_images WHERE 1 ";
try {
$stmt = $DB->prepare($sql);
$stmt->execute();
$images = $stmt->fetchAll();
} catch (Exception $ex) {
echo $ex->getMessage();
}
?>
<table class="bordered">
<?php
if (count($images) > 0) {
foreach ($images as $img) {
?>
<tr>
<td style="text-align: center;">
<a href="uploads/<?php echo $img[" target="_blank">
<</a>
</td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="3">No images in the database.</td>
</tr>
<?php }
?>
</table>
==============================================================

Script diatas kalau di run tampilan image nya adalah Vertical, dari atas ke bawah berbaris,
Nah gimana ya supaya di ganti menjadi Horizontal atau dari kiri ke kanan untuk image display di layer kita

Mohon Bantuan nya ya kk/cc yang budiman
Atas perhatiaanya saya ucapkanTerima kasih
Itu script copas apa bikin sendiri gan??
klo bikin sendiri harusnya agan sudah sedikit tahu tentang struktur table pada HTML..
apa itu tag <tr> <th> <td> apa kegunaan dari tag tersebut dan apa hasil dari tag tersebut..
yg agan gunakan..
<tr> ==> Table Row ==> Baris Tabel
<td> ==> Table Data(Column) ==> Data pada Tabel / Kolom pada table
seperti tertera di sini => http://www.w3schools.com/html/html_tables.asp

sekarang coba bedakan dan pahami perbedaan dari script di bawah..

Spoiler for 1:

Dengan ..
Spoiler for 2:


yg di script agan tuh seperti contoh 1..yg di looping/di ulang-ulang <tr> atau baris tabel..ya tampilannya jadi menyusun ke bawah(vertical)..
kalau agan ganti dengan seperti contoh 2..<td> atau kolom tabel yg di looping/di ulang-ulang..tampilannya baru menyamping(horizontal)

Untuk gambar..dari pada pakai <table> <tr> <td> kenapa g pakai <ul> <li> atau <div>..lebih mudah di utak-atik stylenya...
Quote:


ini sricpt asal copypaste emoticon-Smilie
terima kasih uda kasih clue nya, ok kalau gitu aku coba lagi.

Hallo kk tidak emoticon-Wink
maap ganggu ya, ini mau tanya soal script php lagi, kemarin di kasih clue uda bisa emoticon-Big Grin Terima kasih ya

sekarang aku mau tanya soal script ini
=================================================================================

<?php
/*
@author: Shahrukh Khan
@website: http://www.thesoftwareguy.in
@facebook fanpage: https://www.facebook.com/Thesoftwareguy7
*/
error_reporting(E_ALL & ~E_NOTICE);
@ini_set('post_max_size', '64M');
@ini_set('upload_max_filesize', '64M');

/* * *********************************************** */
// database constants
define('DB_DRIVER', 'mysql');
define('DB_SERVER', 'localhost');
define('DB_SERVER_USERNAME', 'root');
define('DB_SERVER_PASSWORD', '');
define('DB_DATABASE', 'image_test');

$dboptions = array(
PDO::ATTR_PERSISTENT => FALSE,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);

try {
$DB = new PDO(DB_DRIVER . ':host=' . DB_SERVER . ';dbname=' . DB_DATABASE, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, $dboptions);
} catch (Exception $ex) {
echo $ex->getMessage();
die;
}

if (isset($_POST["sub1"]) || isset($_POST["sub2"])) {
// include resized library
require_once('./php-image-magician/php_image_magician.php');
$msg = "";
$valid_image_check = array("image/gif", "image/jpeg", "image/jpg", "image/png", "image/bmp");
if (count($_FILES["user_files"]) > 0) {
$folderName = "uploads/";

$sql = "INSERT INTO tbl_images(image_name) VALUES (:img)";
$stmt = $DB->prepare($sql);

for ($i = 0; $i < count($_FILES["user_files"]["name"]); $i++) {

if ($_FILES["user_files"]["name"][$i] <> "") {

$image_mime = strtolower(image_type_to_mime_type(exif_imagetype($_FILES["user_files"]["tmp_name"][$i])));
// if valid image type then upload
if (in_array($image_mime, $valid_image_check)) {

$ext = explode("/", strtolower($image_mime));
$ext = strtolower(end($ext));
$filename = rand(10000, 990000) . '_' . time() . '.' . $ext;
$filepath = $folderName . $filename;

if (!move_uploaded_file($_FILES["user_files"]["tmp_name"][$i], $filepath)emoticon-Wink {
$emsg .= "Failed to upload <strong>" . $_FILES["user_files"]["name"][$i] . "</strong>. <br>";
$counter++;
} else {
$smsg .= "<strong>" . $_FILES["user_files"]["name"][$i] . "</strong> uploaded successfully. <br>";

$magicianObj = new imageLib($filepath);
$magicianObj->resizeImage(100, 100);
$magicianObj->saveImage($folderName . 'thumb/' . $filename, 100);

/* * ****** insert into database starts ******** */
try {
$stmt->bindValue(":img", $filename);
$stmt->execute();
$result = $stmt->rowCount();
if ($result > 0) {
// file uplaoded successfully.
} else {
// failed to insert into database.
}
} catch (Exception $ex) {
$emsg .= "<strong>" . $ex->getMessage() . "</strong>. <br>";
}
/* * ****** insert into database ends ******** */
}
} else {
$emsg .= "<strong>" . $_FILES["user_files"]["name"][$i] . "</strong> not a valid image. <br>";
}
}
}


$msg .= (strlen($smsg) > 0) ? successMessage($smsg) : "";
$msg .= (strlen($emsg) > 0) ? errorMessage($emsg) : "";
} else {
$msg = errorMessage("You must upload atleast one file");
}
}
?>
===========================================================================================

Nah script diatas itu auto rename kk, gimana ya biar gak auto rename file/image yang di upload.

mohon bantuan nya ya kk tidakkkk emoticon-Smilie
Terima kasih

Coba ganti
Code:
$filename = rand(10000, 990000) . '_' . time() . '.' . $ext;


menjadi
Code:
$filename = $_FILES["user_files"]["name"][$i];


kalau pake fungsi yg diatas script dibawah ini bisa di hilangkan(hapus)..karena fungsi yg diatas udh sekalian ambil extension filenya juga
Code:
$ext = explode("/", strtolower($image_mime));
$ext = strtolower(end($ext));
ini cuman permasalahan tr dan td ajah gan....
coba belajar script table....
Quote:


ok kk, ttiiddaakk. terima kasih, di coba lagi emoticon-Big Grin

Quote:


baik kk cweaver, terima kasih
×