<?php
//so LIISTEN CAREFULLY
/*
we have to TABLE in data base first one is 'emglish'->where article is added
and second TABLE is 'images' where we will insert ARTICLE id which is called 'artid' also insert 'id' which is picture id and 'fullname' which is image name
which has changed name with str_shuffle().
*/
//this is where you enter article and upload images--->
$form = '
<center>
<form action="" method="POST" id="form" enctype="multipart/form-data">
<br><p>title: </p><input type="text" name="title" class="inputadtext" id="d" /><br><br>
<input type="file" name="files[]" multiple /><br><br>
<p>short story:</p><textarea cols="60" rows="10" name="shortstory" class="inputadtext"></textarea><br><br>
<p>full story: </p><textarea cols="60" rows="20" name="fullstory" class="inputadtext"></textarea><br><br>
<input type="submit" name="submit" value="Add Tour" class="inputadtext" />
</form>
</center>
';
if(isset($_POST['submit'])){
$title = mysql_real_escape_string($_POST['title']);
$short_story = mysql_real_escape_string($_POST['shortstory']);
$full_story = mysql_real_escape_string($_POST['fullstory']);
if($title && $short_story && $full_story){
mysql_query("INSERT INTO emglish VALUES ('', '$title', '$short_story', '$full_story', '', 'en','','')");
$query = mysql_query("SELECT id FROM emglish WHERE title='$title'");
$fetch = mysql_fetch_assoc($query);
$id = $fetch['id'];
$files = $_FILES['files'];
foreach($files['name'] as $p=>$n){
$type = $files['type'][$p];
$subtype = substr($type, 6);
$tmp = $files['tmp_name'][$p];
#$hashedname = md5(md5($name));
$title = $_POST['title'];
/**/
$string="qwertyuiopasdfghjklzxcvbnm1234567890";
$hashedname = str_shuffle($string);
$fullname = $hashedname . ".$subtype";
if($subtype=="jpeg" or $subtype=="jpg" or $subtype=="png"){
#inserting IMAGE NAME into text
mysql_query("INSERT INTO images VALUES ('$fullname', '', '$id')") or die(mysql_error());
move_uploaded_file($tmp, "../upload/".$fullname);
echo "<span style='float:left;margin-left:30px;'><img width='100px' height='100px' src='../upload/$fullname'><br><span style='color:skyblue;'><b>Upload complete</b></span></span></center>";
}else
echo "<center><span style='color:red'><b>Not an Image</b></span> <b>$n</b>";
}
/*
after that you are echoing your pictures and article title...
for css you have to give them classs and not an IDs i mean container and header which is decleared in the following code....
*/
$q = mysql_query("SELECT * FROM emglish WHERE lang='$lang' order by id DESC");
while($fetch = mysql_fetch_array($q)){
echo "<span id='showarticle'>";
$dbtitle = $fetch['title'];
$id=$fetch['id'];
$subtitle = mb_substr($dbtitle, 0, 70) . '...';
$pic_query = mysql_query("SELECT * FROM images WHERE artid='$id'");
echo "<p style='margin-bottom:8px;float:left;width:540px;word-wrap:break-word;'><a href='./index.php?page=fullstory&id=$id&lang=$lang'><b>" . $subtitle . "</a></b></p>";
echo "<a href='./index.php?page=fullstory&id=$id&lang=$lang'>";
echo "<b>" . $f['title'] . "</b><br><br>";
echo "<center><div class='container2'>
<div class='header3'>
";
while($pic_fetch = mysql_fetch_array($pic_query)){
$picture = $pic_fetch['fullname'];
echo "<img style='width:400px;height:400px;border-radius:5px;' src='./upload/". $picture ."' />";
}
echo "</div></div></center>";
echo "</a>";
echo "</span>";
/*
after that you can cycle this image and this slider with jquery cycle plugin....
*/
?>