I am having a problem with my php code, it is not pulling my table row from mysql database. Does this code look correct.
<?php
$host="localhost"; // Host name
$username="username"; // Mysql username
$password="password"; // Mysql password
$db_name="database"; // Database name
$tbl_name="marquee"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Retrieve data from database
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>
<?php
// Start looping rows in mysql database.
$rows=mysql_fetch_array($result);
?>
test
<? echo $rows['scroll'];
echo $rows['id'];
?>
Change your code to this, and try again.
For updating row through html form
Below, is the code to update but, you must post
$new_valueand$idfirst so, sql know which one to update.$result = mysql_query("UPDATE marquee SET scroll='$new_value' WHERE id='$id'")or die(mysql_error());
For the above code, you should use html form to send values like:
The above to code + the passing of variables are all you need to update that table