Jump to content

understanding mysql_query?


DuaneCawaling

Recommended Posts

<?php

$username = "root"; 
$password = "vince";
$hostname = "localhost";

$con = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
$selected = mysql_select_db("dummy") or die ("No existing database".mysql_error());

$query = mysql_query("SELECT * from prepurchase");
$row = mysql_fetch_array($query);

echo $nrow = mysql_num_rows($query); //=4

while ($row = mysql_fetch_array($query)){ //why does this loop only 3times??
	echo $bool = $row['Reply'];
	echo $id = $row['ID'];
	$getinfo = mysql_query("SELECT * from profile where studentid = '$id'");
	$bal = $getinfo['credit'];
	$num = $getinfo['contact'];
	
	if ($bool == "1")
		echo "Your order is ready for pickup.<br>";
	else 
	if ($bool == "2")
		echo "Sorry, your order cound not be processed.<br>
		Your credit is refunded. Remaining credit: $bal.<br>";
}

	
?>

 

i counted the array, it has 4 items in it..why does it loop only 3 times??

awaw1.bmp

Link to comment
https://forums.phpfreaks.com/topic/275307-understanding-mysql_query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.