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>";
Related
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
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>
";
}
}
?>
Hi to all i have a problem, i want to remove the duplicate value from my looping
eg.
I have a 4 record,
It must be 4 records display from my output, the problem is, it display a 16 records that's why I need to remove duplicate from my looping statement
See my code below
coming from submit
<input type='text' value='<?php echo "$row[partyid]"; ?>' name='phonenum[]' readonly />
for ($i=0; $i<sizeof($phonenum);$i++)
{
$sql = "SELECT *
FROM
$table2,
$table3
WHERE
$table2.billdate = '$date'
AND $table3.tel_three LIKE '%$phonenum[$i]%'
";
<?php if( $rs == null ):?>
<tr>
<td align='center'><font size=1>0</font></td>
<td align='center'><font size=1>0</font></td>
<td align='center'><font size=1>0</font></td>
<td align='center'><font size=1>0</font></td>
<td align='center'><font size=1>0</font></td>
</tr>";
<?php else:?>
<?php while( $row = mysql_fetch_assoc($rs) ):
?>
<tr>
<form action='flookup.php' method='post'>
<td align='center'><?php echo "<font size=1>".$row['billdate']."</font>"; ?></td>
<td align='center'><?php echo "<font size=1>".$row['calldate']."</font>"; ?></td>
<td align='center'><?php echo "<font size=1>".$row['partyid']."</font>"; ?></td>
<td align='center'><?php echo "<font size=1>".$row['billedamount']."</font>"; ?></td>
<td align='center'>
<?php echo "<font size=1>".$row['partyid']."</font>"; ?>
<input type='hidden' value="<?php echo $row['partyid']; ?>" name='phonenum' readonly />
</td>
<td align='center'><?php echo "<font size=1>".$row['value']."</font>"; ?>
<input type='hidden' value="<?php echo $row['value']; ?>" name='sipvalue' readonly />
<td align='center'><input type='text' value="<?php echo $row['value']; ?>" name='value' readonly />
</td>
</tr>
<?php endwhile;?>
<?php endif;
}
?>
You need to modify your SQL statement to add a joining condition between $table2 and $table3
$sql = "SELECT *
FROM
$table2,
$table3
WHERE
$table2.billdate = '$date'
AND $table3.tel_three LIKE '%$phonenum[$i]%'
AND $table2.something = $table3.something
";
hi everyone im creating simple posting grade online.
the problem is how i can save all value inside the while loop
here is the code
$sql1 = mysql_query("SELECT * FROM tblsubjecschedule where sched_id='".$col."' ")or die(mysql_error());
while($val=mysql_fetch_array($sql1)){
$Subject=$val['Subject'];
}
echo "<tr><td width=''><font face='Arial' size='3pt'>Subjec Code</td><td width=''><font face='Arial' size='3pt'>".$Subject."</td></tr><tr>
<td width=''><font face='Arial' size=''>Student Name</td>
<td width=''><font face='Arial' size=''>Course</td>
<td width=''><font face='Arial' size=''>Prelim</td>
<td width=''><font face='Arial' size=''>Midterm</td>
<td width=''><font face='Arial' size=''>Semi</td>
<td width=''><font face='Arial' size=''>Final</td>
</tr>";
echo "</thead>
<tfoot></tfoot>
<tbody>";
$sql = mysql_query("SELECT * FROM tblstudntsub where Sublink='".$control."' order by studname ASC")or die(mysql_error());
$a=0;
$b=1;
while($row=mysql_fetch_assoc($sql)){
$id=$row['id'];
$name=$row['studname'];
$cor=$row['course'];
$yl=$row['YearLevel'];
echo"<tr bgcolor='#E6E6E6'>
<td align='left'><p align='left'>".$b.".".$name."</p><input type='hidden' name='cont[$a]' value=".$id."></td>
<td><p align='left'>".$cor."</p></td>
<td> <input type='text' name='pre[$a]' value=''style='width:40px;'></td>
<td> <input type='text' name='mid[$a]' value=''style='width:40px;' ></td>
<td> <input type='text' name='semi[$a]' value=''style='width:40px;' ></td>
<td> <input type='text' name='fin[$a]' value=''style='width:40px;' ></td>
</tr>";
$a++;
$b++;
}
echo " <tr><td>
<input type='submit' name='save[$a]' value='Save'/>
</td></tr>";
echo "</tbody><table>";
sorry for my bad grammar hope you understand what i mean.
THANK YOU IN ADVANCE
Create an array to save all the subject,
Like
$subject= array();
$i=0;
while($row=mysql_fetch_assoc($records))
{
$subject[$i]=$row['subject'];
$i++;
}
Hope it helps
better to write code inside the loop like this
while(.......)
{
...
?>
<tr>
<td>fdsf</td>
</tr>
<?php
}
?>
Construct an array for each value and store data to it.
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"]}'");