Jump to content

understanding mysql_query?


DuaneCawaling
Go to solution Solved by 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

Edited by DuaneCawaling
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.