underneath is a small script which shows if someone has a birthday today.
The only thing what i miss is a line under the name with the text "Happy birthday" It should only appear, ofcourse is someone has a birthday. how can i achieve this?
<html>
<head>
<title>Vandaag Jarig:</title>
</head>
<body>
<table>
<thead>
</thead>
<tbody>
<?php
$connect = mysql_connect("localhost","root", "****");
if (!$connect) {
die(mysql_error());
}
mysql_select_db("my_site_db");
$results = mysql_query
("SELECT * FROM aevinew2_verjaardagen WHERE DAY(geboortedatum) = DAY (CURDATE ()) AND MONTH(geboortedatum) = MONTH(CURDATE())");
if(mysql_num_rows($results) > 0){
while($row = mysql_fetch_array($results)) {
?>
<tr>
<td><?php echo $row['Naam']?></td>
<td><?php echo $row['Afdeling']?></td>
</tr>
<?php
}
}else{
echo "Helaas geen taart vandaag, er is niemand jarig";
}
?>
</tbody>
</table>
</body>
</html>
Something like this? You had syntax error in your code aswell. Missing ; delimiter at end of echo command.
<td><?php echo $row['Naam'].'<br/>Happy Birthday!'; ?></td>
<td><?php echo $row['Afdeling']; ?></td>
Replace line 22 ,23 with these lines. You are missing ';' after echo statement.
<td><?php echo $row['Naam'].'<br/>Happy Birthday!'; ?></td>
<td><?php echo $row['Afdeling']; ?></td>
well, the script is working (it was already), but the only thing i need is an echo under the current echo which is just showing some text.
If i do that it letterly puts that kind of text on top include the text Echo
Related
I want to display records in the website and the $row['data'] of the table report its type (BLOB) in a database and I want to display it as a link but it doesn't appear anymore.
What Can I do ? Whats the problem here?
<?php
include 'connect.php';
extract($_SESSION);
session_start();
?>
<html>
<body >
<table>
<?php
$sql="SELECT data,report.StudID,studFName,StudLName
FROM report,student
WHERE report.SuperID={$_SESSION['supervisor']} AND
report.StudID=student.StudID ";
$result= mysqli_query($con,$sql) or die ("could not found;
".mysqli_error($con));
while ($row=mysqli_fetch_array($result) )
{
?>
<tr>
<td><?php echo '<a href="data:application/pdf;base64,'.base64_encode($row ['data']).' " height="20" width="20" />'?></td>
<td><?php echo $row['StudLName'] ?></td>
<td><?php echo $row['studFName'] ?></td>
<td><?php echo $row['StudID'] ?></td>
<?php
}
?>
</tr>
</table>
Your link won't appear because you need to enclose it with </a> and specify text in it.
<?php
echo '<a href="data:application/pdf;base64,'.base64_encode($row ['data']).' " />Pdf Link</a>'
?>
I don't think you need to specify height and width for link.
I've been turning in circles for a while now trying to understand what I have done wrong with lines 68 and 110. It comes up with:
"expects parameter 1 to be resource, boolean given"
but I don't understand where my mistake is. Would someone be able to point me in the right direction or explain my error so I can better understand?
I'm really new to PHP (only started learning it last week) so I've been mostly doing my best with tutorials and what I can find online.
Line 68 onwards:
while($row = mysql_fetch_array($query)){
$card_number = $row['card_number'];
$card_id = $row['card_id'];
$card_name = $row['card_name'];
$card_mana_img = $row['card_mana_img'];
$card_type = $row['card_type'];
$card_rarity = $row['card_rarity'];
$card_set = $row['card_set'];
}
?>
Lines 99 onwards:
<table>
<tr>
<td>Number</td>
<td>Name</td>
<td>Type</td>
<td>Mana</td>
<td>Rarity</td>
<td>Set</td>
</tr>
<?php while ($row = mysql_fetch_array($query)) { ?>
<tr>
<td><?php echo $card_number; ?></td>
<td><?php echo $card_name; ?></td>
<td><?php echo $card_type; ?></td>
<td><?php echo $card_mana_img; ?></td>
<td><?php echo $card_rarity; ?></td>
<td><?php echo $card_set; ?></td>
</tr>
<?php } ?>
</table>
<br>
<?php echo $paginationCtrls; ?><br>
<?php echo $textline2;?><br>
<?php echo $textline1;?>
Don't use this: $sql = "SELECT number FROM magicorigins_cardset";
Use this:
$sql = "SELECT count(*) FROM magicorigins_cardset";
Trying to list the data from mysql to a html table using php in main html file. I've been through all of the other questions on here and I'm sure I have mostly the same methods and code as them.
For some reason (which I suspect has something to do with mysql and not the code) the only result is a blank table with one row and five columns. Each time I try to implement the other codes they just seem to print text onto the site.
I'm very confused as I think I've done the right thing. I've even been able to list the data from mysql through php echo so I know it's there and that I can access it. Really would appreciate some help on this. Thank you.
<table border="1">
<tbody>
<?php
$connect = mysqli_connect("localhost", "daemon", "xampp", "test");
if (!$connect) {
die(mysqli_error());
}
$results = mysqli_query("SELECT title,url,details,file,submission_date FROM input");
while($row = mysqli_fetch_array($results)) {
?>
<td><?php echo $row['title']?></td>
<td><?php echo $row['url']?></td>
<td><?php echo $row['details']?></td>
<td><?php echo $row['file']?></td>
<td><?php echo $row['submission_date']?></td>
<?php
}
?>
</tbody>
</table>
You say this code is in your mail html file? And it is printing out onto the screen? Try changing your file to .php not .html! Php code won't run in a .html file, and will likely output your code directly onto the page.
Mysqli_query expect connection link as first parameter.
$results = mysqli_query($connect, "SELECT title,url,details,file,submission_date FROM input");
Just a quick not so related improvement. You can avoid inserting most of the php opening and closing clauses:
...
while($row = mysqli_fetch_array($results)){
echo "<td>".$row['title']."/td>";
echo "<td>".$row['url']"</td>";
...
}
?>
Use <tr> because table must have atleast one row(<tr>) and one column(<td>)
<table border="1">
<tbody>
<tr>
<?php
$connect = mysqli_connect("localhost", "daemon", "xampp", "test");
if (!$connect) {
die(mysqli_error());
}
$results = mysqli_query("SELECT title,url,details,file,submission_date FROM input");
while($row = mysqli_fetch_array($results)) {
?>
<td><?php echo $row['title']?></td>
<td><?php echo $row['url']?></td>
<td><?php echo $row['details']?></td>
<td><?php echo $row['file']?></td>
<td><?php echo $row['submission_date']?></td>
<?php
}
?>
</tr>
</tbody>
<table border="1">
<tbody>
<?php
$connect = mysqli_connect("localhost", "daemon", "xampp", "test");
if (!$connect) {
die(mysqli_error());
}
$results = mysqli_query($connect, "SELECT title,url,details,file,submission_date FROM input");
if (!$results) {
mysqli_error($results);
die();
}
while ($row = mysqli_fetch_array($results)) {
?>
<tr>
<td><?php echo $row['title'] ?></td>
<td><?php echo $row['url'] ?></td>
<td><?php echo $row['details'] ?></td>
<td><?php echo $row['file'] ?></td>
<td><?php echo $row['submission_date'] ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
I am using this code to create an infinite table for my mysql queries:
<table cellspacing='0'> <!-- cellspacing='0' is important, must stay -->
<!-- Table Header -->
<thead>
<tr>
<th>User</th>
<th>SteamID</th>
<th>Banned by</th>
<th>Admin SteamID</th>
<th>Time Banned (min)</th>
<th>Reason</th>
</tr>
</thead>
<!-- Table Header -->
<!-- Table Body -->
<tbody>
<?php
echo '<tr>';
for($i = 0; $bans = mysqli_fetch_array($query2); $i = ($i+1)%3){
echo '<td>'.$bans['name'].'</td>';
echo '<td>'.$bans['steamid'].'</td>';
echo '<td>'.$bans['nameAdmin'].'</td>';
echo '<td>'.$bans['steamidAdmin'].'</td>';
echo '<td>'.$bans['time'].'</td>';
echo '<td>'.$bans['reason'].'</td>';
if($i == 2)
echo '</tr><tr>';
}
echo '</tr>';
?>
</tbody>
I got that code from Mysql fetch array, table results
It works fine, except it doesn't CORRECTLY go further down than 6 rows. The other rows for whatever reason are placed to the right of my last column as shown in this screenshot:
http://puu.sh/h0qZF/a12de1dd87.png
How can I fix this? Is there something wrong with my code? Why is it happening?
Well, your looping makes no sense. Using $i to inject new rows, like is done here, is not necessary; you can just loop over each row and then output it as a row:
<table>
<!-- <thead>...</thead> -->
<tbody>
<?php while ($bans = mysqli_fetch_array($query2)): ?>
<tr>
<td><?php echo $bans['name'] ?></td>
<td><?php echo $bans['steamid'] ?></td>
<td><?php echo $bans['nameAdmin'] ?></td>
<td><?php echo $bans['steamidAdmin'] ?></td>
<td><?php echo $bans['time'] ?></td>
<td><?php echo $bans['reason'] ?></td>
</tr>
<?php endwhile ?>
</tbody>
</table>
You are making two columns.
You have code that will print out the end of the table row every two sets of data:
if($i == 2)
echo '</tr><tr>';
It should just be echo '</tr><tr>';
Use a while loop as instructed here . So something like this:
$result = $conn->query($sql);
while($bans = $result->fetch_assoc()) {
echo '<td>'.$bans['name'].'</td>';
echo '<td>'.$bans['steamid'].'</td>';
echo '<td>'.$bans['nameAdmin'].'</td>';
}
I have a file /admin/php.php which has the following:
<?php
$ID=$_GET['ID'];
require("../admin/config.php");
$sql = "SELECT * FROM contacts WHERE contacttype IN ('New','Buyer','Seller','Buyer / Seller','Investor') AND leadstatus = 'New' ORDER BY date DESC";
$space = (!empty($row['firstname']) && !empty($row['lastname'])) ? ' ' : '';
$name = $row['firstname'].$space.$row['lastname'];
$partner = $row['spousefirst'];
$cell = (!empty($row['phonecell'])) ? " {$row['phonecell']} (cell)" : '';
$email = (!empty($row['email'])) ? " {$row['email']} (email)" : '';
mysql_query($sql) or die ("Error: ".mysql_error());
?>
On another page /admin/index.php I have:
<?php require("php.php"); ?>
<tbody>
<tr>
<td><input type="checkbox" name="" id="" value="<?php echo $row['ID']; ?>"></td>
<td><strong><?php echo $name; ?></strong></td>
<td><?php echo $partner; ?></td>
<td><?php echo $row['phonecell']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo date("M jS, g:i A", strtotime($row['date'])); ?></td>
<td><?php echo $row['contacttype']; ?></td>
<td><?php echo $row['agentassigned']; ?></td>
<td><?php echo $row['leadstatus']; ?></td>
<td>View + </td>
<td>View + </td>
<td>D</td>
</tr>
</tbody>
<?php
}
mysql_close();
?>
</table>
When I run this, I get a Parse error: syntax error, unexpected '}' in /admin/index.php. I've tried removing the '}' after <?php in /admin/index.php and I get an error for unexpected $end in /admin/php.php. Really confused why this isn't working. Thanks for your help!
First of all, } should not be there. There is no opening { in this file, so there should not be a closing one.
Next up, unexpected $end - that error is in another file, so that's another problem.
The syntax of php.php looks valid, but:
your mysql_query call should return a result, and i don't see you assigning it to anything.
check that closing ?> isn't followed/preceeded by non-printable characters we do not see here, but that can make parser choke - basically, remove that line, recreate it and save the file.
<?php
}
mysql_close($sql);
?>
You have closing bracket but I can't see opening.
the "}" will cause an error from the code that is posted in your question. I'm not sure if this is all the code though.
also another question would be are you connection to a database at all? cause there is nothing in your code here that shows that either.
and you are not doing anything after the mysql_query($sql) is ran.