I neeed some help with the next and preview buttons, i want to make a button show me the next or preview information of my data but I don´t know how, also it have to stay in the same webpage. What i mean is that i have thousands of data and im showing only 10, so the next botton is to refresh and show the next 10 rows of information. Here is my code:
<td><table border="2" cellpadding="0">
<tr>
<th colspan='9'>Ejemplares</th>
<tr>
<td width="150">
Titular
</td>
<td width="150">
Criador
</td>
<td width="125">
Nombre
</td>
<td width="80">
Chip
</td>
<td width="80">
Estado
</td>
<td width="60">
Capa LG
</td>
<td width="50">
Sexo
</td>
<td width="125">
Grado Generacional
</td>
</tr>
<?php
$database="caballos"; //database name
$con = mysqli_connect("127.0.0.1","root" ,"",$database)
or die('Could not connect to database server ');
$query = "SELECT * FROM caballo";
$result = mysqli_query($con,$query);
$nfilas = mysqli_num_rows ($result);
for ($i=0; $i<$nfilas; $i++)
{
$resultado = mysqli_fetch_array ($result);
print ("<TR>\n");
print ("<TD width='150px'>" . $resultado['titular'] . "</TD>\n");
print ("<TD width='150px'>" . $resultado['criador'] . "</TD>\n");
print ("<TD width='125px'>" . $resultado['nombre'] . "</TD>\n");
print ("<TD width='75px'>" . $resultado['chip'] . "</TD>\n");
print ("<TD width='75px'>" . $resultado['estado'] . "</TD>\n");
print ("<TD width='150px'>" . $resultado['capalg'] . "</TD>\n");
print ("<TD width='50px'>" . $resultado['sex'] . "</TD>\n");
print ("<TD width='150px'>" . $resultado['grado_gen'] . "</TD>\n");
print ("</TR>\n");
}
mysqli_close($con);
?>
</tr>
</td>
<tr>
<td colspan="2">
<input type="button" value="INGRESAR" onclick= "self.location.href = 'ing_caballos.php'" /></td>
<td colspan="2">
<input type="button" value="GENEALOGIA" onclick= "self.location.href = 'genealogia.php'" /></td>
<td>
<!--hear goes the next and preview buttons-->
</td>
<td colspan="2">
<input type="button" value="ELIMINAR" onclick= "self.location.href = 'del_caballo.php'" />
</td>
</tr>
</tr>
You are looking for a pagination script , try this tutorial
Related
I'm trying to create echo image in while loops with table, but I'm getting the error . please see part of the code
$image = $rows['image'];
$sql = "SELECT * FROM boxes ";
$result = $db->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
if ($row['status'] == 1)
$visible = "visible";
else
$visible = "hidden";
if ($row['side'] == 1)
$side = "right";
else if ($row['side'] == 2)
$side = "left";
else $side = "not set yet";
echo "
<tr>
<td width=\"15%\" rowspan=\"3\"><img src="data:image' image \. ($row['image']).'" />';</td>
<td width=\"85%\" colspan=\"5\">".$row['title_boxe'] . "</td>
</tr>
<tr>
<td colspan=\"5\">desc</td>
</tr>
<tr>
<td>Visible</td>
<td>sss</td>
<td><form method='post'><input type='hidden' name='id' value='" . $row['id_boxe'] . "'/>
<input type='submit' name='update' value='Update' class=\"btn btn-primary\"/></form></td>
<td> </td>
</tr>
<tr>
<td colspan=\"6\">hr</td>
</tr>
<tr>
<td colspan=\"6\"> </td>
</tr>
";
}
}
?>
</tbody>
</table>
what wrong with this line of code inside of php that i can figure out how to solve this...
<td width=\"15%\" rowspan=\"3\"><img src="data:image' image \. ($row['image']).'" />';</td>
many thanks for your help.
Seems that you echo is wrong ( and to me is not clear what you are doing with <src='data:image image .. if you need a \ but this interfer
with quote escape it using \
echo "
<tr>
<td width='15%' rowspan='3'><img src='../image/box-manage/" . $row['image'] ."' />;</td>
<td width='85%' colspan='5'>". $row['title_boxe'] . "</td>
</tr>
<tr>
<td colspan='5'>desc</td>
</tr>
<tr>
<td>Visible</td>
<td>sss</td>
<td><form method='post'><input type='hidden' name='id' value='" . $row['id_boxe'] . "'/>
<input type='submit' name='update' value='Update' class='btn btn-primary'/></form></td>
<td> </td>
</tr>
<tr>
<td colspan='6'>hr</td>
</tr>
<tr>
<td colspan='6'> </td>
</tr>";
I have the following code to display posts in a forum discussion.
I would like the person who posted a reaction to see two buttons:
A delete button
An edit button
I can't seem to find a way to connect the user session to the userid in the forumberichten table. Is there anyone who can help me with this? I've tried a lot of things, but I keep getting the buttons on all the posts.
<?php
if (isset($_REQUEST['id'])){
$id = preg_replace('#[^a-z0-9]#i', '', $_GET['id']);
}
$user = $_SESSION['SESS_USERID'];
if (isset($_REQUEST['user'])){
$user = preg_replace('#[^a-z0-9]#i', '', $_GET['user']);
}
$sql="SELECT forumberichten.bericht_id,forumberichten.discussieid,forumberichten.userid,forumberichten.omschrijving,forumberichten.datum, forumberichten.active,users.userid,users.username,users.userimage FROM forumberichten,users WHERE forumberichten.userid=users.userid AND forumberichten.active='yes' AND forumberichten.discussieid='".$id."' ORDER BY discussieid DESC";
$result = $conn->query($sql);
if ($result->num_rows >=1) {
while($row = $result->fetch_assoc()) {
echo "
<br><table width='450' border='0'>
<tr><td bgcolor='#1E1E1E'> </td>
<td colspan='5' bgcolor='#1E1E1E'><a href='user.php? id=" . $row['userid'] . "'</a> ".$row["username"]."</td>
<td> </td></tr>
<tr><td bgcolor='#1E1E1E'> </td>
<td colspan='5' bgcolor='#1E1E1E'>
";
if ($row["userimage"] == '') {
echo "
<a href='user.php? id=" . $row['userid'] . "'</a>
<img src='Images/users/nopicture.png' alt='nopicture' class='user-imagelarge' title='".$row['username']."''>
</a>
";
} else {
echo "
<a href='user.php? id=" . $row['userid'] . "'</a>
<img src='Images/users/".$row['userimage']."' class='user-imagelarge' title='".$row['username']."''>
</a>
";
}
echo "
</td>
<td> </td></tr>
<tr><td bgcolor='#1E1E1E'> </td>
<td colspan='5' bgcolor='#1E1E1E'>".$row['omschrijving']."</td>
<td> </td></tr>
<tr><td bgcolor='#1E1E1E'> </td>
<td bgcolor='#1E1E1E'>
";
echo date("d-m-y H:i",strtotime($row["datum"]));"</td>";
// HERE I DON'T KNOW WHAT TO DO SO ONLY THE POSTER OF THIS MESSAGE CAN SEE THE FOLLOWING BUTTONS:
echo "
<td bgcolor='#1E1E1E'><a href='forumberichtbewerk.php? id=" . $row['bericht_id'] . "' target='_blank'>
<input type='image' src='Images/Icons/penorange.png' width='15' height='15'></a></td>
<td bgcolor='#1E1E1E'><a href='forumberichtdelete.php? id=" . $row['bericht_id'] . "'><input type='image' class='backgroundgreyfotoos' src='Images/Icons/crossorangebutton.png' width='15' height='15' border='0' ></a></td>
<td bgcolor='#1E1E1E'></td>
<td bgcolor='#1E1E1E'></td>
<td> </td></tr>
<tr><td bgcolor='#1E1E1E'> </td>
<td colspan='5' bgcolor='#1E1E1E'><img src='Images/lijntransparant.png' width='570' height='2'></td>
<td><img src='Images/lijntransparant.png' width='35' height='2'></td></tr>
</table>
";
}
}
?>
Have been struggling with making this work. Not sure where I'm going wrong.
main page: pkg_list_30d.php
<?php
$conn = new mysqli('host', 'user', 'pwd', 'db');
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// SELECT sql query
$sql = "SELECT pkg.*, i.isotope AS pkgisotope
FROM tbl_packagereceipt pkg
INNER JOIN tbl_isotopes i
on
pkg.isotope = i.isoID
GROUP BY pkg.pkgID
ORDER BY `datereceived` DESC
LIMIT 5";
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
// output data of each row from $result
echo '
<table width="568" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="80" > </td>
<td width="110"> </td>
<td width="108"> </td>
<td width="150"> </td>
<td width="120" > </td>
</tr>
<tr>
<td> </td>
<td><strong>Date</strong></td>
<td><strong>Package #</strong></td>
<td><strong>Isotope</strong></td>
<td> </td>
</tr>
</table>';
$c = false;
while($row = $result->fetch_assoc())
{
echo '<table width="568" border="0" cellspacing="1" cellpadding="1">
<tr style="background:',(($c=!$c)? '#eee' : '#ddd' ),'">
<td width="80"> </td>
<td width="110">'.date('d-M-Y', strtotime($row['datereceived'])).'</td>
<td width="108">'.$row['pkgnumber'].'</td>
<td width="150">'.$row['pkgisotope'].'</td>
<td width="120">' . '<a class="gegevens2"
href="../patientinjection/record_inj_form.php?id=' . $row['pkgID'] . '"> ' .
"Add Patient". '</a>' . '</td>
</tr>
</table>
<br />';
echo include 'pkg_patient.php';
}
}
else {
echo 'All packages returned.';
}
$conn->close();
?>
Directly under the table within the while() I would like it to display the patients for that result. I have tried doing an include of a page, but it just shows only the top row of the main page (instead of maybe 5 or 6 rows based on query results). And it shows the number 1 under it.
The code on the pkg_patient.php is:
<?php
$conn = new mysqli(removed);
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// SELECT sql query
$pkgID = (int)$_GET[$id];
$sql = "SELECT pdi.*, radp.radiopharmaceutical AS radp, pkp.initials
FROM tbl_patientdoseinformation pdi
INNER JOIN tbl_isotopes i
ON
pdi.isotope = i.isoID
INNER JOIN tbl_radpharmaceuticals radp
ON pdi.isotope = radp.isotopeID
INNER JOIN tbl_packagepersonnel pkp
ON pdi.adminby = pkp.pkgpersonnelID
WHERE pdi.pkgnumberID='" . $pkgID . "'
GROUP BY pdi.patientdoseID
ORDER BY `datetimestated` DESC";
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
// output data of each row from $result
echo '<table width="1103" border="0" cellspacing="1" cellpadding="1">
<tr>
<td colspan="9"></td>
</tr>
<tr>
<td width="80" > </td>
<td width="110"> </td>
<td width="108"> </td>
<td width="161"> </td>
<td width="84"> </td>
<td width="151"> </td>
<td width="83"> </td>
</tr>
<tr>
<td> </td>
<td><strong>Date</strong></td>
<td><strong>Case No.</strong></td>
<td><strong>Radiopharmaceutical</strong></td>
<td><strong><div align="center">Dose</div></strong></td>
<td><strong><div align="right">State Date/Time</div></strong></td>
<td><strong><div align="right">Initials</div></strong></td>
</tr>
</table>
<br />';
$c = false;
while($row = $result->fetch_assoc())
{
echo '<table width="1103" border="0" cellspacing="1" cellpadding="1">
<tr style="background:',(($c=!$c)? '#eee' : '#ddd' ),'">
<td width="80">' . '<a class="gegevens" href="edit_inj_form.php?id=' .
$row['patientdoseID'] . '"> ' . "Edit". '</a>' . '</td>
<td width="117">'.date('d-M-Y', strtotime($row['datetimestated'])).'</td>
<td width="108">'.$row['patientID'].'</td>
<td width="161">'.$row['radp'].'</td>
<td width="84"><div align="right">'.$row['dose'].' mCi</div></td>
<td width="180"><div align="right">'.date('d-M-Y H:i',
strtotime($row['datetimestated'])).'</div></td>
<td width="83"><div align="right">'.$row['initials'].'</div></td>
</tr>
</table>';
}
}
else {
echo ' ';
}
$conn->close();
?>
You don't need to re-run the query in pkg_patient.php, all the variables from pkg_list_30d.php are accessible from pkg_patient.php once you've included it...
In pkg_list_30d.php on line 68 you use
echo include 'pkg_patient.php';
Instead you should echo the data you're wanting to display on pkg_patient.php and include it using include pkg_patient.php on pkg_list_30d.php
MSSQL query link is this;
click here for picture
and my output shows three different pictures for the same product as shown below. What I want is, if the product is the same, keep just one picture and then get the colors and sizes for that product.
Means;
My output ıs the picture below,
click here for picture
as you see there are three product in the picture but they are the same product with different colors and sizes, instead of seeing the same product every time, I want my output like in the picture below.
<table width="376" cellspacing="0" class="stats" width:100%>
<tr>
<td colspan="9" align="center"><?php echo $secim ?></td>
</tr>
<?php
while(odbc_fetch_into($sql_result, &$row)) {
$unit1 = floor($row[3]);
$unit2 = floor($row[4]);
$unit3 = floor($row[5]);
$unit4 = floor($row[6]);
$unit5 = floor($row[7]);
?>
<tr>
<td colspan="2" align="left" valign="top"><?php echo"$row[0]";?></td>
<td>36</td>
<td>38</td>
<td>40</td>
<td>42</td>
<td>44</td>
</tr>
<tr>
<td width="114" align="right" valign="top">
<img src= <?php echo"images/Resize/$row[2]"?>></td>
<td width="25" valign="top"><?php echo"$row[1]";?></td>
<td width="25"valign="top"><?php echo"$unit1";?></td>
<td width="25"valign="top"><?php echo"$unit2";?></td>
<td width="25"valign="top"><?php echo"$unit3";?></td>
<td width="25"valign="top"><?php echo"$unit4";?></td>
<td width="25"valign="top"><?php echo"$unit5";?></td>
</tr>
<?php } }?>
<?php
odbc_free_result($sql_result);
odbc_close($connection);
?>
</table>
I think this is what you are looking for, http://jsfiddle.net/sv8ZS/
while(odbc_fetch_into($sql_result, &$row)) {
$unit1 = floor($row[3]);
$unit2 = floor($row[4]);
$unit3 = floor($row[5]);
$unit4 = floor($row[6]);
$unit5 = floor($row[7]);
?>
//you can check with the index to see if its a first row or not
//This will avoid printing the same header for each row.
if (this-is-the-first row) {
<tr>
<td colspan="2" align="left" valign="top"><?php echo"$row[0]";?></td>
<td>36</td>
<td>38</td>
<td>40</td>
<td>42</td>
<td>44</td>
</tr>
}
//above if ends
<tr>
//If its not a first row then do not show the image again and merge all the next rows
if (this-is-the-first-row) {
<td width="114" align="right" valign="top" rowspan='3'>
<img src= <?php echo"images/Resize/$row[2]"?>
</td>
}
//above if ends
<td width="25" valign="top"><?php echo"$row[1]";?></td>
<td width="25"valign="top"><?php echo"$unit1";?></td>
<td width="25"valign="top"><?php echo"$unit2";?></td>
<td width="25"valign="top"><?php echo"$unit3";?></td>
<td width="25"valign="top"><?php echo"$unit4";?></td>
<td width="25"valign="top"><?php echo"$unit5";?></td>
</tr>
<?php } }?>
enter code here
<?php
echo "<table border='1'>
<tr>
<th>Model</th>
<th>Color</th>
<th>Unit</th>
</tr>";
?>
<?php
while($row =odbc_fetch_array($result)){
//if $row['sAciklama']=$row['sAciklama'] bla bla ???
if (this-is-the-first row) {
echo "<tr>";
echo "<td>" . $row['sAciklama'] . "</td>"; //Model First Element
}
if (this-is-the-first-row) {
echo "<td>" . $row['sRenkAdi'] . "</td>"; //color
echo "<td>" . $row['Kalan'] . "</td>"; //unit
echo "</tr>";
}}
echo "</table>";
?>
I just want to simplify what I am doing before, having multiple php files for all data to be listed.
Here is my html form:
<table border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#D3D3D3">
<tr>
<form name="formcheck" method="post" action="list.php" onsubmit="return formCheck(this);">
<td>
<table border="0" cellpadding="3" cellspacing="1" bgcolor="">
<tr>
<td colspan="16" height="25" style="background:#5C915C; color:white; border:white 1px solid; text-align: left"><strong><font size="3">List Students</td>
</tr>
<tr>
<td width="30" height="35"><font size="3">*List:</td>
<td width="30"><input name="specific" type="text" id="specific" maxlength="25" value="">
</td>
<td><font size="3">*By:</td>
<td>
<select name="general" id="general">
<font size="3">
<option>Year</option>
<option>Address</option>
</select></td></td>
</tr>
<tr>
<td width="10"><input align="right" type="submit" name="Submit" value="Submit" > </td>
</tr>
</form>
</table>
And here's the form action:
<?php
$con = mysql_connect("localhost","root","nitoryolai123$%^");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("school", $con);
$gyear= $_POST['general'];
if ("YEAR"==$_POST['general']) {
$result = mysql_query("SELECT * FROM student WHERE YEAR='{$_POST["specific"]}'");
echo "<table border='1'>
<tr>
<th>IDNO</th>
<th>YEAR</th>
<th>LASTNAME</th>
<th>FIRSTNAME</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['IDNO'] . "</td>";
echo "<td>" . $row['YEAR'] . "</td>";
echo "<td>" . $row['LASTNAME'] . "</td>";
echo "<td>" . $row['FIRSTNAME'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
mysql_close($con);
?>
Please help, how do I equate the YEAR(column in mysql database) and the option box(general).
if ("YEAR"==$_POST['general'])
please correct me if I'm wrong.
<option>Year</option>
you just need to change that to
<option value="YEAR">Year</option>
also definitely have a read of this page : http://en.wikipedia.org/wiki/SQL_injection because otherwise your code is wide open to nasty attacks.
[edit : also pay heed to the comments on your original question, posting your real root username/password on a website isn't a very good idea.]
if ("YEAR"==$_POST['general']) {
$result = mysql_query("SELECT * FROM student WHERE date_format(YEAR, '%Y')='{$_POST["specific"]}'");