What's going on with this space between my images? PHP/HTML - php

So, currently i'm programming my own website. The design is way not finished yet, so don't blame me for that xD Well, I've got a very small problem with a gap which is not supposed to be where it is (red square in the picture below). Do you know how it comes/came there?
Thanks in advance!
My Code:
(the while loop is there the pictures are displayed)
JustBasti's website
Home
<a href='index.php?mod=news'>News</a>
<a href='index.php?mod=allnews'>All News</a>
<a href='index.php?mod=gallery'>Gallery</a>
<a href='index.php?mod=guestbook'>Guestbook</a>
<a href='index.php?mod=admin'>Administrator</a><table>
<tr>
<td>Nam liber tempor</td>
</tr>
<tr>
<td>Saturday, 11th Jun 2011, 7:00 pm</td>
</tr>
<tr>
<td><a href='albums/110611190045 - Nam liber tempor/aus.png' rel='lightbox[testalbum]'
title='aus.png'><img src='albums/110611190045 - Nam liber tempor/thumbs/aus.png' /> </a>
</td>
<td><a href='albums/110611190045 - Nam liber tempor/airport.png' rel='lightbox[testalbum]'
title='airport.png'><img src='albums/110611190045 - Nam liber tempor/thumbs/airport.png' /> </a>
</td>
<td><a href='albums/110611190045 - Nam liber tempor/fam.png' rel='lightbox[testalbum]'
title='fam.png'><img src='albums/110611190045 - Nam liber tempor/thumbs/fam.png' /> </a>
</td>
<td><a href='albums/110611190045 - Nam liber tempor/way.png' rel='lightbox[testalbum]'
title='way.png'><img src='albums/110611190045 - Nam liber tempor/thumbs/way.png' /> </a>
</td>
</tr>
while ($photos = mysql_fetch_array($photo)){
$url_thumb = $photos['url_thumb'];
$url = $photos['url'];
$title = $photos['title'];
?>
<td><a href='<? echo $url; ?>' rel='lightbox[testalbum]'
title='<? echo $title; ?>'><img src='<? echo $url_thumb; ?>' /> </a>
</td>
<?
}
The website is not online yet. I didnt use any CSS. I just coded in php and html.

You have to add colspan=3 or so (or as long as the table goes) for your first 3 rows:
the navigation bar
the latin quote
and the date
Personally I wouldn't even put them in the table, but that's me. Anyway your problem stems from the 3 rows I mentioned being stuck in a cell and forcing the width of the first column to be bigger than the image.

Most of the time problems like this depends on spaces in HTML. Try to delete all the spaces of you code, such as:
<a> </a> --> <a></a>
And you'll see the spaces will disappear.

If you are using Firefox, try plugin Firebug and right-click on the empty space, choose "edit", on its left panel it will show you all margins, paddings etc.
\If using Chrome, you dont need to install anything as by default similar addon its already there.
Eventually another great plugin for FF is WebDeveloper, in its menu go for "select">"select element" and click on your empty space.
Also you should use:
<tr>
<td colspan="4">Nam liber tempor</td>
</tr>
<tr>
<td colspan="4">Saturday, 11th Jun 2011, 7:00 pm</td>
</tr>
if you haven't got it in your CSS already

Related

XPath & PHP: Matching text after a <br>

I'm trying to sort through a large list of video links. I'm wanting to sort them by 2014, 2013, 2012, and so on, so as an example, I'm after an XPath query to get the '2014', and retrieve all the movies that match 2014.
My effort: Tried matching text and checking for text after <br>, but that retrieves every single thing after every <br> in the document!
Maybe something with a text match as well? I.e. after <br> and text() = '2014 - '?
<td>
<table>
<tbody>
<tr>
<td>
<span>
<br>
2014 -
<a id="3447" class="tippable" href="www.examplemovie.com" style="color:#fff">The MovieName1</a>
<br>
2014 -
<a id="3595" class="tippable" href="www.examplemovie.com" style="color:#fff">MovieName2</a>
<br>
Thanks!!
I would suggest trying
//a[preceding-sibling::node()[1][contains(self::text(), '2014')]]
This will actually select the a elements for 2014, which I think is what you're actually after.
You can use the following xpath expression:
//a[contains(preceding-sibling::text()[1], "2014")]
This basically means: give me all of the a tags that has a text before it, containing 2014.
Demo:
Imagine you have the following index.html file:
<table>
<tbody>
<tr>
<td>
<span>
<br/>
2014 -
<a id="3447" class="tippable" href="www.examplemovie.com" style="color:#fff">The MovieName1</a>
<br/>
2014 -
<a id="3595" class="tippable" href="www.examplemovie.com" style="color:#fff">MovieName2</a>
<br/>
</span>
</td>
</tr>
</tbody>
</table>
Then, here is the output of xmllint xpath test:
$ xmllint index.html --xpath '//a[contains(preceding-sibling::text()[1], "2014")]'
<a id="3447" class="tippable" href="www.examplemovie.com" style="color:#fff">The MovieName1</a>
<a id="3595" class="tippable" href="www.examplemovie.com" style="color:#fff">MovieName2</a>

How to merge PHP and HTML theme code? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
For a school project I need to make a webshop. Right now the products are in a table, but I really dislike the look of it, because it looks very unprofessional. This is the code:
while($product = mysql_fetch_assoc($query)) {
echo "<form action=\"add_product.php\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"productnumber\" value=\"".$product['product_id']."\" />\n";
echo "<p> <b>".$product['name'] . "</b> <br />\n";
echo "<table>";
echo "<tr>";
echo "<td>";
echo "<td>" . $product['image'] . "</td>";
echo "<td>" . $product['description'] . "</td>";
echo "</tr>";
echo "</table>";
?>
<?php
echo "Price: €".$product['price']."<br />\n";
echo "Quantity: <input type=\"text\" name=\"Quantity\" size=\"2\" maxlength=\"2\" value=\"1\" />\n";
echo "<input type=\"submit\" value=\"Add To Cart\" /></p>\n";
echo "</form>\n";
}
}
?>
Now, from the template I'm using (Modus by Luis Zono) I want to make the products show up like this page: http://luiszuno.com/themes/modus/portfolio.html with this HTML code:
<div class="featured portfolio-list">
// This is one figure, but it can be copy-pasted to infinity:
<figure>
<img src="img/dummies/gallery-1.jpg" alt="Alt text" />
<div>
Pellentesque habitant morbi
tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.
</div>
<a class="link" href="project.html"></a>
</figure>
<div class="clearfix"></div>
</div>
My coding skills aren't very good, so how can I write code that makes the products in the loop look like the portfolio-figures? (so that the dummy image will be the $product['image'] and such). I'm totally stuck right now.
I'm not going to give the answer (SO is not that kind of site), but the road how to get there.The example below is IMO the best solution here, but for your situation:
In php you can do this:
while($product = mysql_fetch_assoc($query)) {
?>
<!-- Your code here -->
<img src="example-html-image.jpg" />
<!-- Your code here -->
<?php
} // end of while
So, instead of the current echo of html you got now, you add the html you want.
You probaly want to use the fetched variables in your code, below I'll provide two examples:
while($product = mysql_fetch_assoc($query)) {
?>
<!-- You can do this -->
<img src="image<?php echo $product['id']; ?>.jpg" />
<!-- Or the short version of echo -->
<img src="image<?=$product['id'] ?>.jpg" />
<?php
}
If you want to kick it up a notch, you should not use html in your code at all. The same way you dont use JS in-page, you dont use html in php. You use a template (this is the most proper method IMO):
<!-- example.html: -->
<div> Hi, Im product <!-- NAME --> </div>
Very simple, and I use a comment to get replaced further along the line.
Then you take php, open the file, and replace the comment:
$template = file_get_contents($_SERVER['DOCUMENT_ROOT'].'loc/to/file/example.html');
$template = str_replace("<!-- NAME -->", $product['name'], $template);
echo $template;
Assumed $product['image'] = "my_picture.jpg"
Then use this:
<img src="/path/to/images/<?php echo $product['image']; ?>" />
The result in html source will be:
<img src="/path/to/images/my_picture.jpg" />

How to display 20 columns in html design

Hello I'm new to php development... I want to understand how to get details from database and display on HTML CSS... I have a database i'm saving hotel data... Now I want to pull these data and display it on website.. please find below html codes design...
<div class="offset-2">
<div class="col-md-4 offset-0">
<div class="listitem2">
<img src="images/items/item7.jpg" alt=""/>
<div class="liover"></div>
<a class="fav-icon" href="#"></a>
<a class="book-icon" href="details.html"></a>
</div>
</div>
<div class="col-md-8 offset-0">
<div class="itemlabel3">
<div class="labelright">
<img src="images/filter-rating-5.png" width="60" alt=""/><br/><br/><br/>
<img src="images/user-rating-5.png" width="60" alt=""/><br/>
<span class="size11 grey">18 Reviews</span><br/><br/>
<span class="green size18"><b>$36.00</b></span><br/>
<span class="size11 grey">avg/night</span><br/><br/><br/>
<form action="http://demo.titanicthemes.com/travel/details.html">
<button class="bookbtn mt1" type="submit">Book</button>
</form>
</div>
<div class="labelleft2">
<b>Mabely Grand Hotel</b><br/><br/><br/>
<p class="grey">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nec semper lectus. Suspendisse placerat enim mauris, eget lobortis nisi egestas et.
Donec elementum metus et mi aliquam eleifend. Suspendisse volutpat egestas rhoncus.</p><br/>
<ul class="hotelpreferences">
<li class="icohp-internet"></li>
<li class="icohp-air"></li>
<li class="icohp-pool"></li>
<li class="icohp-childcare"></li>
<li class="icohp-fitness"></li>
<li class="icohp-breakfast"></li>
<li class="icohp-parking"></li>
<li class="icohp-pets"></li>
<li class="icohp-spa"></li>
</ul>
</div>
</div>
</div>
</div>
Please Suggest at the earliest
Example:
<?php
$database_data = array(
array(
'name' => 'A', 'age' => 28, 'email' => 'a#abc.com'
),
array(
'name' => 'B', 'age' => 27, 'email' => 'b#abc.com'
),
array(
'name' => 'C', 'age' => 26, 'email' => 'c#abc.com'
),
);
?>
Now loop through data and echo your value
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php foreach($database_data as $data): ?>
<tr>
<td><?php echo $data['name']; ?></td>
<td><?php echo $data['age']; ?></td>
<td><?php echo $data['email']; ?></td>
</tr>
<?php endforeach ; ?>
</tbody>
</table>
There are so many tutorials available online around pagination with PHP and database (for example MySQL). Follow some of the below and you will understand the concept and be able to apply to your page easily.
http://www.tutorialspoint.com/php/mysql_paging_php.htm
http://php.about.com/od/phpwithmysql/ss/php_pagination.htm
http://www.developphp.com/view_lesson.php?v=289
plz use limit tag of mysql to display the as your required data ..
I want ot provide some link
1). if i use LIMIT on a mysql query, should the result set be equal to the limit?
2). Limit
and then you should set the next button which tag a parameter as Start like index.php?start=20&limit=20 and then get on your query page like
$start=isset($_GET['start'])?$_GET['start']:0;
$limit=isset($_GET['limit'])?$_GET['limit']:20;
$query = mysql_query("select * from table limit $start,$limit ");
i Hope this help ful and if you want to set the pagination in your page then follow follow links
1). Pagination of MySQL Query Results
2). Simple Pagination With PHP & MYSQL
3). PHP Pagination
hope you get solution ...

Regex to replace url in html page

i have an html page
<tr>
<td rowspan="7">
<a href="http://www.link1.com/" style="text-decoration: none;">
<img src="image1.jpg" width="34" height="873" alt="" style="display:block;border:none" />
</a>
</td>
<td colspan="2" rowspan="2">
<a href='http://www.link1.com/test.php?c=1'>
<img src="image1.jpg" width="287" height="146" alt="" style="display:block;border:none" />
</a>
</td>
<td colspan="2" rowspan="2">
<a href='http://www.url.com/test.php?c=1'>
<img src="image1.jpg" width="287" height="146" alt="" style="display:block;border:none" />
</a>
</td>
I want to replace all url in href by mytest.com?url=$link
I try with :
$messaget = preg_replace('/<a(.*)href="([^"]*)"(.*)>/','mytest.com?url=$2',$messaget);
This may help you in the short run:
preg_replace('/<a (.*)href=[\'"]([^"]*)[\'"](.*)>/', '<a $1href="mytest.com?url=$2"$3>', $messaget);
In your regex you were using href="...", that is, double quotes, but in your HTML you have a mixture of both double and single quotes.
And in the replacement string you forgot to include $1 and $3.
That said, DO NOT use regex to parse HTML. The answer by #BenLanc below is better, use that instead. Read the link he posted.
Don't use regex on HTML, HTML is not regular.
Assuming your markup is valid (and if it's not, pass it through Tidy first), you should use xpath, to grab the elements and then update the href directly. For example:
<?php
$messaget = <<<XML
<tr>
<td rowspan="7">
<a href="http://www.link1.com/" style="text-decoration: none;">
<img src="image1.jpg" width="34" height="873" alt="" style="display:block;border:none" />
</a>
</td>
<td colspan="2" rowspan="2">
<a href='http://www.link1.com/test.php?c=1'>
<img src="image1.jpg" width="287" height="146" alt="" style="display:block;border:none" />
</a>
</td>
<td colspan="2" rowspan="2">
<a href='http://www.url.com/test.php?c=1'>
<img src="image1.jpg" width="287" height="146" alt="" style="display:block;border:none" />
</a>
</td>
</tr>
XML;
$xml = new SimpleXMLElement($messaget);
// Select all "a" tags with href attributes
$links = $xml->xpath("//a[#href]");
// Loop through the links and update the href, don't forget to url encode the original!
foreach($links as $link)
{
$link["href"] = sprintf("mytest.com/?url=%s", urlencode($link['href']));
}
// Return your HTML with transformed hrefs!
$messaget = $xml->asXml();
Don't forget /m at the end of your regexp since your are using multiline source:
PHP Doc PCRE
Regex to match an url:
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
More background info

HTML , PHP search box Help

How do i define the search box as VIN , so the value in my search field is sent to the php code $VIN which then retrieves it from the database.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Victorian Car Imports</title>
</head>
<body body bgcolor= "#000000">
<table width="1359" height="1028" border="0" bgcolor="#000000" bg>
<tr>
<td width="111" height="120"><img src="Logo.png" width="111" height="120" /></td>
<td width="1238"><img src="banner.jpg" width="720" height="94" align="middle"/></td>
</tr>
<tr>
<td height="780" valign="top"><a href="index.html">
<img src="Home.png" width="100" height="35" border="0"/></a> <br/> <p>
<img src="cars.png" border="0" width="100" height="35" /> <br/>
<p>
<img src="FAQ.png" border="0" width="100" height="35" /> <br/> <p>
<img src="Order_form.png" width="100" height="35" border="0" /> <p>
<img src="Contact_us.png" width="100" height="35" border="0" /></td>
<td font color= "#FFFFFF" BODY TEXT="#FFFFFF" valign="top" ><font color="#FFFFFF" >
<form name="search" action="http://www.deakin.edu.au/~sjrem/ssss.php" method="post">
<h2> Search for a car of your choice </h2>
<?php
$VIN = $_request ["search"]
?>
<p>
<table border="0">
<tr>
<td><input type="text" name="search" /> </td>
</tr>
</table>
<p>
<input type="submit" name="action" value="search" />
</FORM>
<p>
1) This skyline R32 GTR has a low 22000K's on the clock. It has been taken car of very well. It is a 1992 model which consists of a immaculate interior and a manual gearbox. It comes equipped with Air Conditioner, Alloy Wheels, Power Steering, Power Windows and a stereo system. <p> $22000 Complied
<p>
<p><img src="R32_GTR_Front.jpeg" width="320" height="240" /><img src="R32_GTR_Rear.jpeg" width="320" height="240" />
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/nissan/skyline+gt-r/7898243/photo/?sid=300&pn=4 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/nissan/skyline+gt-r/7898243/photo/?sid=300&pn=0 -->
<p> 2) As new 2002 Nissan Silvia S15. 15000 Genuine K's with log books. This prestige car, come with Air Conditioner, Alloy Wheels, Power Steering, Power Windows, Turbo. This is a clean unmodified Silvia. Its one of a kind these days. It has been driven by our buyers in Japans, and the all clear has been given. So what are you waiting for? <p> $20000 including on road costs <p>
<img src="Silvia_front.jpeg" width="374" height="294" /><img src="Silvia_rear.jpeg" width="390" height="295" /> <p>
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/nissan/silvia/7896477/photo/?sid=300&pn=1 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan car/nissan/silvia/7896477/photo/?sid=300&pn=0 -->
3) Brand New Nissan Skyline R35 GTR. This GTR is straight from the Nissan Factory in Japan. It is a 3.8 Ltr, Right hand drive, Gun metal grey in colour. It has a manual gearbox with 6 speed control. This performance car has 320kw at all four wheels and with that comes, traction control, abs brakes, driver, passenger and side air bags, power steering, and a alarm system. Contact us, if you would like any more information. $180000 Deliverd to your door step.
<p><img src="R35_front.jpg" width="384" height="284" /><img src="R35_rear.jpg" width="360" height="285" />
<p>
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/nissan/nissan+gt-r/7901460/photo/?sid=300&pn=2 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/nissan/nissan+gt-r/7901460/photo/?sid=300&pn=0 -->
4) This 2005 Subaru Impreza arrived last week. It is one of our AWD turbo vechicles. It sports a powerful 180kw, and handles like a dream. The body is staight, and the paint is immaculate. It comes with 12 months rego, $17999
<p><img src="subaru_front.jpg" width="384" height="284" /><img src="subaru_rear.jpg" width="360" height="285" />
<p>
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/subaru/impreza/7904397/photo/?sid=300&pn=4 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/subaru/impreza/7904397/photo/?sid=300&pn=0 -->
5) Mitsubishi Evolution 2006. This car is scheduled to arrive in Victoria in two weeks. It is All wheel drive sports car, sporting a 210 kw engine. It has all the safety features, such as airbags, traction control, ABS brakes, and power steering. This is a car which will never disappoint. $35000 including all on road costs.
<p><img src="mitsubishi_front.jpeg" width="384" height="284" /><img src="mitsubishi_rear.jpeg" width="360" height="285" />
<p>
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/mitsubishi/lancer+evolution+ix+mr/7901029/photo/?sid=300&pn=2 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/mitsubishi/lancer+evolution+ix+mr/7901029/photo/?sid=300&pn=0 -->
6) Toyota Chaser 1996. Boasting many electric features, Power windows, Power mirrors, Heated seats, and HID lights. This is a car, which looks like a normal family car, but has the grunt when the power is needed. We need this car moved fast, due to our next shipment coming in September. Priced to sell! $10 999
<p><img src="chaser_front.jpg" width="384" height="284" /><img src="chaser_rear.jpg" width="360" height="285" />
<p>
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/toyota/chaser/7846594/photo/?sid=300&pn=0 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/toyota/chaser/7846594/photo/?sid=300&pn=2 -->
</FONT>
</tr>
<tr>
<td width="111" height="120">row 2 cell 3</td>
<td width="1238"><FONT color="#FFFFFF" >©Deakin University, School of Information Technology. This web page has been developed as a student assignment for the unit SIT104: Introduction to Web Development. Therefore it is not part of the University's authorised web site. DO NOT USE THE INFORMATION CONTAINED ON THIS WEB PAGE IN ANY WAY."</FONT>
</td>
</tr>
</table>
</body>
</html>
first your searchbox:
<input type="text" value="" name="vin" />
then in your php code:
$vin = mysql_real_escape_string($_POST['vin']);
//then do your query with $vin

Categories