I used tag inside php tag. When I run the code it appears as a link. But its not work as a link.It's mean that link is not clickable.
$data1 = mysql_query("SELECT * FROM image_upload INNER JOIN user_table
ON image_upload.user_id=user_table.user_id WHERE flag=1 ORDER BY timestamp DESC;")
or die(mysql_error());
//Puts it into an array
while($info = mysql_fetch_array($data1)){
//Outputs the image and other data
echo
'<div class="test" id='.$info['ID'].'>';
echo'<div class="username">'.$info['user_name'].'</div>';
echo'<div class="imagedisplay"><img src="uploads/'.$info['image'].'" width="230px" height=auto border="1px solid #"
-webkit-border-radius=" 20px"
-moz-border-radius= "20px"
border-radius="20px"
></div>';
echo'</div>';
}
?>
my css code is
div.test{
margin: 5px;
border: 1px solid #ffffff;
border-radius:8px;
height: auto;
width:250px;
float: left;
text-align: center;
background-color:#ffffff;
}
Can any one help me.
You have forgot to close tag on line #11
CODE
$data1 = mysql_query("SELECT * FROM image_upload INNER JOIN user_table
ON image_upload.user_id=user_table.user_id WHERE flag=1 ORDER BY timestamp DESC; ") or die(mysql_error());
//Puts it into an array
while($info = mysql_fetch_array($data1)){
//Outputs the image and other data
echo '<div class="test" id='.$info['ID'].'>';
echo '<div class="username">'.$info['user_name'].'</div>';
echo '<div class="imagedisplay"><img src="uploads/'.$info['image'].'" style="width:230px; height:auto; border:1px solid #000; border-radius:20px;"></div>';
echo '</div>';
}
?>
try following
while($info = mysql_fetch_array($data1)){
echo " <div class=\"username\"><a href=\"profile.php\" class=\"button\" title=\"\">".$info['user_name']."</div>";
}
It is probably due to the arrangement of your quotes. Try this clean version:
<?php
echo "<div class='username'>";
echo "<a href='profile.php' class='button' title=''>$info['user_name']</a>";
echo "</div>";
?>
echo '<div class="username">'.$info['user_name'].'</div>';
Try this...
Link should be close properly
'<div class="username">'.''.$info['user_name'].'</div>'.
Related
if(!empty($interest)){
foreach ($interest as $key => $value) {
echo "<div style='float:left; height:130px; width:100px; margin-left:10px; border:solid #f8f8f8; background-color: #f8f8f8;'>";
echo "<a class='avatar' href='#'><img width='90' height='40' src=".$value['item_image']."></a>";
echo "<div><i>".$value['item_name']."</i></div>";
echo "<a href='#' style='text-decoration: none; outline: none;'><span class='label label-success' value=".$value['item_id']." id=".$value['item_id']." onClick='reply_click1(this.id)'>Added</span></a>";
echo " </div>";
}
}
this is my code I'm printing images horizontally here but i need to print two images per line !
this is my output .
I need two items per row
i tried to put <hr> and <br> it did not help me ! is there any way to do this?
$counter = 0;
foreach ($interest as $key => $value) {
$counter++;
if($counter%2==0){
echo '<div style="clear:both;"></div>';
}
echo "<div style='float:left; height:130px; width:100px; margin-left:10px; border:solid #f8f8f8; background-color: #f8f8f8;'>";
echo "<a class='avatar' href='#'><img width='90' height='40' src=".$value['item_image']."></a>";
echo "<div><i>".$value['item_name']."</i></div>";
echo "<a href='#' style='text-decoration: none; outline: none;'><span class='label label-success' value=".$value['item_id']." id=".$value['item_id']." onClick='reply_click1(this.id)'>Added</span></a>";
echo " </div>";
}
}
Because you have float:left css property, you must write a <br style="clear:both" />
easy way to define your div width:50% in style or use clear:both in br
I have an Image uploaded to a folder with the filepath stored in a table along with other info (title, description). I would like this info looping inside a repeated div. Both other variables loop correctly, however the filepath variable needs to be used in a background URL and at the moment only echos the value of the last row. Thank you very much for your help, there has got to be a simple solution! -Sean
<?php
$result = mysql_query("SELECT * FROM `program`");
$values = mysql_fetch_array($result);
$globals['filepath'] = $row['filepath'];
echo "<div>"; // start a table tag in the HTML
while($row = mysql_fetch_array($result)){ //Creates a loop to loop through results
echo "<div class=wrapper3 >
<h2>" . $row['program_name'] . "</h2>
<p>" . $row['program_description'] . "</p>
</div>
<p> </br> </p>";
$globals['bgimage'] = $row['filepath'];
}
echo "</div>";
?>
<style type="text/css">
.wrapper3{
width:85%;
margin:0 auto;
padding:20px;
height:auto;
color:#FFF;
background: url(/SMLC/<?php while ($row = mysql_fetch_array($result)){ echo $globals['bgimage'];} ?>
) no-repeat;
background-size:cover;
color:#000;
height:250px;
text-align:center;
background-color:#fff;
border-radius:6px;
border:1px solid #0FF;
}
</style>
<?php mysql_close();?>
Remove the background from the .wrapper3 in css, and add it to the element as an inline style.
<?php
$result = mysql_query("SELECT * FROM `program`");
echo "<div>"; // start a table tag in the HTML
while ($row = mysql_fetch_array($result)) { //Creates a loop to loop through results
$globals['filepath'] = $row['filepath'];
echo "<div class='wrapper3' style=\"background: url('/SMLC/".$row["filepath"]."');\">
<h2>" . $row['program_name'] . "</h2>
<p>" . $row['program_description'] . "</p>
</div>
<p></br></p>";
}
echo "</div>";
?>
NOTE: Use mysqli functions or PDO instead of mysql functions, since, mysql functions are deprecated.
I wanna make the dropdown list to appear in the center of the page. How do I do that?
Code:
echo '<div class="dropCenter" align="center">';
echo '<label><SELECT name="projectDropdown" id="projectDropdown" class="projectSelect">'.'<br>';
echo '<OPTION VALUE=" ">'."".'</OPTION>';
while($row = oci_fetch_array($compCuttingResult,OCI_ASSOC)) {
$projectName = $row ['PROJECT_NAME'];
echo "<OPTION VALUE='$projectName'>$projectName</OPTION>";
}
echo '</SELECT></label><br />';
First, remove all BR and LABEL tags from the HTML markup.
Next append a closind DIV tag at the end of the markup.
PHP Code
$html = null;
$html .= "<div class=\"dropCenter\">";
$html .= "<select id=\"projectDropDown\" name=\"projectDropDown\">";
$html .= "<option value=\"\"></option>";
while($row = oci_fetch_array($compCuttingResult,OCI_ASSOC)){
$projectName = $row['PROJECT_NAME'];
$html = sprintf("<option value=\"%s\">%s</option>", $projectName, $projectName);
}
$html .= "</select>";
$html .= "</div>";
print $html;
CSS Code
<style type="text/css">
select.projectSelect{ width:280px; height:24px; margin:10px; }
select.projectSelect option{line-height:24px;}
div.dropCenter{ display:inline-block; position:absolute; width:300px; height:34px; margin-left:-150px; margin-top:-17px; background-color:#e0e0e0; border:1px solid #c0c0c0; }
</style>
use the style to the first div
margin: 0px auto;
This should put the div in center
You can use this code
margin:auto;
<div class="dropCenter" style= 'margin:auto;'>
also you will have to check what are the divs you have above this. If there is no effect with above divs this would work fine.
External Inherited Style Sheets will also have an effect.
I am trying to get information from mysql including a blob image which i shall echo with php and will have an onclick event within the php, redirecting it to another page. The onlick event will contain a mysql result which it will carry with it as seen in the code below.
My main issue is with the syntax of the code or if there is another way to do it all together. please keep in mind the output when the script is run is similiar to that of google images, bing images etc. Thank you.
<?php
$con=mysqli_connect("localhost","root","*******","media");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM movies ORDER BY `movies`.`title` ASC");
echo "<table border='3' style='margin: auto; text-align: left;background: white; padding: 3em;'>
<tr>
<th><b>Movie Title</b></th>
<th><b>Language</b></th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td style='padding-right: 2em;'><img src="data:image/jpeg;base64,' . base64_encode( $row['image'] ) . '" width="160px" height="200px";" onclick="window.location='lookup.php?pattern=" . $row['title'] . "';>";
</td>
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
Untested but here is one way you could clean up your code move style and javascript (and use some jquery) into the head:
<?php
$con=mysqli_connect("localhost","root","*******","media") or die("Failed to connect to MySQL: " . mysqli_connect_error());
$result = mysqli_query($con,"SELECT * FROM movies ORDER BY `movies`.`title` ASC");
?>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('img').each(function() {
var img = $(this);
img.click(function() {
window.location="lookup.php?pattern=" + img.attr('title');
});
});
});
</script>
<style>
table {
margin: auto;
text-align: left;
background: white;
padding: 3em;
border: 2px solid #000000;
}
table tr td {
padding-right: 2em;
}
table tr td img {
width: 160px;
height: 200px;
}
</style>
</head>
<body>
<table>
<tr>
<th>Movie Title</th>
<th>Language</th>
</tr>
<?php
while($row = mysqli_fetch_array($result)) {
echo "
<tr>
<td>
<img src=\"data:image/jpeg;base64," . base64_encode( $row['image'] ) . "\" title=\"" . $row['title'] . "\">
</td>
</tr>
";
}
?>
</table>
</body>
</html>
<?php mysqli_close($con); ?>
Or if you don't want to use javascript, you could always wrap the image around the anchor tag instead:
<td>
<a href='lookup.php?pattern={$row['title']}'>
<img src=\"data:image/jpeg;base64," . base64_encode( $row['image'] ) . "\">
</a>
</td>
You could further separate PHP and HTML code:
<?php
$con=mysqli_connect("localhost","root","*******","media");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
die();
}
$result = mysqli_query($con,"SELECT * FROM movies ORDER BY `movies`.`title` ASC");
?>
<table border='3' style='margin: auto; text-align: left;background: white; padding: 3em;'>
<tr>
<th><b>Movie Title</b></th>
<th><b>Language</b></th>
</tr>
<?php
while($row = mysqli_fetch_array($result)) {
$img = 'data:image/jpeg;base64,'
. base64_encode( $row['image'] );
?>
<tr>
<td style='padding-right: 2em;'>
<img src="<?php echo $img; ?>"
style="width: 160px; height: 200px;"
onclick="window.location='lookup.php?pattern=<?php echo $row['title']?>;'"
/>
</td>
</tr>
<?php } ?>
</table>
<?php
mysqli_close($con);
?>
You could also use some sort of templating engine to do this, but the results would be pretty much the same - I don't see much point in writing, say,
<strong>{{ title }}</strong>
instead of
<strong><?php echo $title; ?></strong>
show http://img28.imageshack.us/img28/3052/unledcwk.png
this is my html and the name and the picture is taken from php (mysql).I only want to make 3 of these things(name and picture) side by side not like a queue.So i want the name asdasddasd is in the right of the asdasd.
<?php
echo '<div class="box">';
$kategori=$_GET["kategori"];
$con = mysql_connect("localhost","root","root");
if (!$con){die('Could not connect: ' . mysql_error());}
mysql_select_db("marmaris", $con);
$bilgi= mysql_query("SELECT * FROM $kategori ");
while($sutun= mysql_fetch_array($bilgi))
{
$name=$sutun["name"];
$resb=$sutun["resbuyuk"];
echo '<div id="texttitle">'.$name.'</div>';
echo '<img src="upload/'.$resb.'" width="202" height="154" alt="resim" style="background-color: #000000" />';
echo '<div id="textdetailup">Detayları görmek için tıklayın.</div>';
}
echo '</div>';
?>
this is the code that makes them.How can i make the side by side showing.
this is the css of the box
.box {
margin-bottom: 10px;
margin-right: 10px;
float: left;
height: auto;
width: 207px;
}
The div you are using to display the image subtext is a block level element so it is pushing the content to the next line.
You need to put echo '<div class="box">'; inside the while loop, along with the corresponding </div>