[SOLVED] Query Problem!

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Problem solved :) I made a search facility instead where you can search individual cutomers and there orders. Code go's like:

Code: Select all

<?php
$ID = $_POST['name'];
$link = mysql_connect($DBHost, $DBUser, $DBPass);
mysql_select_db($DBName) or die("Could not connect!" . mysql_error());
$query = "SELECT * FROM orders WHERE fullname = '$ID'";
$result = mysql_query($query) or die(mysql_error());

if (mysql_num_rows($result))
{
$row = mysql_fetch_assoc($result);
echo "<br><td><b>ID:</b> ".$row['ID']."</a></td><br>";	
echo "<td><b>Total:</b> $".$row['pricing']."</nobr></td><br>";
echo "<td><b>Date:</b> ".$row['date']."</nobr></td><br>";

echo "<td><b>Payment Method:</b> ".$row['payment']."</nobr></td><br>";
echo "<td><b>Full Name:</b> ".$row['fullname']."</nobr></td><br>";
echo "<td><b>Email:</b> <a href='mailto:".$row['email']."'>".$row['email']."</a></nobr></td><br>";
echo "<tr><br>";
echo "<hr color='gray' width='100%'>";
}

$query = "SELECT * FROM images AS image1, orders AS order1 WHERE image1.ID < '18' AND image1.name <> 'Sample Pak' AND image1.name <> 'Contact' AND order1.fullname = '$ID'";
$result = mysql_query($query) or die(mysql_error());

while (true)
{
 $row = mysql_fetch_assoc($result);
 if ($row == false) break;
 $name = $row['name'];
 $name = str_replace("-","", $name);

 if ($row[$name] != '')
 echo "<b>$name</b>  $".$row[$name].".00 [".$row[$name] / $row['price']." grams]<br>";
}
?>
Thanks for everyones help!
Post Reply