This is my script for printing out stuff so I can make a list:
output.php = This is supposed to fetch the 'Name' column from the database and echo a table with the column 'Name'. Then it will try to filter the 'Name' Row with with filename.php.
<?php
include 'go.php';
$sql = "SELECT Name FROM utf";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<div class=\"CSSTableGenerator style=\"width:600px;height:150px;\"><table><tr><th>Name</th></tr></div>";
// output data of each row
while($row = $result->fetch_assoc()) {
include 'filename2.php';
echo "<tr><td>".$pics."</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
$conn->close();
?>
My filename2.php: This is supposed to require the seo function
and translate rows into something I can output. I have a feeling the issue is here?
<?php
require_once ('seo.php');
$name= $row["Price"];
$pics = seo ($name);
?>
My seo.php:This removes all of the spaces and bad characters and optimizes their name:
<?php
function seo($string){
$string = str_replace(array('[\', \']'), '', $string);
$string = preg_replace('/\[.*\]/U', '', $string);
$string = preg_replace('/&(amp;)?#?[a-z0-9]+;/i', '-', $string);
$string = htmlentities($string, ENT_COMPAT, 'utf-8');
$string = preg_replace('/&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);/i', '\\1', $string );
$string = preg_replace(array('/[^a-z0-9]/i', '/[-]+/') , '-', $string);
return strtolower(trim($string, '-'));
}
?>
The out put is just
Row
Row
Row
Row
Nothing else. What am I doing wrong here?
Fixed the code after a little bit of not being stupid:
<?php
include 'go.php';
include 'seo.php';
$sql = "SELECT Name FROM utf";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<div class=\"CSSTableGenerator style=\"width:600px;height:150px;\"><table><tr><th>Name</th></tr></div>";
// output data of each row
while($row = $result->fetch_assoc()) {
$name = ('$row["Name"]');
$seo2 = seo ($row["Name"]);
$ext = '.jpg';
$pics = $seo2 . $ext ;
echo "<tr><td>".$pics."</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
$conn->close();
?>
Don't drink/smoke and try to code !