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
i tried without single quotes and with it does not work.
$insert_query="INSERT INTO users_line
(name,surname,company_name,tel_number,cell_number,email,location,main_image,about_us)
VALUES('$name','$surname','$company_name','$tel_number','$cell_number','$email','$location','$main_image','$about_us')";
if(mysqli_query($connect,$insert_query==true)){
echo " <script>alert('successfully Posted') </script> ";
} else{ echo " h1> Did not work </h1>";
try
$connect->query($insert_query) to run the query.
Try this.
$insert_query="INSERT INTO
users_line (name,surname,company_name,tel_number,cell_number,email,location,main_image,about_us)
VALUES('$name', '$surname','$company_name', '$tel_number', '$cell_number', '$email', '$location', '$ main_image', '$about_us')";
mysqli_query($connect,$insert_query);
if(mysqli_affected_rows($connection) > 0){
echo "It is working";
}
else{
echo "Not Working!";
You had echo " h1> Did not work </h1>"; that should be echo "<h1> Did not work </h1>";
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
My search is running perfectly but I need to link each result to a description page. Any ideas as to how to do it?
<?php
session_start();
require_once 'login.php';
$conn = mysqli_connect($server,$user,$password,$dbase);
if(!$conn){
die("Failure to connect".mysqli_connect_error());
}
$id = $_SESSION['twitcher'];
$srch = $_POST['searchstr'];
$sql = "select * from gallery where title like '%$srch%'";
$result = mysqli_query($conn,$sql);
if(mysqli_num_rows($result) > 0){
while ($rows=mysqli_fetch_assoc($result)){
echo $rows['title'].$br.$br;
}
}else echo "No posts found.";
mysqli_close($conn);
?>
Exactly as #Dagon stated: You need to simply echo out a link tag (<a>)
while ($rows=mysqli_fetch_assoc($result)) {
echo "<a href='/link_to_where_you_want_to_go'>" . $rows['title'] . "</a>" . $br . $br;
}
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
i want to echo 3rd column's value up to the last column
i know i can do this by echo $result[3]; echo $result[4]; echo $result[5]; and so on up to the last but is there any way to do it this way echo $result[3] UNTIL $result[last]; ?
please help me
thanks in advance
You need to return numeric indices from DB query and simple for loop. Notice the MYSQL_NUM flag added:
while($result=mysql_fetch_array($query, MYSQL_NUM)) {
for ($index = 3; $index < count($result); $index++) {
echo $result[$index];
}
}
EDIT:
An alternative. Use mysql_fetch_assoc and access your data using column names instead of numeric indices. This improves readablity of code as well.
while ($row = mysql_fetch_assoc($result)) {
echo $row["userid"];
echo $row["fullname"];
echo $row["userstatus"];
}
mysql_free_result($result);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
here is my code, it takes informations from database, but how can i stop TH from repeating in every row pls help :
echo '<table border="0">'."\n";
$result = mysql_query("select projektet.p_id, projektet.p_emri, arqitekti.a_emri, arqitekti.a_mbiemri, llojet.ll_emri, projektet.p_marrjes, projektet.p_dorrezimit, projektet.p_cmimi from projektet,arqitekti,llojet where projektet.a_id = arqitekti.a_id and projektet.ll_id = llojet.ll_id order by p_id desc");
while ($row = mysql_fetch_row($result) ) {
echo "<TR><TH>ID<TH>Emri Projektit<TH>Emri Arqitektit<TH>Mbiemri<TH>Lloji projektit<TH>Data Marrjes<TH>Data Dorrezimit<TH>Cmimi<TH>Opcionet";
echo "<tr><td>";
echo("$row[0]");
echo("</td><td>");
echo("$row[1]");
echo("</td><td>");
echo("$row[2]");
echo("</td><td>");
echo("$row[3]");
echo("</td><td>");
echo("$row[4]");
echo("</td><td>");
echo("$row[5]");
echo("</td><td>");
echo("$row[6]");
echo("</td><td>");
echo("$row[7]");
echo("</td><td>");
echo('<a href=projekt_edit.php?id='.($row[0]).'><img src="images/modifiko.png" /></a> ');
echo('<a href=projekt_fshi.php?id='.($row[0]).'><img src="images/fshi.png" /></a> ');
echo("</tr>\n");
and here is how it looks .. well its repeating TH and i dont want it :
http://i.imgur.com/gKqYIuy.png
Write this statement before While loop
echo "<TR><TH>ID<TH>Emri Projektit<TH>Emri Arqitektit<TH>Mbiemri<TH>Lloji projektit<TH>Data Marrjes<TH>Data Dorrezimit<TH>Cmimi<TH>Opcionet";
while ($row = mysql_fetch_row($result) ) {
...
}
Write header before while loop.
echo "<TR><TH>ID<TH>Emri Projektit<TH>Emri Arqitektit<TH>Mbiemri<TH>Lloji projektit<TH>Data Marrjes<TH>Data Dorrezimit<TH>Cmimi<TH>Opcionet";
while ($row = mysql_fetch_row($result) ) {
// other stuff;
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a database table called 'partners'. I want to echo this table into a html/php table which has 5 columns id, channel, email, paypal, and network. I also wan't a form that adds new people to the table through the website.
<?php
mysql_connect("localhost", "mysql_user", "mysql_password"); //your parameters here
mysql_select_db("mydb"); //you DB name here
$q = "SELECT id, channel, email, paypal, network FROM partners;";
$result = mysql_query($q);
echo "<table>";
echo "<tr><td>id</td><td>channel</td><td>email</td><td>paypal</td><td>network </td></tr>";
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo "<tr>";
echo "<td>".$row[0]."</td>";
echo "<td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."</td>";
echo "<td>".$row[4]."</td>";
echo "</tr>";
}
echo "</table>";
mysql_free_result($result);
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
New to php. Trying to create a list of images with text in a loop. The script works fine with just , but I want to add a class name to it so that I can control it with css, but I am getting an error. Seems not to flow cleanly with HTML. Any suggestions?
$rs = $conn->Execute("SELECT ProductName, ProductID FROM Products ");
//opens a recordset from the connection object
while (!$rs->EOF) {
$fv1=$rs->Fields("ProductID");
$fv2=$rs->Fields("ProductName");
print "<div class="product-img"> ";
print "<a href='moredetails.php?productid=$fv1'>";
print "<img src = \"thumbs/artifact-$fv1.jpg\" alt = \"Artifact-$fv1\"</a><br>";
print "<a href='moredetails.php?productid=$fv1'>";
print "$fv2</a><br>";
print "</div>";
$rs->MoveNext();
}
$rs->Close();
The double quotation will close the php function, try to use a single quotation for your class attr.
print "<div class='product-img'> ";
or escape it
print "<div class=\"product-img\"> ";
Change
print "<div class="product-img"> ";
to
print "<div class=\"product-img\"> ";