Looking to fix my PHP code.

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

phpnewbie34
New php-forum User
New php-forum User
Posts: 14
Joined: Mon Apr 22, 2013 4:00 am

Looking to fix my PHP code.

Postby phpnewbie34 » Fri Apr 26, 2013 5:11 am

Good day friends and programmers,

How do I fix my code so that it outputs more like Craigslist.

What I'm trying to do is basic PHP to make a classified type of site.

My code is: while($row = mysqli_fetch_array($result))
{
$time = date("l jS F Y", $row['Date']);
if(time("l jS F Y") == $time)
{
echo "<h1>" . $time . "</h1>";
echo "<table border='1' width='1000'>
<tr>
<th>ID</th>
<th>Name</th>
<th>Book</th>
<th>Subject</th>
<th>Price</th>
<th>Description</th>
<th>Picture</th>
</tr>";
echo "<tr>";
echo '<td><a class="top" href="DetailPage.php?ID=' . $row["ID"];
echo '">' . $row['ID'] . '</a></td>';
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['book'] . "</td>";
echo "<td>" . $row['subject'] . "</td>";
echo "<td>" . $row['Price'] . "</td>";
echo "<td>" . $row['Description'] . "</td>";
echo "<td>" . "<img src=\"" . $row['picname'] . "\" width=100 height=100 />" . "</td>";
echo "</tr>";
echo "</table>";
}

}

I want them listed by Date. The only problem is I'm trying to have one day per however number of advertisements that are listed.

So like...

Monday
blah
blah
blah

Sunday
blah
blah
blah

Saturday
blah
blah
blah

I almost had it working please advise me

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Looking to fix my PHP code.

Postby johnj » Fri Apr 26, 2013 7:03 pm

You need to create two rows for each item, one for date and another for details.


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests